Skip to content

Commit 92aca99

Browse files
[PM-37816] Remove check for new tab (#492)
* Remove check for new tab * fix button locator * remove unnecessary step --------- Co-authored-by: ✨ Audrey ✨ <ajensen@bitwarden.com>
1 parent 384a6e3 commit 92aca99

3 files changed

Lines changed: 9 additions & 42 deletions

File tree

benchmarks/fixtures.benchmark.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,14 @@ import {
88
} from "@playwright/test";
99
import { configDotenv } from "dotenv";
1010

11-
import {
12-
debugIsActive,
13-
vaultEmail,
14-
vaultPassword,
15-
vaultHostURL,
16-
} from "../constants";
11+
import { vaultEmail, vaultPassword, vaultHostURL } from "../constants";
1712
import { PerfCapture } from "../abstractions";
1813
import {
19-
closeWelcomePage,
2014
fetchFeatureFlags,
2115
type FeatureFlags,
2216
getBackgroundPage,
2317
loginToVault,
18+
obtainTestPage,
2419
prepareEnvironment,
2520
readManifestVersion,
2621
submitEnvironment,
@@ -87,16 +82,7 @@ export function createBenchmarkTest(
8782
await use(extensionId);
8883
},
8984
extensionSetup: async ({ context, extensionId }, use) => {
90-
let testPage: Page;
91-
92-
await test.step("Close the extension welcome page when it pops up", async () => {
93-
testPage = await closeWelcomePage(
94-
context,
95-
!debugIsActive &&
96-
process.env.HEADLESS !== "true" &&
97-
process.env.CI === "true",
98-
);
99-
});
85+
const testPage: Page = await obtainTestPage(context);
10086

10187
await test.step("Configure the environment", async () => {
10288
if (vaultHostURL) {

fixtures/extension-setup.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,12 @@ import { defaultGotoOptions, defaultWaitForOptions } from "../constants";
66

77
export type FeatureFlags = { [key: string]: boolean };
88

9-
export async function closeWelcomePage(
10-
context: BrowserContext,
11-
// Wait for the extension to open the welcome page before continuing
12-
// (only relevant when using prod or build artifacts in CI)
13-
shouldWaitForWelcomePopup: boolean,
14-
): Promise<Page> {
15-
if (shouldWaitForWelcomePopup) {
16-
await context.waitForEvent("page");
17-
}
18-
19-
const contextPages = await context.pages();
9+
export async function obtainTestPage(context: BrowserContext): Promise<Page> {
10+
const contextPages = context.pages();
2011

2112
// close all but the first tab
2213
await Promise.all(
23-
contextPages.slice(1).map((contextPage) => contextPage.close()),
14+
contextPages.slice(1).map((contextPage: Page) => contextPage.close()),
2415
);
2516

2617
return contextPages[0];
@@ -65,7 +56,7 @@ export async function prepareEnvironment(
6556
}
6657

6758
export async function submitEnvironment(testPage: Page): Promise<void> {
68-
await testPage.click("bit-dialog button[type='submit']");
59+
await testPage.click("[bit-dialog] button[type='submit']");
6960
}
7061

7162
export async function loginToVault(

tests/fixtures.browser.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,17 @@ import {
1010
import { configDotenv } from "dotenv";
1111

1212
import {
13-
debugIsActive,
1413
screenshotsOutput,
1514
vaultEmail,
1615
vaultPassword,
1716
vaultHostURL,
1817
} from "../constants";
1918
import {
20-
closeWelcomePage,
2119
fetchFeatureFlags,
2220
type FeatureFlags,
2321
getBackgroundPage,
2422
loginToVault,
23+
obtainTestPage,
2524
prepareEnvironment,
2625
readManifestVersion,
2726
submitEnvironment,
@@ -97,16 +96,7 @@ export const test = base.extend<{
9796
await use(extensionId);
9897
},
9998
extensionSetup: async ({ context, extensionId, testOutputPath }, use) => {
100-
let testPage: Page;
101-
102-
await test.step("Close the extension welcome page when it pops up", async () => {
103-
testPage = await closeWelcomePage(
104-
context,
105-
!debugIsActive &&
106-
process.env.HEADLESS !== "true" &&
107-
process.env.CI === "true",
108-
);
109-
});
99+
const testPage: Page = await obtainTestPage(context);
110100

111101
await test.step("Configure the environment", async () => {
112102
if (vaultHostURL) {

0 commit comments

Comments
 (0)