Skip to content

Commit 3acdfe8

Browse files
committed
Fix file upload e2e auth setup
1 parent 59df8a9 commit 3acdfe8

1 file changed

Lines changed: 23 additions & 20 deletions

File tree

playwright/e2e/editor/blocks/file-block-upload.spec.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { test, expect, Page, Request } from '@playwright/test';
2-
import { signInAndNavigate } from '../../support/auth-utils';
2+
import { signInAndWaitForApp } from '../../../support/auth-flow-helpers';
3+
import { generateRandomEmail } from '../../../support/test-config';
34

45
/**
56
* Editor file-block / image-block popover upload regression tests.
@@ -25,16 +26,12 @@ test.describe('Feature: Editor block popover upload', () => {
2526

2627
let page: Page;
2728

28-
test.beforeEach(async ({ browser }) => {
29-
page = await browser.newPage();
30-
await signInAndNavigate(page);
29+
test.beforeEach(async ({ page: testPage, request }) => {
30+
page = testPage;
31+
await signInAndWaitForApp(page, request, generateRandomEmail());
3132
await page.locator('[data-testid="inline-add-page"]').first().waitFor({ state: 'visible', timeout: 30000 });
3233
});
3334

34-
test.afterEach(async () => {
35-
await page.close();
36-
});
37-
3835
/**
3936
* Create a new doc page via the inline-add button.
4037
*/
@@ -106,10 +103,12 @@ test.describe('Feature: Editor block popover upload', () => {
106103
// just persist it locally. The local IndexedDB save and the remote upload
107104
// were re-ordered in a recent refactor; this catches a regression where
108105
// a missing/failed local save would short-circuit the remote upload.
109-
await expect.poll(
110-
() => uploadRequests.filter((r) => r.method() !== 'GET').length,
111-
{ timeout: 30000, message: 'no upload request fired for file block' }
112-
).toBeGreaterThan(0);
106+
await expect
107+
.poll(() => uploadRequests.filter((r) => r.method() !== 'GET').length, {
108+
timeout: 30000,
109+
message: 'no upload request fired for file block',
110+
})
111+
.toBeGreaterThan(0);
113112

114113
// The block also flips out of its empty state (the file name appears).
115114
await expect(getEditor()).toContainText('regression.bin', { timeout: 30000 });
@@ -131,10 +130,12 @@ test.describe('Feature: Editor block popover upload', () => {
131130
buffer: TINY_PNG,
132131
});
133132

134-
await expect.poll(
135-
() => uploadRequests.filter((r) => r.method() !== 'GET').length,
136-
{ timeout: 30000, message: 'no upload request fired for image block' }
137-
).toBeGreaterThan(0);
133+
await expect
134+
.poll(() => uploadRequests.filter((r) => r.method() !== 'GET').length, {
135+
timeout: 30000,
136+
message: 'no upload request fired for image block',
137+
})
138+
.toBeGreaterThan(0);
138139

139140
// The block flips out of its empty state and renders an <img>.
140141
await expect(getEditor().locator('img').first()).toBeVisible({ timeout: 30000 });
@@ -207,9 +208,11 @@ test.describe('Feature: Editor block popover upload', () => {
207208
// rejects, the popover code must NOT swallow that error and skip the
208209
// remote upload. A non-GET request to a file storage endpoint must still
209210
// fire.
210-
await expect.poll(
211-
() => uploadRequests.filter((r) => r.method() !== 'GET').length,
212-
{ timeout: 30000, message: 'no upload request fired when IndexedDB was disabled' }
213-
).toBeGreaterThan(0);
211+
await expect
212+
.poll(() => uploadRequests.filter((r) => r.method() !== 'GET').length, {
213+
timeout: 30000,
214+
message: 'no upload request fired when IndexedDB was disabled',
215+
})
216+
.toBeGreaterThan(0);
214217
});
215218
});

0 commit comments

Comments
 (0)