This repository has been archived by the owner on Feb 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
/
page.test.js
68 lines (51 loc) · 2.65 KB
/
page.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* eslint-disable no-undef */
jest.setTimeout(10000);
const TIMEOUT = { timeout: 3000 };
describe('Input methods', () => {
beforeEach(async () => {
await page.goto('http://localhost:5000');
});
it('Sample audio', async () => {
await page.content();
// Select English
await (await page.waitForXPath('//*[@id="language-model-dropdown"]', TIMEOUT)).click();
await (await page.waitForXPath('//*[text()="US English (8khz Narrowband)"]', TIMEOUT)).click();
// Add custom keywords.
const TEST_KEYWORDS = ', course, I';
const keywords = await page.waitForXPath('//*[@class="cds--text-area cds--text-area--light"]', TIMEOUT);
await keywords.type(TEST_KEYWORDS);
const keywordsContent = await page.evaluate(el => el.textContent, keywords);
expect(keywordsContent).toContain(TEST_KEYWORDS)
// Choose to detect speakers.
await (await page.waitForXPath('//*[@class="cds--toggle__switch"]', TIMEOUT)).click();
// Play sample audio.
await (await page.waitForXPath('//*[text()="Play audio sample"]', TIMEOUT)).click();
// Wait for the audio to play for a bit.
await page.waitForTimeout(5000);
// Check transcript (CI checks box exists. Missing creds to check content.)
expect(await page.waitForXPath('//*[@class="transcript-box"]', TIMEOUT)).toBeTruthy();
/* With proper creds, this logs content and tests first words...
const transcriptElement = await page.waitForXPath('//*[@class="transcript-box"]/div/span', TIMEOUT);
const transcript = await page.evaluate(el => el.textContent, transcriptElement);
console.log("TRANSCRIPT: ", transcript);
expect(transcript).toContain("Thank you");
*/
});
it('File upload', async () => {
await page.content();
// Select English
await (await page.waitForXPath('//*[@id="language-model-dropdown"]', TIMEOUT)).click();
await (await page.waitForXPath('//*[text()="US English (16khz Broadband)"]', TIMEOUT)).click();
// Upload file.
await (await page.waitForXPath('//*[@id="id1"]', TIMEOUT)).uploadFile('public/audio/en-US_Broadband-sample.wav');
// Wait for the audio to play for a bit.
await page.waitForTimeout(5000);
// Check transcript (CI checks box exists. Missing creds to check content.)
expect(await page.waitForXPath('//*[@class="transcript-box"]', TIMEOUT)).toBeTruthy();
/* With proper creds, this logs content and tests first words...
const transcript = await page.evaluate(el => el.textContent, await page.waitForXPath('//*[@class="transcript-box"]/div/span', TIMEOUT));
console.log("TRANSCRIPT: ", transcript);
expect(transcript).toContain("So thank you very much for coming");
*/
});
});