Skip to content

Commit a0b8efa

Browse files
sergiolmseamodio
authored andcommitted
add command palette test
1 parent a09aa99 commit a0b8efa

File tree

10 files changed

+60
-37
lines changed

10 files changed

+60
-37
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ images/settings
99
gitlens-*.vsix
1010
tsconfig*.tsbuildinfo
1111
.DS_Store
12-
.wdio-vscode-service
1312
test-results
1413
playwright-report

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17962,6 +17962,7 @@
1796217962
"rebuild": "yarn run reset && yarn run build",
1796317963
"reset": "yarn run clean && yarn --frozen-lockfile",
1796417964
"test": "node ./out/test/runTest.js",
17965+
"test:e2e": "playwright test -c tests/e2e/playwright.config.ts",
1796517966
"watch": "webpack --watch --mode development",
1796617967
"watch:extension": "webpack --watch --mode development --config-name extension",
1796717968
"watch:webviews": "webpack --watch --mode development --config-name webviews",
@@ -18007,7 +18008,7 @@
1800718008
},
1800818009
"devDependencies": {
1800918010
"@eamodio/eslint-lite-webpack-plugin": "0.0.8",
18010-
"@playwright/test": "1.45.1",
18011+
"@playwright/test": "^1.46.1",
1801118012
"@swc/core": "1.7.3",
1801218013
"@twbs/fantasticon": "3.0.0",
1801318014
"@types/mocha": "10.0.7",
@@ -18048,7 +18049,7 @@
1804818049
"lz-string": "1.5.0",
1804918050
"mini-css-extract-plugin": "2.9.0",
1805018051
"mocha": "10.7.0",
18051-
"playwright": "1.45.1",
18052+
"playwright": "^1.46.1",
1805218053
"prettier": "3.1.0",
1805318054
"sass": "1.77.6",
1805418055
"sass-loader": "16.0.0",
File renamed without changes.
File renamed without changes.

tests/playwright/specs/baseTest.ts renamed to tests/e2e/specs/baseTest.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@ export type TestOptions = {
1212

1313
type TestFixtures = TestOptions & {
1414
page: Page;
15-
createTestProject: () => Promise<string>;
1615
createTmpDir: () => Promise<string>;
1716
};
1817

1918
let testProjectPath: string;
2019
export const test = base.extend<TestFixtures>({
2120
vscodeVersion: ['insiders', { option: true }],
22-
page: async ({ vscodeVersion, createTestProject, createTmpDir }, use) => {
21+
page: async ({ vscodeVersion, createTmpDir }, use) => {
2322
const defaultCachePath = await createTmpDir();
2423
const vscodePath = await downloadAndUnzipVSCode(vscodeVersion);
25-
testProjectPath = await createTestProject();
24+
testProjectPath = path.join(__dirname, '../../../');
2625

2726
const electronApp = await _electron.launch({
2827
executablePath: vscodePath,
@@ -61,24 +60,6 @@ export const test = base.extend<TestFixtures>({
6160
await fs.promises.cp(logPath, logOutputPath, { recursive: true });
6261
}
6362
},
64-
createTestProject: async ({ createTmpDir }, use) => {
65-
await use(async () => {
66-
// We want to be outside of the project directory to avoid already installed dependencies.
67-
const projectPath = await createTmpDir();
68-
if (fs.existsSync(projectPath)) await fs.promises.rm(projectPath, { recursive: true });
69-
console.log(`Creating project in ${projectPath}`);
70-
await fs.promises.mkdir(projectPath);
71-
spawnSync(`yarn init playwright@latest --yes -- --quiet --browser=chromium --gha --install-deps`, {
72-
cwd: projectPath,
73-
stdio: 'inherit',
74-
shell: true,
75-
});
76-
spawnSync(`git init .`, {
77-
cwd: projectPath,
78-
});
79-
return projectPath;
80-
});
81-
},
8263
createTmpDir: async ({}, use) => {
8364
const tempDirs: string[] = [];
8465
await use(async () => {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { test, expect } from './baseTest';
2+
3+
test.describe('Test GitLens Command Palette commands', () => {
4+
test('should open commit graph with the command', async ({ page }) => {
5+
// Close any open tabs to ensure a clean state
6+
const welcomePageTab = page.locator('div[role="tab"][aria-label="Welcome to GitLens"]');
7+
await welcomePageTab.waitFor({ state: 'visible', timeout: 5000 });
8+
welcomePageTab.locator('div.tab-actions .action-item a.codicon-close').click();
9+
10+
// Open the command palette by clicking on the View menu and selecting Command Palette
11+
const commandPalette = page.locator('div[id="workbench.parts.titlebar"] .command-center-quick-pick');
12+
await commandPalette.click();
13+
14+
// Wait for the command palette input to be visible and fill it
15+
const commandPaletteInput = page.locator('.quick-input-box input');
16+
await commandPaletteInput.waitFor({ state: 'visible', timeout: 5000 });
17+
await commandPaletteInput.fill('> GitLens: Show Commit graph');
18+
await page.waitForTimeout(1000);
19+
20+
await page.keyboard.press('Enter');
21+
22+
// Click on the first element (GitLens: Show Commit graph)
23+
/*
24+
const commandPaletteFirstLine = page.locator('.quick-input-widget .monaco-list .monaco-list-row.focused');
25+
await commandPaletteFirstLine.waitFor({ state: 'visible', timeout: 5000 });
26+
await commandPaletteFirstLine.click();
27+
*/
28+
// Graph should be opened
29+
await page.locator('.panel.basepanel').waitFor({ state: 'visible' });
30+
await expect(page.locator('div[id="workbench.view.extension.gitlensPanel"]')).toBeVisible();
31+
});
32+
});

tests/playwright/specs/basic.test.ts renamed to tests/e2e/specs/gitlens_install.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ test.describe('Test GitLens installation', () => {
1111
const gitlensIcons = await page.getByRole('tab', { name: 'GitLens' });
1212
expect(gitlensIcons).toHaveCount(2);
1313

14-
expect(await page.title()).toContain('[Extension Development Host] gltest-');
14+
expect(await page.title()).toContain('[Extension Development Host]');
1515
});
1616
});
File renamed without changes.

yarn.lock

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -740,12 +740,12 @@
740740
dependencies:
741741
playwright-core "1.45.3"
742742

743-
"@playwright/test@1.45.1":
744-
version "1.45.1"
745-
resolved "https://registry.npmjs.org/@playwright/test/-/test-1.45.1.tgz#819b90fa43d17000fce5ebd127043fd661938b7a"
746-
integrity sha512-Wo1bWTzQvGA7LyKGIZc8nFSTFf2TkthGIFBR+QVNilvwouGzFd4PYukZe3rvf5PSqjHi1+1NyKSDZKcQWETzaA==
743+
"@playwright/test@^1.46.1":
744+
version "1.46.1"
745+
resolved "https://registry.npmjs.org/@playwright/test/-/test-1.46.1.tgz#a8dfdcd623c4c23bb1b7ea588058aad41055c188"
746+
integrity sha512-Fq6SwLujA/DOIvNC2EL/SojJnkKf/rAwJ//APpJJHRyMi1PdKrY3Az+4XNQ51N4RTbItbIByQ0jgd1tayq1aeA==
747747
dependencies:
748-
playwright "1.45.1"
748+
playwright "1.46.1"
749749

750750
"@polka/url@^1.0.0-next.24":
751751
version "1.0.0-next.25"
@@ -6081,23 +6081,33 @@ pkg-dir@^4.2.0:
60816081
dependencies:
60826082
find-up "^4.0.0"
60836083

6084+
6085+
version "1.45.1"
6086+
resolved "https://registry.npmjs.org/playwright-core/-/playwright-core-1.45.1.tgz#549a2701556b58245cc75263f9fc2795c1158dc1"
6087+
integrity sha512-LF4CUUtrUu2TCpDw4mcrAIuYrEjVDfT1cHbJMfwnE2+1b8PZcFzPNgvZCvq2JfQ4aTjRCCHw5EJ2tmr2NSzdPg==
6088+
60846089
60856090
version "1.45.3"
60866091
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.45.3.tgz#e77bc4c78a621b96c3e629027534ee1d25faac93"
60876092
integrity sha512-+ym0jNbcjikaOwwSZycFbwkWgfruWvYlJfThKYAlImbxUgdWFO2oW70ojPm4OpE4t6TAo2FY/smM+hpVTtkhDA==
60886093

6089-
[email protected], playwright@^1.45.0:
6090-
version "1.45.1"
6091-
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.45.1.tgz#aaa6b0d6db14796b599d80c6679e63444e942534"
6092-
integrity sha512-Hjrgae4kpSQBr98nhCj3IScxVeVUixqj+5oyif8TdIn2opTCPEzqAqNMeK42i3cWDCVu9MI+ZsGWw+gVR4ISBg==
6094+
6095+
version "1.46.1"
6096+
resolved "https://registry.npmjs.org/playwright-core/-/playwright-core-1.46.1.tgz#28f3ab35312135dda75b0c92a3e5c0e7edb9cc8b"
6097+
integrity sha512-h9LqIQaAv+CYvWzsZ+h3RsrqCStkBHlgo6/TJlFst3cOTlLghBQlJwPOZKQJTKNaD3QIB7aAVQ+gfWbN3NXB7A==
6098+
6099+
[email protected], playwright@^1.46.1:
6100+
version "1.46.1"
6101+
resolved "https://registry.npmjs.org/playwright/-/playwright-1.46.1.tgz#ea562bc48373648e10420a10c16842f0b227c218"
6102+
integrity sha512-oPcr1yqoXLCkgKtD5eNUPLiN40rYEM39odNpIb6VE6S7/15gJmA1NzVv6zJYusV0e7tzvkU/utBFNa/Kpxmwng==
60936103
dependencies:
6094-
playwright-core "1.45.3"
6104+
playwright-core "1.46.1"
60956105
optionalDependencies:
60966106
fsevents "2.3.2"
60976107

6098-
playwright@^1.45.1:
6108+
playwright@^1.45.0:
60996109
version "1.45.1"
6100-
resolved "https://registry.npmjs.org/playwright/-/playwright-1.45.1.tgz#aaa6b0d6db14796b599d80c6679e63444e942534"
6110+
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.45.1.tgz#aaa6b0d6db14796b599d80c6679e63444e942534"
61016111
integrity sha512-Hjrgae4kpSQBr98nhCj3IScxVeVUixqj+5oyif8TdIn2opTCPEzqAqNMeK42i3cWDCVu9MI+ZsGWw+gVR4ISBg==
61026112
dependencies:
61036113
playwright-core "1.45.1"

0 commit comments

Comments
 (0)