From c2571cb07bc3aad7e0bb7ea1f71466d23f4094f3 Mon Sep 17 00:00:00 2001 From: imblue-dabadee Date: Wed, 28 Oct 2026 15:52:06 -0500 Subject: [PATCH 1/2] fix: update X share link and stub X in e2e test --- playwright.config.ts | 2 +- static/index.html | 2 +- tests/defaults.spec.ts | 20 ++++++++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 7bfd3d8..66850d4 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -29,7 +29,7 @@ export default defineConfig({ /* Opt out of parallel tests on CI. */ workers: process.env.CI ? 1 : undefined, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: 'html', + reporter: [['html', { open: 'never' }]], /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ diff --git a/static/index.html b/static/index.html index 24dd49c..288585f 100644 --- a/static/index.html +++ b/static/index.html @@ -76,7 +76,7 @@

This website might be harmful

X Icon diff --git a/tests/defaults.spec.ts b/tests/defaults.spec.ts index 3cfd649..c713dac 100644 --- a/tests/defaults.spec.ts +++ b/tests/defaults.spec.ts @@ -81,19 +81,27 @@ test('logs that the service worker is registered', async ({ page }) => { expect(infoLogs[0]).toMatch(expectedMessage); }); -test('redirects to X share page when clicked', async ({ page }) => { +test('redirects to X share page when clicked', async ({ page, context }) => { + // Stub X so the test doesn't depend on its live redirects or availability. + await context.route('https://x.com/**', async (route) => + route.fulfill({ status: 200, contentType: 'text/html', body: '' }), + ); + await page.goto('/'); + const shareLink = page.getByRole('link', { + name: 'If you found this helpful, click here to share on X!', + }); + await expect(shareLink).toHaveAttribute('rel', /noopener/u); + const [newPage] = await Promise.all([ page.waitForEvent('popup'), - page - .getByRole('link', { - name: 'If you found this helpful, click here to share on X!', - }) - .click(), + shareLink.click(), ]); await expect(newPage).toHaveURL( 'https://x.com/intent/post?text=MetaMask%20just%20protected%20me%20from%20a%20phishing%20attack!%20Remember%20to%20always%20stay%20vigilant%20when%20clicking%20on%20links.%20Learn%20more%20at&url=https%3A%2F%2Fmetamask.io', ); + // The opened tab must not be able to control or redirect the warning page. + expect(await newPage.evaluate(() => window.opener)).toBeNull(); }); From 241ddbc6ee1b059844702cdebe1ed82a096ba2e4 Mon Sep 17 00:00:00 2001 From: imblue-dabadee Date: Thu, 29 Oct 2026 12:05:24 -0500 Subject: [PATCH 2/2] fix: encode share text and link to metamask.com --- static/index.html | 2 +- tests/defaults.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/static/index.html b/static/index.html index 288585f..85a1d82 100644 --- a/static/index.html +++ b/static/index.html @@ -76,7 +76,7 @@

This website might be harmful

diff --git a/tests/defaults.spec.ts b/tests/defaults.spec.ts index c713dac..4f5e61a 100644 --- a/tests/defaults.spec.ts +++ b/tests/defaults.spec.ts @@ -100,7 +100,7 @@ test('redirects to X share page when clicked', async ({ page, context }) => { ]); await expect(newPage).toHaveURL( - 'https://x.com/intent/post?text=MetaMask%20just%20protected%20me%20from%20a%20phishing%20attack!%20Remember%20to%20always%20stay%20vigilant%20when%20clicking%20on%20links.%20Learn%20more%20at&url=https%3A%2F%2Fmetamask.io', + 'https://x.com/intent/post?text=MetaMask%20just%20protected%20me%20from%20a%20phishing%20attack%21%20Remember%20to%20always%20stay%20vigilant%20when%20clicking%20on%20links.%20Learn%20more%20at&url=https%3A%2F%2Fmetamask.com', ); // The opened tab must not be able to control or redirect the warning page. expect(await newPage.evaluate(() => window.opener)).toBeNull();