-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): Set up Playwright test environment for desktop app
- Configure Playwright for desktop testing with Chromium - Add test scripts for e2e testing in dev and prod modes - Create basic desktop test suite with viewport and page load tests - Set up test utilities and configuration - Update .gitignore to exclude test artifacts - Add cross-env and playwright dependencies
- Loading branch information
Showing
8 changed files
with
225 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ node_modules | |
!.env.example | ||
vite.config.js.timestamp-* | ||
vite.config.ts.timestamp-* | ||
|
||
/test-results | ||
/playwright-report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
export default defineConfig({ | ||
testDir: './tests/e2e', | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
reporter: 'html', | ||
use: { | ||
// Testing the app in development mode | ||
baseURL: process.env.TAURI_DEV ? 'http://localhost:5173' : 'tauri://localhost', | ||
trace: 'on-first-retry', | ||
screenshot: 'only-on-failure', | ||
video: 'on-first-retry', | ||
}, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { | ||
...devices['Desktop Chrome'], | ||
viewport: { width: 1280, height: 720 }, | ||
launchOptions: { | ||
args: ['--no-sandbox'] | ||
} | ||
}, | ||
} | ||
], | ||
webServer: process.env.TAURI_DEV ? { | ||
command: 'bun run start', | ||
url: 'http://localhost:5173', | ||
reuseExistingServer: !process.env.CI, | ||
timeout: 120000, // Increase timeout to 2 minutes | ||
} : undefined, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { setupDesktopTest } from '../../utils/setup-desktop'; | ||
|
||
test.describe('Basic Desktop Tests', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await setupDesktopTest({ page }); | ||
}); | ||
|
||
test('should load the application', async ({ page }) => { | ||
// Navigate to the home page | ||
await page.goto('/'); | ||
|
||
// Wait for the page to be fully loaded | ||
await page.waitForLoadState('networkidle'); | ||
|
||
// Basic check for main content | ||
const mainContent = await page.locator('body'); | ||
await expect(mainContent).toBeVisible(); | ||
|
||
// Take a screenshot for visual verification | ||
await page.screenshot({ | ||
path: 'test-results/home-page.png', | ||
fullPage: true | ||
}); | ||
}); | ||
|
||
test('should have correct window size', async ({ page }) => { | ||
const viewport = page.viewportSize(); | ||
expect(viewport?.width).toBe(1280); | ||
expect(viewport?.height).toBe(720); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('should load the application', async ({ page }) => { | ||
await page.goto('/'); | ||
|
||
// Wait for the page to be fully loaded | ||
await page.waitForLoadState('networkidle'); | ||
|
||
// Check if the page has loaded by verifying basic HTML structure | ||
await expect(page.locator('html[lang="en"]')).toBeVisible(); | ||
await expect(page.locator('body')).toBeVisible(); | ||
|
||
// Take a screenshot | ||
await page.screenshot({ | ||
path: 'test-results/example-page.png', | ||
fullPage: true | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { Page } from '@playwright/test'; | ||
|
||
export const setupDesktopTest = async ({ page }: { page: Page }) => { | ||
// Set window size | ||
await page.setViewportSize({ width: 1280, height: 720 }); | ||
|
||
// Additional desktop-specific setup | ||
if (process.env.TAURI_DEV) { | ||
console.log('Running in development mode'); | ||
} else { | ||
console.log('Running in production mode'); | ||
} | ||
}; |