Skip to content

Commit 25ef340

Browse files
committed
Add example visual tests
1 parent 0eab780 commit 25ef340

8 files changed

Lines changed: 78 additions & 8 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { test, expect } from '@vscode/test-web/playwright';
7+
8+
test.describe('Page Interactions', () => {
9+
10+
test('command execution with notification', async ({ vscode, page }) => {
11+
await vscode.commands.executeCommand('vscode-test-web-sample.helloWorld');
12+
13+
// Wait for the notification message to appear
14+
const notification = page.locator('.notification-toast-container');
15+
await expect(notification).toContainText('Hello World from vscode-test-web-sample in a web extension host!');
16+
});
17+
18+
});
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { test, expect } from '@vscode/test-web/playwright';
7+
8+
test.describe('Visual Regression', () => {
9+
10+
test('workbench screenshot', async ({ vscode: _vscode, page }) => {
11+
// vscode fixture ensures page is loaded and workbench is ready
12+
// Take a screenshot of the full workbench
13+
await expect(page).toHaveScreenshot('workbench.png', { maxDiffPixels: 100 });
14+
});
15+
16+
test('activity bar screenshot', async ({ vscode: _vscode, page }) => {
17+
// vscode fixture ensures page is loaded
18+
// Locate the activity bar
19+
const activityBar = page.locator('.activitybar');
20+
await expect(activityBar).toBeVisible();
21+
22+
// Take a screenshot of just the activity bar
23+
await expect(activityBar).toHaveScreenshot('activity-bar.png', { maxDiffPixels: 100 });
24+
});
25+
26+
test('notification toast screenshot', async ({ vscode, page }) => {
27+
// Trigger a command that shows a notification
28+
await vscode.commands.executeCommand('vscode-test-web-sample.helloWorld');
29+
30+
// Wait for notification to appear
31+
const notification = page.locator('.notification-toast-container');
32+
await expect(notification).toBeVisible();
33+
34+
// Take a screenshot of the notification
35+
await expect(notification).toHaveScreenshot('notification-toast.png', { maxDiffPixels: 100 });
36+
});
37+
38+
test('sidebar snapshot', async ({ vscode: _vscode, page }) => {
39+
// vscode fixture ensures page is loaded
40+
// Locate the sidebar
41+
const sidebar = page.locator('.sidebar');
42+
await expect(sidebar).toBeVisible();
43+
44+
// Take a snapshot to verify DOM structure
45+
const sidebarContent = await sidebar.textContent();
46+
expect(sidebarContent).toBeTruthy();
47+
48+
// Screenshot for visual comparison
49+
await expect(sidebar).toHaveScreenshot('sidebar.png', { maxDiffPixels: 100 });
50+
});
51+
52+
test('editor area screenshot', async ({ vscode: _vscode, page }) => {
53+
// vscode fixture ensures page is loaded
54+
// Take screenshot of editor/welcome area
55+
const editorPart = page.locator('.part.editor');
56+
await expect(editorPart).toBeVisible();
57+
await expect(editorPart).toHaveScreenshot('editor-area.png', { maxDiffPixels: 100 });
58+
});
59+
60+
});
4.81 KB
Loading
52.3 KB
Loading
5.69 KB
Loading
9.1 KB
Loading
74.6 KB
Loading

sample/src/web/test-playwright/vscode-api.spec.ts renamed to sample/src/web/test-playwright/vscode.spec.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,6 @@ test.describe('VSCode API Proxy', () => {
8888
expect(content).toBeDefined();
8989
expect(content.length).toBeGreaterThan(0);
9090
});
91-
92-
test('command execution (commands.executeCommand)', async ({ vscode, page }) => {
93-
await vscode.commands.executeCommand('vscode-test-web-sample.helloWorld');
94-
95-
// Wait for the notification message to appear
96-
const notification = page.locator('.notification-toast-container');
97-
await expect(notification).toContainText('Hello World from vscode-test-web-sample in a web extension host!');
98-
});
9991
});
10092

10193
});

0 commit comments

Comments
 (0)