22//
33// SPDX-License-Identifier: MPL-2.0
44
5- import * as fs from "fs" ;
6- import * as path from " path" ;
5+ import * as fs from 'fs' ;
6+ import * as path from ' path' ;
77
8- import { test , expect } from " @playwright/test" ;
8+ import { test , expect } from ' @playwright/test' ;
99
10- import { ensureLoggedIn , getAuthHeaders } from " ./auth-helpers" ;
10+ import { ensureLoggedIn , getAuthHeaders } from ' ./auth-helpers' ;
1111import {
1212 type ConsoleErrorCollector ,
1313 createConsoleErrorCollector ,
1414 verifyAudioPlayback ,
15- } from "./test-helpers" ;
16-
17- const repoRoot = path . resolve ( import . meta. dirname , ".." , ".." ) ;
18- const sampleOggPath = path . join (
19- repoRoot ,
20- "samples" ,
21- "audio" ,
22- "system" ,
23- "sample.ogg" ,
24- ) ;
15+ } from './test-helpers' ;
16+
17+ const repoRoot = path . resolve ( import . meta. dirname , '..' , '..' ) ;
18+ const sampleOggPath = path . join ( repoRoot , 'samples' , 'audio' , 'system' , 'sample.ogg' ) ;
2519const mixingYaml = fs . readFileSync (
26- path . join ( repoRoot , " samples" , " pipelines" , " oneshot" , " mixing.yml" ) ,
27- " utf8" ,
20+ path . join ( repoRoot , ' samples' , ' pipelines' , ' oneshot' , ' mixing.yml' ) ,
21+ ' utf8'
2822) ;
2923
30- test . describe ( " Convert View - Audio Mixing Pipeline" , ( ) => {
24+ test . describe ( ' Convert View - Audio Mixing Pipeline' , ( ) => {
3125 let collector : ConsoleErrorCollector ;
3226
3327 test . beforeEach ( async ( { page } ) => {
3428 collector = createConsoleErrorCollector ( page ) ;
35- await page . goto ( " /convert" ) ;
29+ await page . goto ( ' /convert' ) ;
3630 await ensureLoggedIn ( page ) ;
37- if ( ! page . url ( ) . includes ( " /convert" ) ) {
38- await page . goto ( " /convert" ) ;
31+ if ( ! page . url ( ) . includes ( ' /convert' ) ) {
32+ await page . goto ( ' /convert' ) ;
3933 }
40- await expect ( page . getByTestId ( " convert-view" ) ) . toBeVisible ( ) ;
34+ await expect ( page . getByTestId ( ' convert-view' ) ) . toBeVisible ( ) ;
4135 } ) ;
4236
43- test ( " API: POST /api/v1/process with mixing pipeline returns audio" , async ( {
37+ test ( ' API: POST /api/v1/process with mixing pipeline returns audio' , async ( {
4438 page,
4539 baseURL,
4640 } ) => {
47- const audioBase64 = fs . readFileSync ( sampleOggPath ) . toString ( " base64" ) ;
41+ const audioBase64 = fs . readFileSync ( sampleOggPath ) . toString ( ' base64' ) ;
4842 const authHeaders = getAuthHeaders ( ) ;
4943
5044 const result = await page . evaluate (
5145 async ( { url, yaml, audio, headers } ) => {
5246 const formData = new FormData ( ) ;
53- formData . append ( " config" , yaml ) ;
47+ formData . append ( ' config' , yaml ) ;
5448 const bytes = Uint8Array . from ( atob ( audio ) , ( c ) => c . charCodeAt ( 0 ) ) ;
55- formData . append (
56- "media" ,
57- new Blob ( [ bytes ] , { type : "audio/ogg" } ) ,
58- "sample.ogg" ,
59- ) ;
49+ formData . append ( 'media' , new Blob ( [ bytes ] , { type : 'audio/ogg' } ) , 'sample.ogg' ) ;
6050
6151 const controller = new AbortController ( ) ;
6252 const timeoutId = setTimeout ( ( ) => controller . abort ( ) , 30_000 ) ;
6353
6454 try {
6555 const response = await fetch ( `${ url } /api/v1/process` , {
66- method : " POST" ,
56+ method : ' POST' ,
6757 body : formData ,
6858 headers,
6959 signal : controller . signal ,
7060 } ) ;
7161
72- const contentType = response . headers . get ( " content-type" ) ?? "" ;
62+ const contentType = response . headers . get ( ' content-type' ) ?? '' ;
7363 const reader = response . body ! . getReader ( ) ;
7464 const { value } = await reader . read ( ) ;
7565 reader . cancel ( ) ;
@@ -88,99 +78,88 @@ test.describe("Convert View - Audio Mixing Pipeline", () => {
8878 yaml : mixingYaml ,
8979 audio : audioBase64 ,
9080 headers : authHeaders ,
91- } ,
81+ }
9282 ) ;
9383
9484 expect ( result . status , `Process request failed: ${ result . status } ` ) . toBe ( 200 ) ;
9585 expect (
96- result . contentType . includes ( " audio/" ) ||
97- result . contentType . includes ( " video/webm" ) ||
98- result . contentType . includes ( " application/octet" ) ,
99- `Unexpected Content-Type: ${ result . contentType } ` ,
86+ result . contentType . includes ( ' audio/' ) ||
87+ result . contentType . includes ( ' video/webm' ) ||
88+ result . contentType . includes ( ' application/octet' ) ,
89+ `Unexpected Content-Type: ${ result . contentType } `
10090 ) . toBeTruthy ( ) ;
10191 expect ( result . firstChunkSize ) . toBeGreaterThan ( 0 ) ;
10292 } ) ;
10393
104- test ( " UI: select mixing template, upload file, convert, verify audio player" , async ( {
94+ test ( ' UI: select mixing template, upload file, convert, verify audio player' , async ( {
10595 page,
10696 } ) => {
107- await expect ( page . getByText ( " 1. Select Pipeline Template" ) ) . toBeVisible ( ) ;
97+ await expect ( page . getByText ( ' 1. Select Pipeline Template' ) ) . toBeVisible ( ) ;
10898
109- const templateCard = page . getByText ( " Audio Mixing (Upload + Music Track)" , {
99+ const templateCard = page . getByText ( ' Audio Mixing (Upload + Music Track)' , {
110100 exact : true ,
111101 } ) ;
112102 await expect ( templateCard ) . toBeVisible ( { timeout : 10_000 } ) ;
113103 await templateCard . click ( ) ;
114104
115105 await expect ( page . locator ( 'input[type="file"]' ) . first ( ) ) . toBeAttached ( ) ;
116- await page
117- . locator ( 'input[type="file"]' )
118- . first ( )
119- . setInputFiles ( sampleOggPath ) ;
106+ await page . locator ( 'input[type="file"]' ) . first ( ) . setInputFiles ( sampleOggPath ) ;
120107
121- await expect ( page . getByText ( " sample.ogg" ) ) . toBeVisible ( ) ;
108+ await expect ( page . getByText ( ' sample.ogg' ) ) . toBeVisible ( ) ;
122109
123- const convertButton = page . getByRole ( " button" , { name : / C o n v e r t F i l e / i } ) ;
110+ const convertButton = page . getByRole ( ' button' , { name : / C o n v e r t F i l e / i } ) ;
124111 await expect ( convertButton ) . toBeEnabled ( ) ;
125112 await convertButton . click ( ) ;
126113
127- await expect ( page . getByText ( " Converted Audio" ) ) . toBeVisible ( {
114+ await expect ( page . getByText ( ' Converted Audio' ) ) . toBeVisible ( {
128115 timeout : 60_000 ,
129116 } ) ;
130117
131118 const playback = await verifyAudioPlayback ( page ) ;
132- expect ( playback . found , " Audio element not found on page" ) . toBe ( true ) ;
133- expect ( playback . duration , " Audio has no duration" ) . toBeGreaterThan ( 0 ) ;
119+ expect ( playback . found , ' Audio element not found on page' ) . toBe ( true ) ;
120+ expect ( playback . duration , ' Audio has no duration' ) . toBeGreaterThan ( 0 ) ;
134121
135122 const unexpected = collector . getUnexpected ( ) ;
136- expect (
137- unexpected ,
138- `Unexpected console errors: ${ unexpected . join ( "; " ) } ` ,
139- ) . toHaveLength ( 0 ) ;
123+ expect ( unexpected , `Unexpected console errors: ${ unexpected . join ( '; ' ) } ` ) . toHaveLength ( 0 ) ;
140124 } ) ;
141125
142- test ( " UI: select mixing template, use existing asset, convert, verify audio player" , async ( {
126+ test ( ' UI: select mixing template, use existing asset, convert, verify audio player' , async ( {
143127 page,
144128 } ) => {
145- await expect ( page . getByText ( " 1. Select Pipeline Template" ) ) . toBeVisible ( ) ;
129+ await expect ( page . getByText ( ' 1. Select Pipeline Template' ) ) . toBeVisible ( ) ;
146130
147- const templateCard = page . getByText ( " Audio Mixing (Upload + Music Track)" , {
131+ const templateCard = page . getByText ( ' Audio Mixing (Upload + Music Track)' , {
148132 exact : true ,
149133 } ) ;
150134 await expect ( templateCard ) . toBeVisible ( { timeout : 10_000 } ) ;
151135 await templateCard . click ( ) ;
152136
153- const assetModeButton = page . getByRole ( " button" , {
137+ const assetModeButton = page . getByRole ( ' button' , {
154138 name : / S e l e c t E x i s t i n g A s s e t / i,
155139 } ) ;
156140 await expect ( assetModeButton ) . toBeVisible ( ) ;
157141 await assetModeButton . click ( ) ;
158142
159- const assetRadioGroup = page . locator (
160- '[aria-label="Audio asset selection"]' ,
161- ) ;
143+ const assetRadioGroup = page . locator ( '[aria-label="Audio asset selection"]' ) ;
162144 await expect ( assetRadioGroup ) . toBeVisible ( { timeout : 10_000 } ) ;
163145
164- const firstAsset = assetRadioGroup . locator ( " label" ) . first ( ) ;
146+ const firstAsset = assetRadioGroup . locator ( ' label' ) . first ( ) ;
165147 await expect ( firstAsset ) . toBeVisible ( ) ;
166148 await firstAsset . click ( ) ;
167149
168- const convertButton = page . getByRole ( " button" , { name : / C o n v e r t F i l e / i } ) ;
150+ const convertButton = page . getByRole ( ' button' , { name : / C o n v e r t F i l e / i } ) ;
169151 await expect ( convertButton ) . toBeEnabled ( ) ;
170152 await convertButton . click ( ) ;
171153
172- await expect ( page . getByText ( " Converted Audio" ) ) . toBeVisible ( {
154+ await expect ( page . getByText ( ' Converted Audio' ) ) . toBeVisible ( {
173155 timeout : 60_000 ,
174156 } ) ;
175157
176158 const playback = await verifyAudioPlayback ( page ) ;
177- expect ( playback . found , " Audio element not found on page" ) . toBe ( true ) ;
178- expect ( playback . duration , " Audio has no duration" ) . toBeGreaterThan ( 0 ) ;
159+ expect ( playback . found , ' Audio element not found on page' ) . toBe ( true ) ;
160+ expect ( playback . duration , ' Audio has no duration' ) . toBeGreaterThan ( 0 ) ;
179161
180162 const unexpected = collector . getUnexpected ( ) ;
181- expect (
182- unexpected ,
183- `Unexpected console errors: ${ unexpected . join ( "; " ) } ` ,
184- ) . toHaveLength ( 0 ) ;
163+ expect ( unexpected , `Unexpected console errors: ${ unexpected . join ( '; ' ) } ` ) . toHaveLength ( 0 ) ;
185164 } ) ;
186165} ) ;
0 commit comments