Skip to content

Commit c0522de

Browse files
first commit
0 parents  commit c0522de

8 files changed

Lines changed: 364 additions & 0 deletions

File tree

.github/workflows/playwright.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [ main, master ]
5+
pull_request:
6+
branches: [ main, master ]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: lts/*
16+
- name: Install dependencies
17+
run: npm ci
18+
- name: Install Playwright Browsers
19+
run: npx playwright install --with-deps
20+
- name: Run Playwright tests
21+
run: npx playwright test
22+
- uses: actions/upload-artifact@v4
23+
if: ${{ !cancelled() }}
24+
with:
25+
name: playwright-report
26+
path: playwright-report/
27+
retention-days: 30

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# Playwright
3+
node_modules/
4+
/test-results/
5+
/playwright-report/
6+
/blob-report/
7+
/playwright/.cache/
8+
/playwright/.auth/

package-lock.json

Lines changed: 97 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "playwright",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"scripts": {},
6+
"keywords": [],
7+
"author": "",
8+
"license": "ISC",
9+
"description": "",
10+
"devDependencies": {
11+
"@playwright/test": "^1.58.2",
12+
"@types/node": "^25.2.2"
13+
}
14+
}

playwright.config.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
/**
4+
* Read environment variables from file.
5+
* https://github.com/motdotla/dotenv
6+
*/
7+
// import dotenv from 'dotenv';
8+
// import path from 'path';
9+
// dotenv.config({ path: path.resolve(__dirname, '.env') });
10+
11+
/**
12+
* See https://playwright.dev/docs/test-configuration.
13+
*/
14+
export default defineConfig({
15+
testDir: './tests',
16+
/* Run tests in files in parallel */
17+
fullyParallel: true,
18+
/* Fail the build on CI if you accidentally left test.only in the source code. */
19+
forbidOnly: !!process.env.CI,
20+
/* Retry on CI only */
21+
retries: process.env.CI ? 2 : 0,
22+
/* Opt out of parallel tests on CI. */
23+
workers: process.env.CI ? 1 : undefined,
24+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
25+
reporter: 'html',
26+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
27+
use: {
28+
/* Base URL to use in actions like `await page.goto('')`. */
29+
// baseURL: 'http://localhost:3000',
30+
31+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
32+
trace: 'on-first-retry',
33+
},
34+
35+
/* Configure projects for major browsers */
36+
projects: [
37+
{
38+
name: 'chromium',
39+
use: { ...devices['Desktop Chrome'] },
40+
},
41+
42+
{
43+
name: 'firefox',
44+
use: { ...devices['Desktop Firefox'] },
45+
},
46+
47+
{
48+
name: 'webkit',
49+
use: { ...devices['Desktop Safari'] },
50+
},
51+
52+
/* Test against mobile viewports. */
53+
// {
54+
// name: 'Mobile Chrome',
55+
// use: { ...devices['Pixel 5'] },
56+
// },
57+
// {
58+
// name: 'Mobile Safari',
59+
// use: { ...devices['iPhone 12'] },
60+
// },
61+
62+
/* Test against branded browsers. */
63+
// {
64+
// name: 'Microsoft Edge',
65+
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
66+
// },
67+
// {
68+
// name: 'Google Chrome',
69+
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
70+
// },
71+
],
72+
73+
/* Run your local dev server before starting the tests */
74+
// webServer: {
75+
// command: 'npm run start',
76+
// url: 'http://localhost:3000',
77+
// reuseExistingServer: !process.env.CI,
78+
// },
79+
});

tests/TalentManagement.spec.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { test, expect } from '@playwright/test';
2+
import { exec } from 'child_process';
3+
import { promisify } from 'util';
4+
5+
const execAsync = promisify(exec);
6+
7+
// Helper function to speak text (blocking - waits for speech to complete)
8+
async function speak(text: string) {
9+
try {
10+
// Use PowerShell's speech synthesis on Windows
11+
await execAsync(`powershell -Command "Add-Type -AssemblyName System.Speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak('${text}')"`);
12+
} catch (error) {
13+
console.log(`Voice: ${text}`); // Fallback to console if speech fails
14+
}
15+
}
16+
17+
test('test', async ({ page }) => {
18+
// Increase timeout to allow for voice narration
19+
test.setTimeout(120000); // 2 minutes
20+
await speak('Navigating to dashboard');
21+
await page.goto('http://localhost:4200/dashboard');
22+
23+
await speak('Opening Employees menu');
24+
await page.getByRole('button', { name: 'Employees' }).click();
25+
await page.waitForTimeout(500); // Wait for menu to expand
26+
await speak('Viewing Employees List');
27+
await page.getByRole('link', { name: 'L List' }).click();
28+
29+
await speak('Opening Departments menu');
30+
await page.getByRole('button', { name: 'Departments' }).click();
31+
await page.waitForTimeout(500); // Wait for menu to expand
32+
await speak('Viewing Departments List');
33+
await page.getByRole('link', { name: 'L List' }).click();
34+
35+
await speak('Opening Positions menu');
36+
await page.getByRole('button', { name: 'Positions' }).click();
37+
await page.waitForTimeout(500); // Wait for menu to expand
38+
await speak('Viewing Positions List');
39+
await page.getByRole('link', { name: 'L List' }).click();
40+
41+
await speak('Opening Salary Ranges menu');
42+
await page.getByRole('button', { name: 'Salary Ranges' }).click();
43+
await page.waitForTimeout(500); // Wait for menu to expand
44+
await speak('Viewing Salary Ranges List');
45+
await page.getByRole('link', { name: 'L List' }).click();
46+
47+
await speak('Opening account menu');
48+
await page.getByRole('button').filter({ hasText: 'account_circle' }).click();
49+
await speak('Clicking Login');
50+
await page.getByRole('menuitem', { name: 'Login' }).click();
51+
await speak('Entering username');
52+
await page.getByRole('textbox', { name: 'Username' }).click();
53+
await page.getByRole('textbox', { name: 'Username' }).fill('ashtyn1');
54+
await speak('Entering password');
55+
await page.getByRole('textbox', { name: 'Password' }).click();
56+
await page.getByRole('textbox', { name: 'Password' }).fill('Pa$$word123');
57+
await speak('Logging in');
58+
await page.getByRole('button', { name: 'Login' }).click();
59+
60+
await speak('Opening Employees menu to create');
61+
await page.getByRole('button', { name: 'Employees' }).click();
62+
await page.waitForTimeout(500); // Wait for menu to expand
63+
await speak('Creating new Employee');
64+
await page.getByRole('link', { name: 'C Create' }).click();
65+
66+
await speak('Opening Departments menu to create');
67+
await page.getByRole('button', { name: 'Departments' }).click();
68+
await page.waitForTimeout(500); // Wait for menu to expand
69+
await speak('Creating new Department');
70+
await page.getByRole('link', { name: 'C Create' }).click();
71+
72+
await speak('Opening Positions menu to create');
73+
await page.getByRole('button', { name: 'Positions' }).click();
74+
await page.waitForTimeout(500); // Wait for menu to expand
75+
await speak('Creating new Position');
76+
await page.getByRole('link', { name: 'C Create' }).click();
77+
78+
await speak('Opening Salary Ranges menu to create');
79+
await page.getByRole('button', { name: 'Salary Ranges' }).click();
80+
await page.waitForTimeout(500); // Wait for menu to expand
81+
await speak('Creating new Salary Range');
82+
await page.getByRole('link', { name: 'C Create' }).click();
83+
84+
await speak('Opening account menu');
85+
await page.getByRole('button').filter({ hasText: 'account_circle' }).click();
86+
await speak('Logging out');
87+
await page.getByRole('menuitem', { name: 'logout' }).click();
88+
await speak('Test complete');
89+
await page.getByRole('link', { name: 'here' }).click();
90+
});

tests/example.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('has title', async ({ page }) => {
4+
await page.goto('https://playwright.dev/');
5+
6+
// Expect a title "to contain" a substring.
7+
await expect(page).toHaveTitle(/Playwright/);
8+
});
9+
10+
test('get started link', async ({ page }) => {
11+
await page.goto('https://playwright.dev/');
12+
13+
// Click the get started link.
14+
await page.getByRole('link', { name: 'Get started' }).click();
15+
16+
// Expects page to have a heading with the name of Installation.
17+
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
18+
});

tests/test-1.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('test', async ({ page }) => {
4+
await page.goto('http://localhost:4200/dashboard');
5+
await page.getByRole('button', { name: 'Employees' }).click();
6+
await page.getByRole('link', { name: 'L List' }).click();
7+
await page.getByRole('button', { name: 'Departments' }).click();
8+
await page.getByRole('link', { name: 'L List' }).click();
9+
await page.getByRole('button', { name: 'Positions' }).click();
10+
await page.getByRole('link', { name: 'L List' }).click();
11+
await page.getByRole('button', { name: 'Salary Ranges' }).click();
12+
await page.getByRole('link', { name: 'L List' }).click();
13+
await page.getByRole('button').filter({ hasText: 'account_circle' }).click();
14+
await page.getByRole('menuitem', { name: 'Login' }).click();
15+
await page.getByRole('textbox', { name: 'Username' }).click();
16+
await page.getByRole('textbox', { name: 'Username' }).fill('ashtyn1');
17+
await page.getByRole('textbox', { name: 'Password' }).click();
18+
await page.getByRole('textbox', { name: 'Password' }).fill('Pa$$word123');
19+
await page.getByRole('button', { name: 'Login' }).click();
20+
await page.getByRole('button', { name: 'Employees' }).click();
21+
await page.getByRole('link', { name: 'C Create' }).click();
22+
await page.getByRole('button', { name: 'Departments' }).click();
23+
await page.getByRole('link', { name: 'C Create' }).click();
24+
await page.getByRole('button', { name: 'Positions' }).click();
25+
await page.getByRole('link', { name: 'C Create' }).click();
26+
await page.getByRole('button', { name: 'Salary Ranges' }).click();
27+
await page.getByRole('link', { name: 'C Create' }).click();
28+
await page.getByRole('button').filter({ hasText: 'account_circle' }).click();
29+
await page.getByRole('menuitem', { name: 'logout' }).click();
30+
await page.getByRole('link', { name: 'here' }).click();
31+
});

0 commit comments

Comments
 (0)