Skip to content

Commit ea28f9d

Browse files
committed
wip at helping e2e with localized beta warning dlg (didn't work)
1 parent 208b9e3 commit ea28f9d

4 files changed

Lines changed: 91 additions & 9 deletions

File tree

e2e/lametaE2ERunner.ts

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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 understand/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
}

src/components/LametaDialog.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const kDialogPadding = "10px";
1313
export const LametaDialog: React.FunctionComponent<{
1414
open: boolean;
1515
requestClose: () => void;
16+
"data-testid"?: string;
1617
}> = (props) => {
1718
if (!props.open) {
1819
return <React.Fragment />;
@@ -35,6 +36,7 @@ export const LametaDialog: React.FunctionComponent<{
3536
const { requestClose, ...dialogProps } = props;
3637
return (
3738
<Dialog
39+
data-testid={props["data-testid"]}
3840
onClose={() => requestClose()}
3941
onKeyDown={(e) => {
4042
if (e.key === "Enter") {

src/components/ShowMessageDialog/MessageDialog.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface IConfig {
2020
iconPath?: string | undefined | /* alert */ null /* none */;
2121
content?: React.ReactNode;
2222
width?: string;
23+
testId?: string;
2324
}
2425

2526
let staticShowMessageDialog: (config: IConfig) => void = () => {};
@@ -38,7 +39,11 @@ export const MessageDialog: React.FunctionComponent<{}> = (props) => {
3839
setIsOpen(true);
3940
};
4041
return (
41-
<LametaDialog open={isOpen} requestClose={() => setIsOpen(false)}>
42+
<LametaDialog
43+
open={isOpen}
44+
requestClose={() => setIsOpen(false)}
45+
data-testid={config.testId}
46+
>
4247
<div className={"dialogTitle "}>
4348
<div
4449
css={css`

src/containers/HomePage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,17 @@ class HomePage extends React.Component<IProps, IState> {
161161
title: `TESTING ONLY`,
162162
text: "Thank you so much for testing this experimental version of lameta. Make sure you have a backup of your work.",
163163
width: "300px",
164-
buttonText: "I understand"
164+
buttonText: "I understand",
165+
testId: "prerelease-warning-dialog"
165166
});
166167
break;
167168
case "beta":
168169
ShowMessageDialog({
169170
title: `Warning`,
170171
text: "This is a beta test version, so make sure you have a backup of your work.",
171172
width: "300px",
172-
buttonText: "I understand"
173+
buttonText: "I understand",
174+
testId: "prerelease-warning-dialog"
173175
});
174176
break;
175177
default:

0 commit comments

Comments
 (0)