From e07e958e5ed41205c86a1b8a2af4bde236b713e5 Mon Sep 17 00:00:00 2001 From: lukaw3d Date: Wed, 29 Nov 2023 04:21:27 +0100 Subject: [PATCH] Fix addPersistedStorageV1 and clearPersistedStorage in extension tests --- .changelog/1780.internal.md | 1 + playwright/utils/extensionTestExtend.ts | 4 ++++ playwright/utils/storage.ts | 11 ++++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 .changelog/1780.internal.md diff --git a/.changelog/1780.internal.md b/.changelog/1780.internal.md new file mode 100644 index 0000000000..e1bf891d94 --- /dev/null +++ b/.changelog/1780.internal.md @@ -0,0 +1 @@ +Improve e2e tests diff --git a/playwright/utils/extensionTestExtend.ts b/playwright/utils/extensionTestExtend.ts index d4659766d7..87f8ce4232 100644 --- a/playwright/utils/extensionTestExtend.ts +++ b/playwright/utils/extensionTestExtend.ts @@ -13,6 +13,7 @@ export const test = base.extend<{ context: BrowserContext extensionId: string extensionPopupURL: `chrome-extension://${string}` + extensionManifestURL: `chrome-extension://${string}/manifest.json` }>({ // eslint-disable-next-line no-empty-pattern context: async ({}, use) => { @@ -38,4 +39,7 @@ export const test = base.extend<{ extensionPopupURL: async ({ extensionId }, use) => { await use(`chrome-extension://${extensionId}/${popupFile}#`) }, + extensionManifestURL: async ({ extensionId }, use) => { + await use(`chrome-extension://${extensionId}/manifest.json`) + }, }) diff --git a/playwright/utils/storage.ts b/playwright/utils/storage.ts index b8e9ff0cca..acf38ca155 100644 --- a/playwright/utils/storage.ts +++ b/playwright/utils/storage.ts @@ -3,16 +3,21 @@ import { privateKeyPersistedState } from '../../src/utils/__fixtures__/test-inpu export async function clearPersistedStorage( page: Page, - url: '/app.webmanifest' | `chrome-extension://${string}`, + url: '/app.webmanifest' | `chrome-extension://${string}/manifest.json`, ) { // Move to the right domain, but don't needlessly load HTML and JS. await page.goto(url) - await page.evaluate(() => window.localStorage.clear()) + await page.evaluate(() => { + window.localStorage.clear() + + const chrome = (window as any).chrome + chrome?.extension?.getBackgroundPage?.().location.reload() + }) } export async function addPersistedStorageV1( page: Page, - url: '/app.webmanifest' | `chrome-extension://${string}`, + url: '/app.webmanifest' | `chrome-extension://${string}/manifest.json`, ) { // Move to the right domain, but don't needlessly load HTML and JS. await page.goto(url)