Spaces:
Running
Running
alessandro trinca tornidor
commited on
Commit
·
a1c02f9
1
Parent(s):
7aaf29c
test: add first playwright test e2e
Browse files- static/.gitignore +2 -0
- static/.vscode/launch.json +20 -0
- static/package.json +15 -0
- static/playwright.config.ts +91 -0
- static/pnpm-lock.yaml +52 -0
- static/tests/test-1.spec.ts +26 -0
static/.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
playwright-report/*
|
2 |
+
node_modules
|
static/.vscode/launch.json
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
// Use IntelliSense to learn about possible attributes.
|
3 |
+
// Hover to view descriptions of existing attributes.
|
4 |
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
5 |
+
"version": "0.2.0",
|
6 |
+
"configurations": [
|
7 |
+
{
|
8 |
+
"type": "node",
|
9 |
+
"request": "launch",
|
10 |
+
"name": "Launch Program",
|
11 |
+
"skipFiles": [
|
12 |
+
"<node_internals>/**"
|
13 |
+
],
|
14 |
+
"program": "${workspaceFolder}/tests/test-1.spec.ts",
|
15 |
+
"outFiles": [
|
16 |
+
"${workspaceFolder}/**/*.js"
|
17 |
+
]
|
18 |
+
}
|
19 |
+
]
|
20 |
+
}
|
static/package.json
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "ai-pronunciation-trainer",
|
3 |
+
"version": "1.0.0",
|
4 |
+
"description": "",
|
5 |
+
"main": "index.js",
|
6 |
+
"scripts": {
|
7 |
+
"test": "echo \"Error: no test specified\" && exit 1"
|
8 |
+
},
|
9 |
+
"keywords": [],
|
10 |
+
"author": "",
|
11 |
+
"license": "ISC",
|
12 |
+
"dependencies": {
|
13 |
+
"@playwright/test": "^1.48.2"
|
14 |
+
}
|
15 |
+
}
|
static/playwright.config.ts
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { defineConfig, devices } from '@playwright/test';
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Read environment variables from file.
|
5 |
+
* https://github.com/motdotla/dotenv
|
6 |
+
*/
|
7 |
+
// require('dotenv').config();
|
8 |
+
|
9 |
+
/**
|
10 |
+
* See https://playwright.dev/docs/test-configuration.
|
11 |
+
*/
|
12 |
+
export default defineConfig({
|
13 |
+
timeout: 60 * 1000,
|
14 |
+
testDir: './tests',
|
15 |
+
/* Run tests in files in parallel */
|
16 |
+
fullyParallel: true,
|
17 |
+
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
18 |
+
forbidOnly: !!process.env.CI,
|
19 |
+
/* Retry on CI only */
|
20 |
+
retries: process.env.CI ? 2 : 0,
|
21 |
+
/* Opt out of parallel tests on CI. */
|
22 |
+
workers: process.env.CI ? 1 : undefined,
|
23 |
+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
24 |
+
reporter: [ ['html', { open: 'never' }] ],
|
25 |
+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
26 |
+
use: {
|
27 |
+
/* Base URL to use in actions like `await page.goto('/')`. */
|
28 |
+
baseURL: 'http://127.0.0.1:3000',
|
29 |
+
viewport: { width: 1280, height: 900 },
|
30 |
+
ignoreHTTPSErrors: true,
|
31 |
+
permissions: ['microphone'],
|
32 |
+
screenshot: 'only-on-failure',
|
33 |
+
trace: 'on-first-retry',
|
34 |
+
video: 'retain-on-failure',
|
35 |
+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
36 |
+
},
|
37 |
+
|
38 |
+
/* Configure projects for major browsers */
|
39 |
+
projects: [
|
40 |
+
{
|
41 |
+
name: 'chromium',
|
42 |
+
// grepInvert: /mobile/,
|
43 |
+
use: {
|
44 |
+
...devices['Desktop Chrome'],
|
45 |
+
viewport: { width: 1280, height: 900 },
|
46 |
+
},
|
47 |
+
},
|
48 |
+
|
49 |
+
{
|
50 |
+
name: 'firefox',
|
51 |
+
// grepInvert: /mobile/,
|
52 |
+
use: { ...devices['Desktop Firefox'] },
|
53 |
+
},
|
54 |
+
|
55 |
+
{
|
56 |
+
name: 'webkit',
|
57 |
+
// grepInvert: /mobile/,
|
58 |
+
use: { ...devices['Desktop Safari'] },
|
59 |
+
},
|
60 |
+
|
61 |
+
/*
|
62 |
+
// Test against mobile viewports.
|
63 |
+
{
|
64 |
+
name: 'MobileChrome',
|
65 |
+
// grep: /mobile/,
|
66 |
+
use: { ...devices['Pixel 5'] },
|
67 |
+
},
|
68 |
+
{
|
69 |
+
name: 'MobileSafari',
|
70 |
+
// grep: /mobile/,
|
71 |
+
use: { ...devices['iPhone 12'] },
|
72 |
+
},
|
73 |
+
|
74 |
+
// Test against branded browsers.
|
75 |
+
{
|
76 |
+
name: 'Microsoft Edge',
|
77 |
+
use: { ...devices['Desktop Edge'], channel: 'msedge' },
|
78 |
+
},
|
79 |
+
{
|
80 |
+
name: 'Google Chrome',
|
81 |
+
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
|
82 |
+
},*/
|
83 |
+
],
|
84 |
+
|
85 |
+
/* Run your local dev server before starting the tests */
|
86 |
+
// webServer: {
|
87 |
+
// command: 'npm run start',
|
88 |
+
// url: 'http://127.0.0.1:3000',
|
89 |
+
// reuseExistingServer: !process.env.CI,
|
90 |
+
// },
|
91 |
+
});
|
static/pnpm-lock.yaml
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
lockfileVersion: '9.0'
|
2 |
+
|
3 |
+
settings:
|
4 |
+
autoInstallPeers: true
|
5 |
+
excludeLinksFromLockfile: false
|
6 |
+
|
7 |
+
importers:
|
8 |
+
|
9 |
+
.:
|
10 |
+
dependencies:
|
11 |
+
'@playwright/test':
|
12 |
+
specifier: ^1.48.2
|
13 |
+
version: 1.48.2
|
14 |
+
|
15 |
+
packages:
|
16 |
+
|
17 |
+
'@playwright/test@1.48.2':
|
18 |
+
resolution: {integrity: sha512-54w1xCWfXuax7dz4W2M9uw0gDyh+ti/0K/MxcCUxChFh37kkdxPdfZDw5QBbuPUJHr1CiHJ1hXgSs+GgeQc5Zw==}
|
19 |
+
engines: {node: '>=18'}
|
20 |
+
hasBin: true
|
21 |
+
|
22 |
+
fsevents@2.3.2:
|
23 |
+
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
|
24 |
+
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
25 |
+
os: [darwin]
|
26 |
+
|
27 |
+
playwright-core@1.48.2:
|
28 |
+
resolution: {integrity: sha512-sjjw+qrLFlriJo64du+EK0kJgZzoQPsabGF4lBvsid+3CNIZIYLgnMj9V6JY5VhM2Peh20DJWIVpVljLLnlawA==}
|
29 |
+
engines: {node: '>=18'}
|
30 |
+
hasBin: true
|
31 |
+
|
32 |
+
playwright@1.48.2:
|
33 |
+
resolution: {integrity: sha512-NjYvYgp4BPmiwfe31j4gHLa3J7bD2WiBz8Lk2RoSsmX38SVIARZ18VYjxLjAcDsAhA+F4iSEXTSGgjua0rrlgQ==}
|
34 |
+
engines: {node: '>=18'}
|
35 |
+
hasBin: true
|
36 |
+
|
37 |
+
snapshots:
|
38 |
+
|
39 |
+
'@playwright/test@1.48.2':
|
40 |
+
dependencies:
|
41 |
+
playwright: 1.48.2
|
42 |
+
|
43 |
+
fsevents@2.3.2:
|
44 |
+
optional: true
|
45 |
+
|
46 |
+
playwright-core@1.48.2: {}
|
47 |
+
|
48 |
+
playwright@1.48.2:
|
49 |
+
dependencies:
|
50 |
+
playwright-core: 1.48.2
|
51 |
+
optionalDependencies:
|
52 |
+
fsevents: 2.3.2
|
static/tests/test-1.spec.ts
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { test, expect, chromium } from "@playwright/test";
|
2 |
+
|
3 |
+
test("test: get a custom sample writing within the input field.", async () => {
|
4 |
+
const browser = await chromium.launch({
|
5 |
+
args: [
|
6 |
+
"--use-fake-device-for-media-stream",
|
7 |
+
"--use-fake-ui-for-media-stream",
|
8 |
+
],
|
9 |
+
});
|
10 |
+
const context = await browser.newContext();
|
11 |
+
context.grantPermissions(["microphone"]);
|
12 |
+
const page = await browser.newPage({});
|
13 |
+
await page.goto("/");
|
14 |
+
|
15 |
+
const inputField = page.getByPlaceholder(
|
16 |
+
"Write and press enter to filter"
|
17 |
+
);
|
18 |
+
await inputField.fill("Hi Tom, how are you?");
|
19 |
+
await inputField.press("Enter");
|
20 |
+
await expect(page.getByText("Hi Tom, how are you?")).toBeVisible();
|
21 |
+
await expect(
|
22 |
+
page.getByText("/ hiː toːm, hoː aːrɛː yːuː? /")
|
23 |
+
).toBeVisible();
|
24 |
+
console.log("end");
|
25 |
+
await page.close();
|
26 |
+
});
|