Spaces:
Running
Running
alessandro trinca tornidor
commited on
Commit
·
ab57dda
1
Parent(s):
8b607be
test: add more e2e test cases
Browse files- static/package.json +1 -0
- static/playwright.config.ts +0 -1
- static/tests/test-app-7860-example-medium0-upload-de.spec.ts +48 -0
- static/tests/test-app-7860-example-medium0-upload-en.spec.ts +48 -0
- static/tests/test-app-7860-random-upload-de.spec.ts +64 -0
- static/tests/test-app-7860-random-upload-en.spec.ts +60 -0
- static/tests/test-app-7860-upload-de.spec.ts +49 -0
- static/tests/test-app-7860-upload-en.spec.ts +3 -7
- static/tests/test-webApp-3000.spec.ts +13 -2
- static/tests/test-webApp-3000.spec.ts-snapshots/test-get-a-custom-sample-writing-within-the-input-field-1-chromium-linux.png +3 -0
- static/tests/test-webApp-3000.spec.ts-snapshots/test-get-a-custom-sample-writing-within-the-input-field-1-firefox-linux.png +3 -0
- static/tests/test-webApp-3000.spec.ts-snapshots/test-get-a-custom-sample-writing-within-the-input-field-1-webkit-linux.png +3 -0
- static/tests_broken/test-app-7860-example-medium--rec-en.spec.ts +70 -0
- static/tests_broken/test-app-7860-rec-de.spec.ts +100 -0
- static/{tests → tests_broken}/test-app-7860-rec-en.spec.ts +4 -5
- tests/events/test_de_easy.wav +3 -0
- tests/events/test_de_hard.wav +3 -0
- tests/events/test_de_medium.wav +3 -0
- tests/events/test_en_easy.wav +3 -0
- tests/events/test_en_hard.wav +3 -0
- tests/events/test_en_medium.wav +3 -0
static/package.json
CHANGED
@@ -6,6 +6,7 @@
|
|
6 |
"scripts": {
|
7 |
"test": "echo \"Error: no test specified\" && exit 1"
|
8 |
},
|
|
|
9 |
"keywords": [],
|
10 |
"author": "",
|
11 |
"license": "ISC",
|
|
|
6 |
"scripts": {
|
7 |
"test": "echo \"Error: no test specified\" && exit 1"
|
8 |
},
|
9 |
+
"type": "module",
|
10 |
"keywords": [],
|
11 |
"author": "",
|
12 |
"license": "ISC",
|
static/playwright.config.ts
CHANGED
@@ -34,7 +34,6 @@ export default defineConfig({
|
|
34 |
trace: 'on-first-retry',
|
35 |
video: 'retain-on-failure',
|
36 |
launchOptions: {
|
37 |
-
headless: false,
|
38 |
ignoreDefaultArgs: ['--mute-audio'],
|
39 |
args: [
|
40 |
"--use-fake-device-for-media-stream",
|
|
|
34 |
trace: 'on-first-retry',
|
35 |
video: 'retain-on-failure',
|
36 |
launchOptions: {
|
|
|
37 |
ignoreDefaultArgs: ['--mute-audio'],
|
38 |
args: [
|
39 |
"--use-fake-device-for-media-stream",
|
static/tests/test-app-7860-example-medium0-upload-de.spec.ts
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { test, expect, chromium } from "@playwright/test";
|
2 |
+
|
3 |
+
test("test: get a phonetic accuracy evaluation from an uploaded audio file.", async () => {
|
4 |
+
const testAudioEnvPath = `${import.meta.dirname}/../../tests/events/test_de_medium.wav`
|
5 |
+
console.log(`testAudioEnvPath: ${testAudioEnvPath}...`);
|
6 |
+
|
7 |
+
const browser = await chromium.launch({
|
8 |
+
args: [
|
9 |
+
"--use-fake-device-for-media-stream",
|
10 |
+
],
|
11 |
+
ignoreDefaultArgs: ['--mute-audio']
|
12 |
+
})
|
13 |
+
|
14 |
+
const context = await browser.newContext();
|
15 |
+
context.grantPermissions(["microphone"]);
|
16 |
+
const page = await browser.newPage({});
|
17 |
+
|
18 |
+
await page.goto('http://localhost:7860/');
|
19 |
+
|
20 |
+
const accordionExamples = page.getByText('Click here to expand the table examples ▼ Examples Learner Transcription');
|
21 |
+
accordionExamples.click();
|
22 |
+
const exampleMediumFirst = page.getByRole('gridcell', { name: 'medium' }).first();
|
23 |
+
await exampleMediumFirst.click();
|
24 |
+
|
25 |
+
await page.getByRole('button', { name: 'Run TTS' }).click();
|
26 |
+
const buttonPlay = page.getByLabel('Play', { exact: true })
|
27 |
+
await buttonPlay.click();
|
28 |
+
const waveFormTTS = page.locator('.scroll > .wrapper').first();
|
29 |
+
await waveFormTTS.waitFor({ state: 'attached' });
|
30 |
+
await waveFormTTS.waitFor({ state: 'visible' });
|
31 |
+
await expect(waveFormTTS).toBeVisible();
|
32 |
+
|
33 |
+
const fileChooserPromise = page.waitForEvent('filechooser');
|
34 |
+
await page.getByLabel('Upload file').click();
|
35 |
+
await page.getByRole('button', { name: 'Drop Audio Here - or - Click' }).click();
|
36 |
+
const fileChooser = await fileChooserPromise;
|
37 |
+
await fileChooser.setFiles(testAudioEnvPath);
|
38 |
+
|
39 |
+
await page.getByRole('button', { name: 'Recognize speech accuracy' }).click();
|
40 |
+
|
41 |
+
await page.waitForTimeout(300);
|
42 |
+
const errorsElements = page.getByText(/Error/);
|
43 |
+
const ErrorText = errorsElements.all()
|
44 |
+
console.log(`ErrorText: ${(await ErrorText).length}...`)
|
45 |
+
await expect(errorsElements).toHaveCount(0);
|
46 |
+
console.log("end");
|
47 |
+
await page.close();
|
48 |
+
});
|
static/tests/test-app-7860-example-medium0-upload-en.spec.ts
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { test, expect, chromium } from "@playwright/test";
|
2 |
+
|
3 |
+
test("test: get a phonetic accuracy evaluation from an uploaded audio file.", async () => {
|
4 |
+
const testAudioEnvPath = `${import.meta.dirname}/../../tests/events/test_en_medium.wav`
|
5 |
+
console.log(`testAudioEnvPath: ${testAudioEnvPath}...`);
|
6 |
+
|
7 |
+
const browser = await chromium.launch({
|
8 |
+
args: [
|
9 |
+
"--use-fake-device-for-media-stream",
|
10 |
+
],
|
11 |
+
ignoreDefaultArgs: ['--mute-audio']
|
12 |
+
})
|
13 |
+
|
14 |
+
const context = await browser.newContext();
|
15 |
+
context.grantPermissions(["microphone"]);
|
16 |
+
const page = await browser.newPage({});
|
17 |
+
|
18 |
+
await page.goto('http://localhost:7860/');
|
19 |
+
|
20 |
+
const accordionExamples = page.getByText('Click here to expand the table examples ▼ Examples Learner Transcription');
|
21 |
+
accordionExamples.click();
|
22 |
+
const exampleMediumFirst = page.getByRole('gridcell', { name: 'medium' }).nth(1);
|
23 |
+
await exampleMediumFirst.click();
|
24 |
+
|
25 |
+
await page.getByRole('button', { name: 'Run TTS' }).click();
|
26 |
+
const buttonPlay = page.getByLabel('Play', { exact: true })
|
27 |
+
await buttonPlay.click();
|
28 |
+
const waveFormTTS = page.locator('.scroll > .wrapper').first();
|
29 |
+
await waveFormTTS.waitFor({ state: 'attached' });
|
30 |
+
await waveFormTTS.waitFor({ state: 'visible' });
|
31 |
+
await expect(waveFormTTS).toBeVisible();
|
32 |
+
|
33 |
+
const fileChooserPromise = page.waitForEvent('filechooser');
|
34 |
+
await page.getByLabel('Upload file').click();
|
35 |
+
await page.getByRole('button', { name: 'Drop Audio Here - or - Click' }).click();
|
36 |
+
const fileChooser = await fileChooserPromise;
|
37 |
+
await fileChooser.setFiles(testAudioEnvPath);
|
38 |
+
|
39 |
+
await page.getByRole('button', { name: 'Recognize speech accuracy' }).click();
|
40 |
+
|
41 |
+
await page.waitForTimeout(300);
|
42 |
+
const errorsElements = page.getByText(/Error/);
|
43 |
+
const ErrorText = errorsElements.all()
|
44 |
+
console.log(`ErrorText: ${(await ErrorText).length}...`)
|
45 |
+
await expect(errorsElements).toHaveCount(0);
|
46 |
+
console.log("end");
|
47 |
+
await page.close();
|
48 |
+
});
|
static/tests/test-app-7860-random-upload-de.spec.ts
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { test, expect, chromium, } from "@playwright/test";
|
2 |
+
|
3 |
+
test("test: get a phonetic accuracy evaluation from an uploaded audio file.", async () => {
|
4 |
+
const testAudioEnvPath = `${import.meta.dirname}/../../tests/events/test_de_easy.wav`
|
5 |
+
console.log(`testAudioEnvPath: ${testAudioEnvPath}...`);
|
6 |
+
|
7 |
+
const browser = await chromium.launch({
|
8 |
+
args: [
|
9 |
+
"--use-fake-device-for-media-stream",
|
10 |
+
],
|
11 |
+
ignoreDefaultArgs: ['--mute-audio']
|
12 |
+
})
|
13 |
+
|
14 |
+
const context = await browser.newContext();
|
15 |
+
context.grantPermissions(["microphone"]);
|
16 |
+
const page = await browser.newPage({});
|
17 |
+
|
18 |
+
await page.goto('http://localhost:7860/');
|
19 |
+
await page.waitForSelector("textarea")
|
20 |
+
|
21 |
+
const textboxLearnerTranscriptionInput = page.getByLabel("Learner Transcription");
|
22 |
+
let learnerTranscriptionScreenshot0 = await textboxLearnerTranscriptionInput.screenshot()
|
23 |
+
|
24 |
+
const buttonRandom = page.getByRole('button', { name: 'Choose a random phrase' });
|
25 |
+
await buttonRandom.click();
|
26 |
+
await page.waitForTimeout(300);
|
27 |
+
let learnerTranscriptionScreenshot1 = await textboxLearnerTranscriptionInput.screenshot();
|
28 |
+
|
29 |
+
// find a way to measure how much the screenshots differ
|
30 |
+
// assert that the Learner Transcription screenshots (converted both to base64 strings) changed
|
31 |
+
expect(
|
32 |
+
learnerTranscriptionScreenshot0.toString('base64')
|
33 |
+
).not.toEqual(
|
34 |
+
learnerTranscriptionScreenshot1.toString('base64')
|
35 |
+
)
|
36 |
+
|
37 |
+
await page.getByRole('button', { name: 'Run TTS' }).click();
|
38 |
+
const buttonPlay = page.getByLabel('Play', { exact: true })
|
39 |
+
await buttonPlay.click();
|
40 |
+
const waveFormTTS = page.locator('.scroll > .wrapper').first();
|
41 |
+
await waveFormTTS.waitFor({ state: 'attached' });
|
42 |
+
await waveFormTTS.waitFor({ state: 'visible' });
|
43 |
+
await expect(waveFormTTS).toBeVisible();
|
44 |
+
|
45 |
+
const fileChooserPromise = page.waitForEvent('filechooser');
|
46 |
+
await page.getByLabel('Upload file').click();
|
47 |
+
await page.getByRole('button', { name: 'Drop Audio Here - or - Click' }).click();
|
48 |
+
const fileChooser = await fileChooserPromise;
|
49 |
+
await fileChooser.setFiles(testAudioEnvPath);
|
50 |
+
|
51 |
+
await page.getByRole('button', { name: 'Recognize speech accuracy' }).click();
|
52 |
+
|
53 |
+
await page.waitForTimeout(300);
|
54 |
+
const errorsElements = page.getByText(/Error/);
|
55 |
+
const ErrorText = errorsElements.all()
|
56 |
+
console.log(`ErrorText: ${(await ErrorText).length}...`)
|
57 |
+
await expect(errorsElements).toHaveCount(0);
|
58 |
+
|
59 |
+
// find a way to validate the different 'Current score' field values
|
60 |
+
// const currentScore = page.getByLabel('Current score');
|
61 |
+
// const currentScoreText = await currentScore.innerText();
|
62 |
+
console.log("end");
|
63 |
+
await page.close();
|
64 |
+
});
|
static/tests/test-app-7860-random-upload-en.spec.ts
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { test, expect, chromium } from "@playwright/test";
|
2 |
+
|
3 |
+
test("test: get a phonetic accuracy evaluation from an uploaded audio file.", async () => {
|
4 |
+
const testAudioEnvPath = `${import.meta.dirname}/../../tests/events/test_de_easy.wav`
|
5 |
+
console.log(`testAudioEnvPath: ${testAudioEnvPath}...`);
|
6 |
+
|
7 |
+
const browser = await chromium.launch({
|
8 |
+
args: [
|
9 |
+
"--use-fake-device-for-media-stream",
|
10 |
+
],
|
11 |
+
ignoreDefaultArgs: ['--mute-audio']
|
12 |
+
})
|
13 |
+
|
14 |
+
const context = await browser.newContext();
|
15 |
+
context.grantPermissions(["microphone"]);
|
16 |
+
const page = await browser.newPage({});
|
17 |
+
|
18 |
+
await page.goto('http://localhost:7860/');
|
19 |
+
await page.waitForSelector("textarea")
|
20 |
+
|
21 |
+
const textboxLearnerTranscriptionInput = page.getByLabel("Learner Transcription");
|
22 |
+
let learnerTranscriptionScreenshot0 = await textboxLearnerTranscriptionInput.screenshot()
|
23 |
+
|
24 |
+
const buttonRandom = page.getByRole('button', { name: 'Choose a random phrase' });
|
25 |
+
await buttonRandom.click();
|
26 |
+
await page.waitForTimeout(300);
|
27 |
+
let learnerTranscriptionScreenshot1 = await textboxLearnerTranscriptionInput.screenshot();
|
28 |
+
|
29 |
+
// find a way to measure how much the screenshots differ
|
30 |
+
// assert that the Learner Transcription screenshots (converted both to base64 strings) changed
|
31 |
+
expect(
|
32 |
+
learnerTranscriptionScreenshot0.toString('base64')
|
33 |
+
).not.toEqual(
|
34 |
+
learnerTranscriptionScreenshot1.toString('base64')
|
35 |
+
)
|
36 |
+
|
37 |
+
await page.getByRole('button', { name: 'Run TTS' }).click();
|
38 |
+
const buttonPlay = page.getByLabel('Play', { exact: true })
|
39 |
+
await buttonPlay.click();
|
40 |
+
const waveFormTTS = page.locator('.scroll > .wrapper').first();
|
41 |
+
await waveFormTTS.waitFor({ state: 'attached' });
|
42 |
+
await waveFormTTS.waitFor({ state: 'visible' });
|
43 |
+
await expect(waveFormTTS).toBeVisible();
|
44 |
+
|
45 |
+
const fileChooserPromise = page.waitForEvent('filechooser');
|
46 |
+
await page.getByLabel('Upload file').click();
|
47 |
+
await page.getByRole('button', { name: 'Drop Audio Here - or - Click' }).click();
|
48 |
+
const fileChooser = await fileChooserPromise;
|
49 |
+
await fileChooser.setFiles(testAudioEnvPath);
|
50 |
+
|
51 |
+
await page.getByRole('button', { name: 'Recognize speech accuracy' }).click();
|
52 |
+
|
53 |
+
await page.waitForTimeout(300);
|
54 |
+
const errorsElements = page.getByText(/Error/);
|
55 |
+
const ErrorText = errorsElements.all()
|
56 |
+
console.log(`ErrorText: ${(await ErrorText).length}...`)
|
57 |
+
await expect(errorsElements).toHaveCount(0);
|
58 |
+
console.log("end");
|
59 |
+
await page.close();
|
60 |
+
});
|
static/tests/test-app-7860-upload-de.spec.ts
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { test, expect, chromium } from "@playwright/test";
|
2 |
+
|
3 |
+
test("test: get a phonetic accuracy evaluation from an uploaded audio file.", async () => {
|
4 |
+
const testAudioEnvPath = `${import.meta.dirname}/../../tests/events/test_de_easy.wav`
|
5 |
+
console.log(`testAudioEnvPath: ${testAudioEnvPath}...`);
|
6 |
+
|
7 |
+
const browser = await chromium.launch({
|
8 |
+
args: [
|
9 |
+
"--use-fake-device-for-media-stream",
|
10 |
+
],
|
11 |
+
ignoreDefaultArgs: ['--mute-audio']
|
12 |
+
})
|
13 |
+
|
14 |
+
const context = await browser.newContext();
|
15 |
+
context.grantPermissions(["microphone"]);
|
16 |
+
const page = await browser.newPage({});
|
17 |
+
|
18 |
+
await page.goto('http://localhost:7860/');
|
19 |
+
|
20 |
+
const radioLanguageSelectedDE = page.getByRole('radio', { name: 'de' })
|
21 |
+
await radioLanguageSelectedDE.check();
|
22 |
+
|
23 |
+
const textboxLearnerTranscriptionInput = page.getByLabel('Learner Transcription')
|
24 |
+
await textboxLearnerTranscriptionInput.fill('Ich bin Alex, wer bist du?');
|
25 |
+
|
26 |
+
await page.getByRole('button', { name: 'Run TTS' }).click();
|
27 |
+
const buttonPlay = page.getByLabel('Play', { exact: true })
|
28 |
+
await buttonPlay.click();
|
29 |
+
const waveFormTTS = page.locator('.scroll > .wrapper').first();
|
30 |
+
await waveFormTTS.waitFor({ state: 'attached' });
|
31 |
+
await waveFormTTS.waitFor({ state: 'visible' });
|
32 |
+
await expect(waveFormTTS).toBeVisible();
|
33 |
+
|
34 |
+
const fileChooserPromise = page.waitForEvent('filechooser');
|
35 |
+
await page.getByLabel('Upload file').click();
|
36 |
+
await page.getByRole('button', { name: 'Drop Audio Here - or - Click' }).click();
|
37 |
+
const fileChooser = await fileChooserPromise;
|
38 |
+
await fileChooser.setFiles(testAudioEnvPath);
|
39 |
+
|
40 |
+
await page.getByRole('button', { name: 'Recognize speech accuracy' }).click();
|
41 |
+
|
42 |
+
await page.waitForTimeout(300);
|
43 |
+
const errorsElements = page.getByText(/Error/);
|
44 |
+
const ErrorText = errorsElements.all()
|
45 |
+
console.log("ErrorText:", (await ErrorText).length, "#");
|
46 |
+
await expect(errorsElements).toHaveCount(0);
|
47 |
+
console.log("end");
|
48 |
+
await page.close();
|
49 |
+
});
|
static/tests/test-app-7860-upload-en.spec.ts
CHANGED
@@ -1,11 +1,8 @@
|
|
1 |
-
import { test, expect, chromium
|
2 |
-
|
3 |
-
const basedirAudioFiles = `${__dirname}/../../tests/events`
|
4 |
|
5 |
test("test: get a phonetic accuracy evaluation from an uploaded audio file.", async () => {
|
6 |
-
const testAudioEnvPath = `${
|
7 |
-
console.log(
|
8 |
-
console.log("testAudioEnvPath", testAudioEnvPath, "#");
|
9 |
|
10 |
const browser = await chromium.launch({
|
11 |
args: [
|
@@ -26,7 +23,6 @@ test("test: get a phonetic accuracy evaluation from an uploaded audio file.", as
|
|
26 |
await waveFormTTS.waitFor({ state: 'attached' });
|
27 |
await waveFormTTS.waitFor({ state: 'visible' });
|
28 |
await expect(waveFormTTS).toBeVisible();
|
29 |
-
console.log("waveFormTTS??");
|
30 |
|
31 |
const fileChooserPromise = page.waitForEvent('filechooser');
|
32 |
await page.getByLabel('Upload file').click();
|
|
|
1 |
+
import { test, expect, chromium } from "@playwright/test";
|
|
|
|
|
2 |
|
3 |
test("test: get a phonetic accuracy evaluation from an uploaded audio file.", async () => {
|
4 |
+
const testAudioEnvPath = `${import.meta.dirname}/../../tests/events/test_en_easy.wav`
|
5 |
+
console.log(`testAudioEnvPath: ${testAudioEnvPath}...`);
|
|
|
6 |
|
7 |
const browser = await chromium.launch({
|
8 |
args: [
|
|
|
23 |
await waveFormTTS.waitFor({ state: 'attached' });
|
24 |
await waveFormTTS.waitFor({ state: 'visible' });
|
25 |
await expect(waveFormTTS).toBeVisible();
|
|
|
26 |
|
27 |
const fileChooserPromise = page.waitForEvent('filechooser');
|
28 |
await page.getByLabel('Upload file').click();
|
static/tests/test-webApp-3000.spec.ts
CHANGED
@@ -11,16 +11,27 @@ test("test: get a custom sample writing within the input field.", async () => {
|
|
11 |
context.grantPermissions(["microphone"]);
|
12 |
const page = await browser.newPage({});
|
13 |
await page.goto("http://localhost:3000");
|
|
|
|
|
|
|
|
|
14 |
|
15 |
const inputField = page.getByPlaceholder(
|
16 |
"Write and press enter to filter"
|
17 |
);
|
18 |
-
|
|
|
|
|
19 |
await inputField.press("Enter");
|
20 |
-
await expect(page.getByText(
|
|
|
|
|
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 |
});
|
|
|
11 |
context.grantPermissions(["microphone"]);
|
12 |
const page = await browser.newPage({});
|
13 |
await page.goto("http://localhost:3000");
|
14 |
+
await expect(page).toHaveTitle("AI pronunciation trainer");
|
15 |
+
|
16 |
+
const textDescription = page.getByText("Click on the bar on the");
|
17 |
+
await expect(textDescription).toBeVisible();
|
18 |
|
19 |
const inputField = page.getByPlaceholder(
|
20 |
"Write and press enter to filter"
|
21 |
);
|
22 |
+
const text = "Hi Tom, how are you?"
|
23 |
+
await expect(page.getByText(text)).toBeHidden();
|
24 |
+
await inputField.fill(text);
|
25 |
await inputField.press("Enter");
|
26 |
+
await expect(page.getByText(text)).toBeVisible();
|
27 |
+
await page.waitForTimeout(500);
|
28 |
+
|
29 |
await expect(
|
30 |
page.getByText("/ hiː toːm, hoː aːrɛː yːuː? /")
|
31 |
).toBeVisible();
|
32 |
+
await expect(textDescription).toBeHidden();
|
33 |
+
await expect(page).toHaveScreenshot();
|
34 |
+
|
35 |
console.log("end");
|
36 |
await page.close();
|
37 |
});
|
static/tests/test-webApp-3000.spec.ts-snapshots/test-get-a-custom-sample-writing-within-the-input-field-1-chromium-linux.png
ADDED
Git LFS Details
|
static/tests/test-webApp-3000.spec.ts-snapshots/test-get-a-custom-sample-writing-within-the-input-field-1-firefox-linux.png
ADDED
Git LFS Details
|
static/tests/test-webApp-3000.spec.ts-snapshots/test-get-a-custom-sample-writing-within-the-input-field-1-webkit-linux.png
ADDED
Git LFS Details
|
static/tests_broken/test-app-7860-example-medium--rec-en.spec.ts
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { test, expect, chromium } from "@playwright/test";
|
2 |
+
|
3 |
+
test("test: get a phonetic accuracy evaluation from a recorded audio.", async () => {
|
4 |
+
/**
|
5 |
+
* - DE:
|
6 |
+
* - random choice (random, easy, medium, hard)
|
7 |
+
* - choice from the examples accordion
|
8 |
+
* - record a fake new audio
|
9 |
+
* - upload
|
10 |
+
* - EN:
|
11 |
+
* - random choice (random, easy, medium, hard)
|
12 |
+
*/
|
13 |
+
const testAudioEnvPath = `test_de.wav`
|
14 |
+
console.log("start");
|
15 |
+
console.log("testAudioEnvPath", testAudioEnvPath, "#");
|
16 |
+
const browser = await chromium.launch({
|
17 |
+
args: [
|
18 |
+
"--use-fake-device-for-media-stream",
|
19 |
+
"--use-fake-ui-for-media-stream",
|
20 |
+
`--use-file-for-fake-audio-capture=${testAudioEnvPath}`,
|
21 |
+
],
|
22 |
+
ignoreDefaultArgs: ['--mute-audio']
|
23 |
+
})
|
24 |
+
|
25 |
+
const context = await browser.newContext();
|
26 |
+
context.grantPermissions(["microphone"]);
|
27 |
+
const page = await browser.newPage({});
|
28 |
+
|
29 |
+
await page.goto('http://localhost:7860/');
|
30 |
+
|
31 |
+
const accordionExamples = page.getByText('Click here to expand the table examples ▼ Examples Learner Transcription');
|
32 |
+
accordionExamples.click();
|
33 |
+
const exampleMediumNth1 = page.getByRole('gridcell', { name: 'medium' }).nth(1);
|
34 |
+
await exampleMediumNth1.click();
|
35 |
+
|
36 |
+
const buttonTTS = page.getByRole('button', { name: 'Run TTS' })
|
37 |
+
await buttonTTS.click();
|
38 |
+
// todo: improve this hardcoded timeout
|
39 |
+
await page.waitForTimeout(3000);
|
40 |
+
|
41 |
+
const buttonPlay = page.getByLabel('Play', { exact: true })
|
42 |
+
await buttonPlay.click();
|
43 |
+
const waveFormTTS = page.locator('.scroll > .wrapper').first();
|
44 |
+
await waveFormTTS.waitFor({ state: 'attached' });
|
45 |
+
await waveFormTTS.waitFor({ state: 'visible' });
|
46 |
+
await expect(waveFormTTS).toBeVisible();
|
47 |
+
console.log("waveFormTTS??");
|
48 |
+
|
49 |
+
const buttonRecordTTS = page.getByRole('button', { name: 'Record', exact: true })
|
50 |
+
await buttonRecordTTS.click();
|
51 |
+
console.log("buttonRecordTTS??");
|
52 |
+
const buttonStopTTS = page.getByRole('button', { name: 'Stop', exact: true })
|
53 |
+
await buttonStopTTS.click();
|
54 |
+
console.log("buttonStopTTS??");
|
55 |
+
|
56 |
+
const buttonRecognizeSpeechAccuracy = page.getByRole('button', { name: 'Recognize speech accuracy' })
|
57 |
+
console.log("buttonRecognizeSpeechAccuracy??");
|
58 |
+
console.log("buttonRecognizeSpeechAccuracy??");
|
59 |
+
await buttonRecognizeSpeechAccuracy.click();
|
60 |
+
console.log("buttonRecognizeSpeechAccuracy=>click!");
|
61 |
+
console.log("buttonRecognizeSpeechAccuracy=>click!");
|
62 |
+
await page.waitForTimeout(300);
|
63 |
+
|
64 |
+
const errorsElements = page.getByText(/Error/);
|
65 |
+
const ErrorText = errorsElements.all()
|
66 |
+
console.log("ErrorText:", (await ErrorText).length, "#");
|
67 |
+
await expect(errorsElements).toHaveCount(0);
|
68 |
+
console.log("end");
|
69 |
+
await page.close();
|
70 |
+
});
|
static/tests_broken/test-app-7860-rec-de.spec.ts
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { test, expect, chromium } from "@playwright/test";
|
2 |
+
import { writeFile } from 'node:fs/promises'
|
3 |
+
import { Readable } from 'node:stream'
|
4 |
+
import {readFileSync} from "fs"
|
5 |
+
|
6 |
+
|
7 |
+
test("XXX - test: get a phonetic accuracy evaluation from a recorded audio.", async () => {
|
8 |
+
/**
|
9 |
+
* - DE:
|
10 |
+
* - random choice (random, easy, medium, hard)
|
11 |
+
* - choice from the examples accordion
|
12 |
+
* - record a fake new audio
|
13 |
+
* - upload
|
14 |
+
* - EN:
|
15 |
+
* - random choice (random, easy, medium, hard)
|
16 |
+
*/
|
17 |
+
|
18 |
+
// todo: upload del file test_de.wav dalla cartella corrente senza
|
19 |
+
// todo: download del file audio
|
20 |
+
// todo: test online, https://mictests.com/
|
21 |
+
const urlAudio = "https://huggingface.co/spaces/aletrn/ai-pronunciation-trainer/resolve/main/tests/events/test_de.wav"
|
22 |
+
console.log("import.meta dir", import.meta.dirname, "#");
|
23 |
+
const dirname = import.meta.dirname;
|
24 |
+
const testAudioEnvPath = `${dirname}/test_de.wav%%noloop`
|
25 |
+
console.log("urlAudio", urlAudio, "#");
|
26 |
+
console.log("testAudioEnvPath", testAudioEnvPath, "#");
|
27 |
+
console.log("testAudioEnvPath", testAudioEnvPath, "#");
|
28 |
+
|
29 |
+
const response = await fetch(urlAudio)
|
30 |
+
const stream = Readable.fromWeb(response.body)
|
31 |
+
await writeFile(testAudioEnvPath, stream)
|
32 |
+
|
33 |
+
const string_output = readFileSync(testAudioEnvPath, 'utf8')
|
34 |
+
if (string_output.length > 0) {
|
35 |
+
console.log("testAudioEnvPath", testAudioEnvPath, "#");
|
36 |
+
console.log("testAudioEnvPath", testAudioEnvPath, "#");
|
37 |
+
} else {
|
38 |
+
console.log("empty testAudioEnvPath", testAudioEnvPath, "#");
|
39 |
+
throw new Error("File is empty!");
|
40 |
+
}
|
41 |
+
|
42 |
+
// const testAudioEnvPath = `${basedirAudioFiles}/test_de.wav`
|
43 |
+
console.log("start");
|
44 |
+
console.log("testAudioEnvPath", testAudioEnvPath, "#");
|
45 |
+
const browser = await chromium.launch({
|
46 |
+
args: [
|
47 |
+
"--use-fake-device-for-media-stream",
|
48 |
+
"--use-fake-ui-for-media-stream",
|
49 |
+
`--use-file-for-fake-audio-capture=${testAudioEnvPath}`,
|
50 |
+
],
|
51 |
+
ignoreDefaultArgs: ['--mute-audio']
|
52 |
+
})
|
53 |
+
|
54 |
+
const context = await browser.newContext();
|
55 |
+
context.grantPermissions(["microphone"]);
|
56 |
+
const page = await browser.newPage({});
|
57 |
+
|
58 |
+
await page.goto('http://localhost:7860/');
|
59 |
+
|
60 |
+
const radioLanguageSelectedDE = page.getByRole('radio', { name: 'de' })
|
61 |
+
await radioLanguageSelectedDE.check();
|
62 |
+
|
63 |
+
const textboxInput = page.getByLabel('Learner Transcription')
|
64 |
+
await textboxInput.fill('Ich bin Alex, wer bist du?');
|
65 |
+
|
66 |
+
const buttonTTS = page.getByRole('button', { name: 'Run TTS' })
|
67 |
+
await buttonTTS.click();
|
68 |
+
// todo: improve this hardcoded timeout
|
69 |
+
await page.waitForTimeout(3000);
|
70 |
+
|
71 |
+
const buttonPlay = page.getByLabel('Play', { exact: true })
|
72 |
+
await buttonPlay.click();
|
73 |
+
const waveFormTTS = page.locator('.scroll > .wrapper').first();
|
74 |
+
await waveFormTTS.waitFor({ state: 'attached' });
|
75 |
+
await waveFormTTS.waitFor({ state: 'visible' });
|
76 |
+
await expect(waveFormTTS).toBeVisible();
|
77 |
+
console.log("waveFormTTS??");
|
78 |
+
|
79 |
+
const buttonRecordTTS = page.getByRole('button', { name: 'Record', exact: true })
|
80 |
+
await buttonRecordTTS.click();
|
81 |
+
console.log("buttonRecordTTS??");
|
82 |
+
const buttonStopTTS = page.getByRole('button', { name: 'Stop', exact: true })
|
83 |
+
await buttonStopTTS.click();
|
84 |
+
console.log("buttonStopTTS??");
|
85 |
+
|
86 |
+
const buttonRecognizeSpeechAccuracy = page.getByRole('button', { name: 'Recognize speech accuracy' })
|
87 |
+
console.log("buttonRecognizeSpeechAccuracy??");
|
88 |
+
console.log("buttonRecognizeSpeechAccuracy??");
|
89 |
+
await buttonRecognizeSpeechAccuracy.click();
|
90 |
+
console.log("buttonRecognizeSpeechAccuracy=>click!");
|
91 |
+
console.log("buttonRecognizeSpeechAccuracy=>click!");
|
92 |
+
await page.waitForTimeout(300);
|
93 |
+
|
94 |
+
const errorsElements = page.getByText(/Error/);
|
95 |
+
const ErrorText = errorsElements.all()
|
96 |
+
console.log("ErrorText:", (await ErrorText).length, "#");
|
97 |
+
await expect(errorsElements).toHaveCount(0);
|
98 |
+
console.log("end");
|
99 |
+
await page.close();
|
100 |
+
});
|
static/{tests → tests_broken}/test-app-7860-rec-en.spec.ts
RENAMED
@@ -1,16 +1,15 @@
|
|
1 |
import { test, expect, chromium } from "@playwright/test";
|
2 |
|
3 |
-
const basedirAudioFiles = `${__dirname}/../../tests/events`
|
4 |
-
|
5 |
test("test: get a phonetic accuracy evaluation from a recorded audio.", async () => {
|
6 |
-
const
|
7 |
-
|
8 |
console.log("testAudioEnvPath", testAudioEnvPath, "#");
|
|
|
9 |
const browser = await chromium.launch({
|
10 |
args: [
|
11 |
"--use-fake-device-for-media-stream",
|
12 |
"--use-fake-ui-for-media-stream",
|
13 |
-
|
14 |
],
|
15 |
ignoreDefaultArgs: ['--mute-audio']
|
16 |
})
|
|
|
1 |
import { test, expect, chromium } from "@playwright/test";
|
2 |
|
|
|
|
|
3 |
test("test: get a phonetic accuracy evaluation from a recorded audio.", async () => {
|
4 |
+
const dirname = import.meta.dirname;
|
5 |
+
const testAudioEnvPath = `${dirname}/../../tests/events/test_en.wav`
|
6 |
console.log("testAudioEnvPath", testAudioEnvPath, "#");
|
7 |
+
console.log("start");
|
8 |
const browser = await chromium.launch({
|
9 |
args: [
|
10 |
"--use-fake-device-for-media-stream",
|
11 |
"--use-fake-ui-for-media-stream",
|
12 |
+
`--use-file-for-fake-audio-capture=${testAudioEnvPath}`,
|
13 |
],
|
14 |
ignoreDefaultArgs: ['--mute-audio']
|
15 |
})
|
tests/events/test_de_easy.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6b0bb424b10c095c1b1cf8f8b5a1defdc461ede534a6b25077aa889007c01010
|
3 |
+
size 140444
|
tests/events/test_de_hard.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cba72130a3ce81f524b39f27604964bdcf328a65580000a0a54abfbcf4267744
|
3 |
+
size 1018844
|
tests/events/test_de_medium.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eef9842873c7d19ff5cd3656af2221287529d9185a41071a1c94577598229bef
|
3 |
+
size 391244
|
tests/events/test_en_easy.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eab6640e417f25cffb4b9693065c8dbe7b4c9e0d7e37cd45967771dd63395348
|
3 |
+
size 100844
|
tests/events/test_en_hard.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a90f7493a5e9f2977109afe7d7718c0a99dc85f6862f59779fdfd2732d3bdc5d
|
3 |
+
size 616844
|
tests/events/test_en_medium.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:192d0e60b597c7a9318291f1b22e18dc4bd0b74e9a6afea1d8a3630da9b99a54
|
3 |
+
size 319244
|