Skip to content

Commit 3077ecc

Browse files
authored
fix E2E tests (#3610)
* fix error * set max timeout to 10s * minor additions to e2e test config
1 parent 0c1bab0 commit 3077ecc

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

tests/e2e/playwright.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ export default defineConfig({
2222
},
2323
},
2424
],
25+
testMatch: 'specs/*.test.ts',
2526
});

tests/e2e/specs/baseTest.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ type TestFixtures = TestOptions & {
1616
createTmpDir: () => Promise<string>;
1717
};
1818

19+
export const MaxTimeout = 10000;
20+
1921
let testProjectPath: string;
2022
export const test = base.extend<TestFixtures>({
2123
vscodeVersion: ['insiders', { option: true }],
@@ -61,7 +63,12 @@ export const test = base.extend<TestFixtures>({
6163
await fs.promises.cp(logPath, logOutputPath, { recursive: true });
6264
}
6365
},
64-
createTmpDir: async (_, use) => {
66+
// Next line is necessary because of how Playwright works. It expect a destructured pattern here:
67+
// https://github.com/microsoft/playwright/issues/14590#issuecomment-1911734641
68+
// https://github.com/microsoft/playwright/issues/21566#issuecomment-1464858235
69+
70+
// eslint-disable-next-line no-empty-pattern
71+
createTmpDir: async ({}, use) => {
6572
const tempDirs: string[] = [];
6673
await use(async () => {
6774
const tempDir = await fs.promises.realpath(await fs.promises.mkdtemp(path.join(os.tmpdir(), 'gltest-')));

tests/e2e/specs/command_palette.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { expect, test } from './baseTest';
1+
import { expect, MaxTimeout, test } from './baseTest';
22

33
test.describe('Test GitLens Command Palette commands', () => {
44
test('should open commit graph with the command', async ({ page }) => {
55
// Close any open tabs to ensure a clean state
66
const welcomePageTab = page.locator('div[role="tab"][aria-label="Welcome to GitLens"]');
7-
await welcomePageTab.waitFor({ state: 'visible', timeout: 5000 });
7+
await welcomePageTab.waitFor({ state: 'visible', timeout: MaxTimeout });
88
void welcomePageTab.locator('div.tab-actions .action-item a.codicon-close').click();
99

1010
// Open the command palette by clicking on the View menu and selecting Command Palette
@@ -13,15 +13,15 @@ test.describe('Test GitLens Command Palette commands', () => {
1313

1414
// Wait for the command palette input to be visible and fill it
1515
const commandPaletteInput = page.locator('.quick-input-box input');
16-
await commandPaletteInput.waitFor({ state: 'visible', timeout: 5000 });
16+
await commandPaletteInput.waitFor({ state: 'visible', timeout: MaxTimeout });
1717
await commandPaletteInput.fill('> GitLens: Show Commit graph');
1818
await page.waitForTimeout(1000);
1919
void page.keyboard.press('Enter');
2020

2121
// Click on the first element (GitLens: Show Commit graph)
2222
/*
2323
const commandPaletteFirstLine = page.locator('.quick-input-widget .monaco-list .monaco-list-row.focused');
24-
await commandPaletteFirstLine.waitFor({ state: 'visible', timeout: 5000 });
24+
await commandPaletteFirstLine.waitFor({ state: 'visible', timeout: MaxTimeout });
2525
await commandPaletteFirstLine.click();
2626
*/
2727
// Graph should be opened

0 commit comments

Comments
 (0)