Skip to content

Commit

Permalink
ref: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Jun 19, 2023
1 parent 6814844 commit a00b111
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h1 id="h2">Bottom</h1>
document.getElementById('out').innerHTML += 'mutationButton clicked<br>';
});
document.getElementById('windowOpenButton').addEventListener('click', () => {
window.open('https://example.com/', '_self');
window.open('https://example.com/', '_blank');
});

// Do nothing on these elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from '@playwright/test';
import { sentryTest } from '../../../../utils/fixtures';
import { getCustomRecordingEvents, shouldSkipReplayTest, waitForReplayRequest } from '../../../../utils/replayHelpers';

sentryTest('window.open() is considered for slow click', async ({ getLocalTestUrl, page }) => {
sentryTest('window.open() is considered for slow click', async ({ getLocalTestUrl, page, browser }) => {
if (shouldSkipReplayTest()) {
sentryTest.skip();
}
Expand All @@ -29,8 +29,11 @@ sentryTest('window.open() is considered for slow click', async ({ getLocalTestUr
return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.click');
});

// Ensure window.open() still works as expected
const context = browser.contexts()[0];
const waitForNewPage = context.waitForEvent('page');

await page.click('#windowOpenButton');
const navPromise = page.waitForURL('https://example.com/');

const { breadcrumbs } = getCustomRecordingEvents(await reqPromise1);

Expand All @@ -54,8 +57,10 @@ sentryTest('window.open() is considered for slow click', async ({ getLocalTestUr
},
]);

await navPromise;
await waitForNewPage;

// Ensure window.open() still works as expected
expect(await page.url()).toBe('https://example.com/');
const pages = context.pages();

expect(pages.length).toBe(2);
expect(pages[1].url()).toBe('https://example.com/');
});

0 comments on commit a00b111

Please sign in to comment.