alessandro trinca tornidor commited on
Commit
0e70ac7
·
1 Parent(s): 82a2b00

test: add section about play single words in e2e test cases

Browse files
app.py CHANGED
@@ -284,7 +284,6 @@ with gr.Blocks(css=css, head=js.head_driver_tour) as gradio_app:
284
  )
285
  audio_splitted_student_recording_stt.play(
286
  fn=None,
287
- # text, language, sleepTime = null, prefix = null
288
  inputs=[text_selected_recognized_word_hidden, radio_language, num_audio_duration_hidden],
289
  outputs=audio_splitted_student_recording_stt,
290
  js=js.js_play_audio
 
284
  )
285
  audio_splitted_student_recording_stt.play(
286
  fn=None,
 
287
  inputs=[text_selected_recognized_word_hidden, radio_language, num_audio_duration_hidden],
288
  outputs=audio_splitted_student_recording_stt,
289
  js=js.js_play_audio
static/package.json CHANGED
@@ -4,7 +4,7 @@
4
  "description": "",
5
  "main": "index.js",
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
  },
9
  "type": "module",
10
  "keywords": [],
 
4
  "description": "",
5
  "main": "index.js",
6
  "scripts": {
7
+ "test": "pnpm playwright test --workers 1"
8
  },
9
  "type": "module",
10
  "keywords": [],
static/playwright.config.ts CHANGED
@@ -66,7 +66,6 @@ export default defineConfig({
66
  use: { ...devices['Desktop Safari'] },
67
  },
68
 
69
- /*
70
  // Test against mobile viewports.
71
  {
72
  name: 'MobileChrome',
@@ -79,6 +78,7 @@ export default defineConfig({
79
  use: { ...devices['iPhone 12'] },
80
  },
81
 
 
82
  // Test against branded browsers.
83
  {
84
  name: 'Microsoft Edge',
@@ -87,7 +87,7 @@ export default defineConfig({
87
  {
88
  name: 'Google Chrome',
89
  use: { ...devices['Desktop Chrome'], channel: 'chrome' },
90
- },*/
91
  ],
92
 
93
  /* Run your local dev server before starting the tests */
 
66
  use: { ...devices['Desktop Safari'] },
67
  },
68
 
 
69
  // Test against mobile viewports.
70
  {
71
  name: 'MobileChrome',
 
78
  use: { ...devices['iPhone 12'] },
79
  },
80
 
81
+ /*
82
  // Test against branded browsers.
83
  {
84
  name: 'Microsoft Edge',
 
87
  {
88
  name: 'Google Chrome',
89
  use: { ...devices['Desktop Chrome'], channel: 'chrome' },
90
+ }*/
91
  ],
92
 
93
  /* Run your local dev server before starting the tests */
static/tests/test-app-7860-example-medium0-upload-de.spec.ts CHANGED
@@ -1,6 +1,6 @@
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
 
 
1
  import { test, expect, chromium } from "@playwright/test";
2
 
3
+ test("test: German, 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
 
static/tests/test-app-7860-example-medium0-upload-en.spec.ts CHANGED
@@ -1,6 +1,6 @@
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
 
 
1
  import { test, expect, chromium } from "@playwright/test";
2
 
3
+ test("test: English, 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
 
static/tests/{test-app-7860-upload-de.spec.ts → test-app-7860-upload-de-play-single-word.spec.ts} RENAMED
@@ -44,6 +44,19 @@ test("test: get a phonetic accuracy evaluation from an uploaded audio file.", as
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
  });
 
44
  const ErrorText = errorsElements.all()
45
  console.log("ErrorText:", (await ErrorText).length, "#");
46
  await expect(errorsElements).toHaveCount(0);
47
+
48
+ const currentWordIndex = page.getByLabel(/Current word index/);
49
+ currentWordIndex.fill('1');
50
+ const audioSlittedStudentSpeechOutput = page.getByTestId('waveform-Splitted student speech output');
51
+ await expect(audioSlittedStudentSpeechOutput).toBeVisible();
52
+ const buttonPlayStudentSpeechOutput = audioSlittedStudentSpeechOutput.getByLabel('Play', { exact: true })
53
+ // before playing the audio, the color of the button should be gray
54
+ await expect(buttonPlayStudentSpeechOutput).toHaveCSS('color', 'rgb(187, 187, 194)');
55
+ await buttonPlayStudentSpeechOutput.click();
56
+ await page.waitForTimeout(10);
57
+ // after playing the audio, the color of the button should be orange, but only for few milliseconds: don't wait too long!
58
+ await expect(buttonPlayStudentSpeechOutput).toHaveCSS('color', 'rgb(249, 115, 22)');
59
+
60
  console.log("end");
61
  await page.close();
62
  });
static/tests/{test-app-7860-upload-en.spec.ts → test-app-7860-upload-en-play-single-word.spec.ts} RENAMED
@@ -1,6 +1,6 @@
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
 
@@ -15,7 +15,7 @@ test("test: get a phonetic accuracy evaluation from an uploaded audio file.", as
15
  context.grantPermissions(["microphone"]);
16
  const page = await browser.newPage({});
17
 
18
- await page.goto('http://localhost:7860/');
19
  await page.getByRole('button', { name: 'TTS backend', exact: true }).click();
20
  const buttonPlay = page.getByLabel('Play', { exact: true })
21
  await buttonPlay.click();
@@ -37,6 +37,19 @@ test("test: get a phonetic accuracy evaluation from an uploaded audio file.", as
37
  const ErrorText = errorsElements.all()
38
  console.log("ErrorText:", (await ErrorText).length, "#");
39
  await expect(errorsElements).toHaveCount(0);
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  console.log("end");
41
  await page.close();
42
  });
 
1
  import { test, expect, chromium } from "@playwright/test";
2
 
3
+ test("test: English, 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
 
 
15
  context.grantPermissions(["microphone"]);
16
  const page = await browser.newPage({});
17
 
18
+ await page.goto('http://localhost:7860/', { waitUntil: 'commit' });
19
  await page.getByRole('button', { name: 'TTS backend', exact: true }).click();
20
  const buttonPlay = page.getByLabel('Play', { exact: true })
21
  await buttonPlay.click();
 
37
  const ErrorText = errorsElements.all()
38
  console.log("ErrorText:", (await ErrorText).length, "#");
39
  await expect(errorsElements).toHaveCount(0);
40
+
41
+ const currentWordIndex = page.getByLabel(/Current word index/);
42
+ currentWordIndex.fill('2');
43
+ await page.waitForTimeout(200);
44
+ const audioSlittedStudentSpeechOutput = page.getByTestId('waveform-Splitted student speech output');
45
+ await expect(audioSlittedStudentSpeechOutput).toBeVisible();
46
+ const buttonPlayStudentSpeechOutput = audioSlittedStudentSpeechOutput.getByLabel('Play', { exact: true })
47
+ // before playing the audio, the color of the button should be gray
48
+ await expect(buttonPlayStudentSpeechOutput).toHaveCSS('color', 'rgb(187, 187, 194)');
49
+ await buttonPlayStudentSpeechOutput.click();
50
+ await page.waitForTimeout(10);
51
+ // after playing the audio, the color of the button should be orange, but only for few milliseconds: don't wait too long!
52
+ await expect(buttonPlayStudentSpeechOutput).toHaveCSS('color', 'rgb(249, 115, 22)');
53
  console.log("end");
54
  await page.close();
55
  });
static/tests/test-webApp-3000.spec.ts-snapshots/test-get-a-custom-sample-writing-within-the-input-field-1-MobileChrome-linux.png ADDED

Git LFS Details

  • SHA256: ed6c19cc46406289ccbc1fd485d5551b0b0d5823b42ea1d315a94dc20e4f0820
  • Pointer size: 130 Bytes
  • Size of remote file: 46.3 kB
static/tests/test-webApp-3000.spec.ts-snapshots/test-get-a-custom-sample-writing-within-the-input-field-1-MobileSafari-linux.png ADDED

Git LFS Details

  • SHA256: 4c54f4d0e1bf5e5af38b91cb44753048cade1a5408d2d51cebe732c72c816392
  • Pointer size: 130 Bytes
  • Size of remote file: 45.5 kB