|
| 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 | +}); |
0 commit comments