Skip to content

Commit

Permalink
fix: redirect to portfolio so that the client handles the url
Browse files Browse the repository at this point in the history
  • Loading branch information
AugmentedMode committed Oct 17, 2024
1 parent 4096d36 commit 7984951
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
3 changes: 0 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,5 @@ function start() {
params: [],
id: createRandomId(),
});

window.location.href =
'https://portfolio.metamask.io/?metamaskEntry=phishing_page_portfolio_button&marketingEnabled=true';
});
}
21 changes: 12 additions & 9 deletions tests/defaults.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test';
import { setupDefaultMocks } from './helpers/default-mocks';
import { setupStreamInitialization } from './helpers/stream-initialization';

test.beforeEach(async ({ context }) => {
await setupDefaultMocks(context);
Expand Down Expand Up @@ -45,21 +46,23 @@ test('does nothing when the user tries to bypass the warning', async ({
});

test('redirects when the user clicks "Back to safety"', async ({ page }) => {
const postMessageLogs = await setupStreamInitialization(page);
const querystring = new URLSearchParams({
href: 'https://test.com',
});
await page.goto(`/#${querystring}`);

await page.getByRole('button', { name: 'Back to safety' }).click();

await page.waitForURL(
'https://portfolio.metamask.io/?metamaskEntry=phishing_page_portfolio_button&marketingEnabled=true',
{ timeout: 10000 },
);

await expect(page.url()).toBe(
'https://portfolio.metamask.io/?metamaskEntry=phishing_page_portfolio_button&marketingEnabled=true',
);
await expect(postMessageLogs.length).toBe(1);
await expect(postMessageLogs[0].message).toStrictEqual({
data: {
id: expect.any(Number),
jsonrpc: '2.0',
method: 'backToSafetyPhishingWarning',
params: [],
},
name: 'metamask-phishing-safelist',
});
});

test('logs that the service worker is registered', async ({ page }) => {
Expand Down

0 comments on commit 7984951

Please sign in to comment.