11/**
22 * E2E tests for output format rendering.
3- * Uses hackernews (public, fast) as a stable data source.
3+ * Uses the built-in list command so renderer coverage does not depend on
4+ * external network availability.
45 */
56
67import { describe , it , expect } from 'vitest' ;
@@ -10,19 +11,22 @@ const FORMATS = ['json', 'yaml', 'csv', 'md'] as const;
1011
1112describe ( 'output formats E2E' , ( ) => {
1213 for ( const fmt of FORMATS ) {
13- it ( `hackernews top -f ${ fmt } produces valid output` , async ( ) => {
14- const { stdout, code } = await runCli ( [ 'hackernews' , 'top' , '--limit' , '2 ', '-f' , fmt ] ) ;
14+ it ( `list -f ${ fmt } produces valid output` , async ( ) => {
15+ const { stdout, code } = await runCli ( [ 'list ' , '-f' , fmt ] ) ;
1516 expect ( code ) . toBe ( 0 ) ;
1617 expect ( stdout . trim ( ) . length ) . toBeGreaterThan ( 0 ) ;
1718
1819 if ( fmt === 'json' ) {
1920 const data = parseJsonOutput ( stdout ) ;
2021 expect ( Array . isArray ( data ) ) . toBe ( true ) ;
21- expect ( data . length ) . toBe ( 2 ) ;
22+ expect ( data . length ) . toBeGreaterThan ( 50 ) ;
23+ expect ( data [ 0 ] ) . toHaveProperty ( 'command' ) ;
24+ expect ( data [ 0 ] ) . toHaveProperty ( 'site' ) ;
2225 }
2326
2427 if ( fmt === 'yaml' ) {
25- expect ( stdout ) . toContain ( 'title:' ) ;
28+ expect ( stdout ) . toContain ( 'command:' ) ;
29+ expect ( stdout ) . toContain ( 'site:' ) ;
2630 }
2731
2832 if ( fmt === 'csv' ) {
@@ -33,16 +37,8 @@ describe('output formats E2E', () => {
3337
3438 if ( fmt === 'md' ) {
3539 // Markdown table should have pipe characters
36- expect ( stdout ) . toContain ( '|' ) ;
40+ expect ( stdout ) . toContain ( '| command | ' ) ;
3741 }
3842 } , 30_000 ) ;
3943 }
40-
41- it ( 'list -f csv produces valid csv' , async ( ) => {
42- const { stdout, code } = await runCli ( [ 'list' , '-f' , 'csv' ] ) ;
43- expect ( code ) . toBe ( 0 ) ;
44- const lines = stdout . trim ( ) . split ( '\n' ) ;
45- // Header + many data lines
46- expect ( lines . length ) . toBeGreaterThan ( 50 ) ;
47- } ) ;
4844} ) ;
0 commit comments