11import { test , expect } from '@playwright/test' ;
2- import { expectExecutionProgressBarSucceeded , expectToMatchTimestamp } from './utils/expect' ;
3- import { readFromCodeEditor , readFromCodeEditorAsJson } from './utils/editor' ;
4- import { getLabeledValueText } from './utils/labeledValue' ;
2+ import {
3+ expectExecutionProgressBarSucceeded ,
4+ expectExecutionDetails ,
5+ expectExecutionTimings ,
6+ expectExecutionInputs ,
7+ expectExecutionOutputs ,
8+ expectOutputTexts ,
9+ expectOutputFileDownload ,
10+ } from './utils/expect' ;
11+ import { readFromCodeEditor } from './utils/editor' ;
512
613test . describe ( 'Manual Scripts' , ( ) => {
714 test ( 'Execute CSV Generation With I/O' , async ( { page } ) => {
@@ -10,9 +17,9 @@ test.describe('Manual Scripts', () => {
1017 await page . getByText ( 'example/ACME-203_output-csv' ) . click ( ) ;
1118 await page . getByRole ( 'button' , { name : 'Execute' } ) . click ( ) ;
1219
13- await page . getByRole ( 'textbox' , { name : 'Input \'count\' Users to' } ) . fill ( '5000' ) ;
14- await page . getByRole ( 'textbox' , { name : 'Input \'firstNames\' First names' } ) . fill ( 'John\nJane\nJack\nAlice\nBob\nRobert' ) ;
15- await page . getByRole ( 'textbox' , { name : 'Input \'lastNames\' Last names' } ) . fill ( 'Doe\nSmith\nBrown\nJohnson\nWhite\nJordan' ) ;
20+ await page . getByRole ( 'textbox' , { name : 'Users to' } ) . fill ( '5000' ) ;
21+ await page . getByRole ( 'textbox' , { name : 'First names' } ) . fill ( 'John\nJane\nJack\nAlice\nBob\nRobert' ) ;
22+ await page . getByRole ( 'textbox' , { name : 'Last names' } ) . fill ( 'Doe\nSmith\nBrown\nJohnson\nWhite\nJordan' ) ;
1623
1724 await page . getByRole ( 'button' , { name : 'Start' } ) . click ( ) ;
1825 await expectExecutionProgressBarSucceeded ( page ) ;
@@ -21,67 +28,50 @@ test.describe('Manual Scripts', () => {
2128 expect ( output ) . toContain ( '[SUCCESS] Users CSV report generation ended successfully' ) ;
2229
2330 await page . getByRole ( 'tab' , { name : 'Details' } ) . click ( ) ;
31+
32+ await page . waitForTimeout ( 1000 ) ;
33+ await page . screenshot ( ) ;
2434
25- const executionStatus = page . locator ( '#execution-status' ) ;
26- const executionId = await getLabeledValueText ( page , 'ID' , executionStatus ) ;
27- expect ( executionId ) . toMatch ( / ^ 2 0 2 5 \/ \d + \/ \d + \/ \d + \/ \d + \/ / ) ;
28-
29- await expect ( page . getByText ( 'admin' ) ) . toBeVisible ( ) ;
30- await expect ( executionStatus . getByRole ( 'presentation' ) . filter ( { hasText : 'succeeded' } ) ) . toBeVisible ( ) ;
31-
32- const executionTiming = page . locator ( '#execution-timing' ) ;
33- const startedAt = await getLabeledValueText ( page , 'Started At' , executionTiming ) ;
34- expectToMatchTimestamp ( startedAt ) ;
35-
36- const duration = await getLabeledValueText ( page , 'Duration' , executionTiming ) ;
37- expect ( duration ) . toMatch ( / \d + m s \( \d + s e c o n d s ? \) / ) ;
38-
39- const endedAt = await getLabeledValueText ( page , 'Ended At' , executionTiming ) ;
40- expectToMatchTimestamp ( endedAt ) ;
35+ await expectExecutionDetails ( page ) ;
36+ await expectExecutionTimings ( page ) ;
4137
42- const inputs = await readFromCodeEditorAsJson < Record < string , any > > ( page , 'Execution Inputs JSON' ) ;
43- expect ( inputs ) . toEqual ( {
38+ await expectExecutionInputs ( page , {
4439 count : 5000 ,
4540 firstNames : 'John\nJane\nJack\nAlice\nBob\nRobert' ,
4641 lastNames : 'Doe\nSmith\nBrown\nJohnson\nWhite\nJordan' ,
4742 } ) ;
4843
49- const outputs = await readFromCodeEditorAsJson < Array < any > > ( page , 'Execution Outputs JSON' ) ;
50- expect ( outputs ) . toHaveLength ( 2 ) ;
51- expect ( outputs [ 0 ] ) . toMatchObject ( {
52- type : 'FILE ' ,
53- name : 'report ' ,
54- label : 'Report ' ,
55- downloadName : 'report.csv' ,
56- } ) ;
57- expect ( outputs [ 1 ] ) . toMatchObject ( {
58- type : 'TEXT ' ,
59- name : 'summary ' ,
60- value : 'Processed 5000 user(s)' ,
61- } ) ;
44+ await expectExecutionOutputs ( page , [
45+ {
46+ type : 'FILE' ,
47+ name : 'report ' ,
48+ label : 'Report ' ,
49+ downloadName : 'report.csv ' ,
50+ } ,
51+ {
52+ type : 'TEXT' ,
53+ name : 'summary ' ,
54+ value : 'Processed 5000 user(s) ' ,
55+ } ,
56+ ] ) ;
6257
6358 await page . getByRole ( 'tab' , { name : 'Output' } ) . click ( ) ;
59+
60+ await page . getByRole ( 'button' , { name : 'Review' } ) . click ( ) ;
61+ await page . getByRole ( 'tab' , { name : 'Texts' } ) . click ( ) ;
62+ await expectOutputTexts ( page , [ 'Processed 5000 user(s)' ] ) ;
63+ await page . getByTestId ( 'modal' ) . getByRole ( 'button' , { name : 'Close' } ) . click ( ) ;
64+
6465 await page . getByRole ( 'button' , { name : 'Review' } ) . click ( ) ;
65- await expect ( page . getByText ( 'Processed 5000 user(s)' ) ) . toBeVisible ( ) ;
6666 await page . getByRole ( 'tab' , { name : 'Files' } ) . click ( ) ;
67-
68- const downloadArchivePromise = page . waitForEvent ( 'download' ) ;
69- await page . getByRole ( 'button' , { name : 'Download Archive' } ) . click ( ) ;
70- const downloadArchive = await downloadArchivePromise ;
71- expect ( downloadArchive . suggestedFilename ( ) ) . toMatch ( / \. ( z i p ) $ / ) ;
67+ await expectOutputFileDownload ( page , 'Download Archive' , / \. ( z i p ) $ / ) ;
7268
7369 await page . getByRole ( 'button' , { name : 'Review' } ) . click ( ) ;
7470 await page . getByRole ( 'tab' , { name : 'Files' } ) . click ( ) ;
75- const downloadConsolePromise = page . waitForEvent ( 'download' ) ;
76- await page . getByRole ( 'button' , { name : 'Download Console' } ) . click ( ) ;
77- const downloadConsole = await downloadConsolePromise ;
78- expect ( downloadConsole . suggestedFilename ( ) ) . toMatch ( / \. c o n s o l e \. l o g $ / ) ;
71+ await expectOutputFileDownload ( page , 'Download Console' , / \. c o n s o l e \. l o g $ / ) ;
7972
8073 await page . getByRole ( 'button' , { name : 'Review' } ) . click ( ) ;
8174 await page . getByRole ( 'tab' , { name : 'Files' } ) . click ( ) ;
82- const downloadReportPromise = page . waitForEvent ( 'download' ) ;
83- await page . getByRole ( 'button' , { name : 'Download Report' } ) . click ( ) ;
84- const downloadReport = await downloadReportPromise ;
85- expect ( downloadReport . suggestedFilename ( ) ) . toMatch ( / \. c s v $ / ) ;
75+ await expectOutputFileDownload ( page , 'Download Report' , / \. c s v $ / ) ;
8676 } ) ;
8777} ) ;
0 commit comments