@@ -20,7 +20,7 @@ export class LametaE2ERunner {
2020 fs . mkdirSync ( rootDir , { recursive : true } ) ;
2121
2222 const e2eRoot = process . env . E2ERoot || rootDir ; // allow caller override, else use unique temp dir
23- const exePath = process . env . E2E_LAMETA_EXECUTABLE ; // optional path to installed app
23+ const exePath = process . env . E2E_LAMETA_EXECUTABLE ; // optional path to installed app
2424
2525 const launchOptions : any = {
2626 args : exePath ? undefined : [ "." ] ,
@@ -35,17 +35,47 @@ export class LametaE2ERunner {
3535 }
3636 } ;
3737
38- // Do not add --remote-debugging-port; Playwright manages debugging flags itself.
38+ // Do not add --remote-debugging-port; Playwright manages debugging flags itself.
3939
4040 this . electronApp = await electron . launch ( launchOptions ) ;
4141 this . page = await this . electronApp . firstWindow ( ) ;
4242
4343 // Auto-dismiss prerelease warning dialog in packaged builds so tests aren't blocked
4444 try {
45- await this . page . waitForSelector ( 'text=I understand' , { timeout : 3000 } ) ;
46- const btn = this . page . getByRole ( 'button' , { name : / I u n d e r s t a n d / i } ) ;
47- if ( await btn . isVisible ( ) ) {
48- await btn . click ( ) ;
45+ // Look specifically for prerelease warning dialog by test ID - works across all localizations
46+ const dialogSelector = '[data-testid="prerelease-warning-dialog"]' ;
47+ await this . page . waitForSelector ( dialogSelector , { timeout : 3000 } ) ;
48+
49+ // Wait for the dialog to be fully loaded and visible
50+ const prereleaseDialog = this . page . getByTestId ( "prerelease-warning-dialog" ) ;
51+ await prereleaseDialog . waitFor ( { state : 'visible' } ) ;
52+
53+ // Try multiple button selectors to be more robust
54+ const buttonSelectors = [
55+ 'button.defaultButton' ,
56+ 'button[variant="contained"]' ,
57+ 'button:has-text("I understand")' ,
58+ 'button:has-text("Saya mengerti")' , // Indonesian translation
59+ 'button' // fallback to any button in the dialog
60+ ] ;
61+
62+ let buttonClicked = false ;
63+ for ( const selector of buttonSelectors ) {
64+ try {
65+ const button = prereleaseDialog . locator ( selector ) . first ( ) ;
66+ if ( await button . isVisible ( { timeout : 500 } ) ) {
67+ await button . click ( ) ;
68+ buttonClicked = true ;
69+ break ;
70+ }
71+ } catch {
72+ // Try next selector
73+ }
74+ }
75+
76+ if ( buttonClicked ) {
77+ // Wait for the dialog to disappear before continuing
78+ await prereleaseDialog . waitFor ( { state : 'hidden' , timeout : 2000 } ) ;
4979 }
5080 } catch {
5181 // no dialog; proceed
@@ -197,7 +227,50 @@ export class LametaE2ERunner {
197227 }
198228
199229 public async cancelRegistration ( ) {
230+ // First, try to dismiss any prerelease warning dialog that might be blocking
231+ await this . dismissPrereleaseDialogIfPresent ( ) ;
232+
200233 const cancel = await this . page . getByTestId ( "cancel" ) ; //.getByRole("button", { name: "Cancel" });
201234 await cancel . click ( ) ;
202235 }
236+
237+ private async dismissPrereleaseDialogIfPresent ( ) {
238+ try {
239+ const dialogSelector = '[data-testid="prerelease-warning-dialog"]' ;
240+ // Short timeout since this is just a defensive check
241+ await this . page . waitForSelector ( dialogSelector , { timeout : 1000 } ) ;
242+
243+ const prereleaseDialog = this . page . getByTestId ( "prerelease-warning-dialog" ) ;
244+ if ( await prereleaseDialog . isVisible ( ) ) {
245+ // Try multiple button selectors to be more robust
246+ const buttonSelectors = [
247+ 'button.defaultButton' ,
248+ 'button[variant="contained"]' ,
249+ 'button:has-text("I understand")' ,
250+ 'button:has-text("Saya mengerti")' , // Indonesian translation
251+ 'button' // fallback to any button in the dialog
252+ ] ;
253+
254+ let buttonClicked = false ;
255+ for ( const selector of buttonSelectors ) {
256+ try {
257+ const button = prereleaseDialog . locator ( selector ) . first ( ) ;
258+ if ( await button . isVisible ( { timeout : 500 } ) ) {
259+ await button . click ( ) ;
260+ buttonClicked = true ;
261+ break ;
262+ }
263+ } catch {
264+ // Try next selector
265+ }
266+ }
267+
268+ if ( buttonClicked ) {
269+ await prereleaseDialog . waitFor ( { state : 'hidden' , timeout : 2000 } ) ;
270+ }
271+ }
272+ } catch {
273+ // no dialog; proceed
274+ }
275+ }
203276}
0 commit comments