Skip to content

Commit 3937e52

Browse files
JohnMcLearclaude
andcommitted
fix(test): auto-dismiss deletion-token modal in goToNewPad helper
The token modal introduced in PR1 blocks clicks for every Playwright test that creates a new pad via the shared helper. Add a one-line dismissal so unrelated tests keep passing, and have the deletion-token spec navigate inline via newPadKeepingModal() when it needs the modal open to capture the token. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3b3d54d commit 3937e52

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

src/tests/frontend-new/helper/padHelper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ export const goToNewPad = async (page: Page) => {
120120
await page.goto('http://localhost:9001/p/'+padId);
121121
await page.waitForSelector('iframe[name="ace_outer"]');
122122
await page.waitForSelector('#editorcontainer.initialized');
123+
// Creator sessions see the one-time pad-deletion-token modal on first visit.
124+
// Dismiss it so subsequent clicks in generic tests are not blocked. Tests
125+
// that need to interact with the modal should navigate to a new pad inline
126+
// instead of using this helper.
127+
const tokenModal = page.locator('#deletiontoken-modal');
128+
if (await tokenModal.isVisible().catch(() => false)) {
129+
await page.locator('#deletiontoken-ack').click();
130+
}
123131
return padId;
124132
}
125133

src/tests/frontend-new/specs/pad_deletion_token.spec.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1-
import {expect, test} from '@playwright/test';
2-
import {goToNewPad, goToPad} from '../helper/padHelper';
1+
import {expect, test, Page} from '@playwright/test';
2+
import {randomUUID} from 'node:crypto';
3+
import {goToPad} from '../helper/padHelper';
34
import {showSettings} from '../helper/settingsHelper';
45

6+
// goToNewPad() in the shared helper auto-dismisses the deletion-token modal
7+
// so unrelated tests aren't blocked. These tests need the modal, so they
8+
// navigate inline without the helper.
9+
const newPadKeepingModal = async (page: Page) => {
10+
const padId = `FRONTEND_TESTS${randomUUID()}`;
11+
await page.goto(`http://localhost:9001/p/${padId}`);
12+
await page.waitForSelector('iframe[name="ace_outer"]');
13+
await page.waitForSelector('#editorcontainer.initialized');
14+
return padId;
15+
};
16+
517
test.describe('pad deletion token', () => {
618
test.beforeEach(async ({context}) => {
719
await context.clearCookies();
820
});
921

1022
test('creator sees a token modal exactly once and can dismiss it', async ({page}) => {
11-
await goToNewPad(page);
23+
await newPadKeepingModal(page);
1224
const modal = page.locator('#deletiontoken-modal');
1325
await expect(modal).toBeVisible();
1426

@@ -24,7 +36,7 @@ test.describe('pad deletion token', () => {
2436
});
2537

2638
test('second device can delete using the captured token', async ({page, browser}) => {
27-
const padId = await goToNewPad(page);
39+
const padId = await newPadKeepingModal(page);
2840
const token = await page.locator('#deletiontoken-value').inputValue();
2941
await page.locator('#deletiontoken-ack').click();
3042

@@ -45,7 +57,7 @@ test.describe('pad deletion token', () => {
4557
});
4658

4759
test('wrong token keeps the pad alive and surfaces a shout', async ({page, browser}) => {
48-
const padId = await goToNewPad(page);
60+
const padId = await newPadKeepingModal(page);
4961
await page.locator('#deletiontoken-ack').click();
5062

5163
const context2 = await browser.newContext();
@@ -55,7 +67,6 @@ test.describe('pad deletion token', () => {
5567

5668
await page2.locator('#delete-pad-with-token > summary').click();
5769
await page2.locator('#delete-pad-token-input').fill('bogus-token-value');
58-
// Accept the confirm() dialog, then capture the alert() the shout triggers.
5970
const dialogs: string[] = [];
6071
page2.on('dialog', async (d) => {
6172
dialogs.push(d.message());
@@ -66,7 +77,6 @@ test.describe('pad deletion token', () => {
6677
await expect.poll(() => dialogs.length, {timeout: 10000}).toBeGreaterThanOrEqual(2);
6778
expect(dialogs.some((m) => /not the creator|cannot delete/i.test(m))).toBe(true);
6879

69-
// Pad must still exist for the original creator.
7080
await page.reload();
7181
await expect(page.locator('#editorcontainer.initialized')).toBeVisible();
7282
await context2.close();

0 commit comments

Comments
 (0)