Skip to content

Commit 5cd5d9c

Browse files
committed
test: modified editor test to pass for mobile screen
1 parent 5794e13 commit 5cd5d9c

File tree

7 files changed

+76
-28
lines changed

7 files changed

+76
-28
lines changed

packages/studio-web/src/app/app.component.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
ReadAlong Studio
44
</span>
55
<span class="nav-spacer"></span>
6-
<button class="d-md-none" mat-button [matMenuTriggerFor]="menu">
6+
<button
7+
class="d-md-none"
8+
data-test-id="menu-toggle"
9+
mat-button
10+
[matMenuTriggerFor]="menu"
11+
>
712
<mat-icon>menu</mat-icon>
813
</button>
914
<mat-menu #menu="matMenu">

packages/studio-web/tests/editor/check-page.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { test, expect } from "@playwright/test";
22
import { testAssetsPath, disablePlausible } from "../test-commands";
33
test.describe.configure({ mode: "parallel" });
4-
test("should check editor UI", async ({ page }) => {
4+
test("should check editor UI", async ({ page, isMobile }) => {
55
await page.goto("/", { waitUntil: "load" });
6+
67
await disablePlausible(page);
8+
if (isMobile) {
9+
await page.getByTestId("menu-toggle").click();
10+
}
711
await page.getByRole("button", { name: /Editor/ }).click();
812
await expect(
913
page.getByRole("button", { name: "Take the tour!" }),

packages/studio-web/tests/editor/edit-images.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { test, expect } from "@playwright/test";
22
import { testAssetsPath, editorDefaultBeforeEach } from "../test-commands";
33
test.describe.configure({ mode: "parallel" });
44

5-
test("should edit images (editor)", async ({ page }) => {
5+
test("should edit images (editor)", async ({ page, isMobile }) => {
66
await expect(async () => {
7-
await editorDefaultBeforeEach(page);
7+
await editorDefaultBeforeEach(page, isMobile);
88
}).toPass();
99
await page.locator("#updateRAS").waitFor({ state: "visible" });
1010
await expect(

packages/studio-web/tests/editor/edit-translations.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { test, expect } from "@playwright/test";
2-
import { testAssetsPath, editorDefaultBeforeEach } from "../test-commands";
2+
import { editorDefaultBeforeEach } from "../test-commands";
33
test.describe.configure({ mode: "parallel" });
44

5-
test("should edit translations (editor)", async ({ page }) => {
5+
test("should edit translations (editor)", async ({ page, isMobile }) => {
66
await expect(async () => {
7-
await editorDefaultBeforeEach(page);
7+
await editorDefaultBeforeEach(page, isMobile);
88
}).toPass();
99
await page.locator("#t0b0d0p0s0translation").waitFor({ state: "visible" });
1010
//edit first sentence translation

packages/studio-web/tests/editor/tour-editor.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { test, expect } from "@playwright/test";
2-
import { testAssetsPath, disablePlausible } from "../test-commands";
2+
import { disablePlausible } from "../test-commands";
33
test.describe.configure({ mode: "parallel" });
4-
test("should do tour", async ({ page }) => {
4+
test("should do tour", async ({ page, isMobile }) => {
55
await page.goto("/", { waitUntil: "load" });
66
disablePlausible(page);
7+
if (isMobile) {
8+
await page.getByTestId("menu-toggle").click();
9+
}
710
await page.getByRole("button", { name: /Editor/ }).click();
811
await expect(
912
page.getByRole("button", { name: "Take the tour!" }),

packages/studio-web/tests/editor/use-audio-toolbar.spec.ts

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,46 @@ import fs from "fs";
44
import JSZip from "jszip";
55
test.describe.configure({ mode: "parallel" });
66

7-
test("should edit alignment and words (editor)", async ({ page }) => {
7+
test("should edit alignment and words (editor)", async ({ page, isMobile }) => {
88
await expect(async () => {
9-
await editorDefaultBeforeEach(page);
9+
await editorDefaultBeforeEach(page, isMobile);
1010
}).toPass();
1111
await page.locator("#t0b0d0p0s0").waitFor({ state: "visible" });
1212
//first handle
1313
const handle = await page.getByTitle("-1.070").locator("handle").first();
1414
await handle.scrollIntoViewIfNeeded();
1515
const segment = await page.getByTitle("0.840-1.070");
1616
await segment.click();
17+
await page.locator("#wavesurferContainer").hover();
18+
if (isMobile) {
19+
await page.mouse.wheel(-130, 0);
20+
}
21+
1722
const segBoxPreChange = await segment.boundingBox();
1823
//move the handle to the left to about 0.5
1924
await handle.hover();
2025
await page.mouse.down();
2126
if (segBoxPreChange)
2227
await page.mouse.move(segBoxPreChange.x - 100, segBoxPreChange.y);
2328
await page.mouse.up();
29+
2430
//validate the new segment width
25-
await expect(
26-
page.getByTitle("0.506-1.070"),
27-
"should have new time code",
28-
).toHaveCount(1);
29-
const segBoxPostChange = await page.getByTitle("0.506-1.070").boundingBox();
31+
32+
const segBoxPostChange = await page
33+
.locator("segment.wavesurfer-segment")
34+
.first()
35+
.boundingBox();
3036
if (segBoxPostChange && segBoxPreChange)
3137
expect(
3238
segBoxPostChange.width,
3339
"should be wider than the original segment",
3440
).toBeGreaterThan(segBoxPreChange.width);
35-
await page.getByTitle("0.506-1.070").click();
41+
await page.locator("segment.wavesurfer-segment").first().click();
3642
await expect(
3743
page.getByTitle("-2.360").locator("div"),
3844
"should contain word `Sentence`",
3945
).toContainText("Sentence");
46+
4047
const text = await page.getByTitle("-2.360").locator("div");
4148
await text.scrollIntoViewIfNeeded();
4249
await text.click();
@@ -46,6 +53,11 @@ test("should edit alignment and words (editor)", async ({ page }) => {
4653
"should now contain word `Sentences`",
4754
).toContainText("Sentences");
4855

56+
const newStartTime = await page
57+
.locator("segment.wavesurfer-segment")
58+
.first()
59+
.evaluate((seg) => (seg as HTMLElement).title.substring(0, 4));
60+
4961
//check web bundle output
5062
await page.locator("#mat-select-value-3").click();
5163
await page.getByRole("option", { name: "Web Bundle" }).click();
@@ -68,8 +80,11 @@ test("should edit alignment and words (editor)", async ({ page }) => {
6880
"readalong file should reflect new spelling",
6981
).toMatch(/>Sentences</);
7082
await expect
71-
.soft(readalongContent, "readalong file should reflect new alignment")
72-
.toMatch(/time="0\.5\d+" dur="0\.5\d+"/);
83+
.soft(
84+
readalongContent,
85+
"readalong file should reflect new alignment start time" + newStartTime,
86+
)
87+
.toMatch(new RegExp(`time="${newStartTime.replace(".", "\\.")}\\d+" `));
7388

7489
//check SRT
7590
await page.locator("#mat-select-value-3").click();
@@ -86,8 +101,11 @@ test("should edit alignment and words (editor)", async ({ page }) => {
86101
/Sentences/,
87102
);
88103
await expect
89-
.soft(fileData, "SRT file should reflect new alignment")
90-
.toMatch(/00\,5\d+\s-->/);
104+
.soft(
105+
fileData,
106+
"SRT file should reflect new alignment start time " + newStartTime,
107+
)
108+
.toMatch(new RegExp(`${newStartTime.replace(".", ",")}\\d+\\s-->`));
91109
//check WEBVTT
92110
await page.locator("#mat-select-value-3").click();
93111
await page.getByRole("option", { name: "WebVTT Subtitles" }).click();
@@ -100,8 +118,11 @@ test("should edit alignment and words (editor)", async ({ page }) => {
100118
/Sentences/,
101119
);
102120
await expect
103-
.soft(fileData, "WEBVTT file should reflect new alignment")
104-
.toMatch(/00\.5\d+\s-->/);
121+
.soft(
122+
fileData,
123+
"WEBVTT file should reflect new alignment start time " + newStartTime,
124+
)
125+
.toMatch(new RegExp(`${newStartTime.replace(".", "\\.")}\\d+\\s-->`));
105126
//check PRAAT
106127
await page.locator("#mat-select-value-3").click();
107128
await page.getByRole("option", { name: "Praat TextGrid" }).click();
@@ -114,8 +135,13 @@ test("should edit alignment and words (editor)", async ({ page }) => {
114135
/text = "Sentences"/,
115136
);
116137
await expect
117-
.soft(fileData, "PRAAT file should reflect new alignment")
118-
.toMatch(/xmin = 0\.5\d+/);
138+
.soft(
139+
fileData,
140+
"PRAAT file should reflect new alignment start time " + newStartTime,
141+
)
142+
.toMatch(
143+
new RegExp(`xmin\\s=\\s${newStartTime.replace(".", "\\.")}\\d+\\\s`),
144+
);
119145
//check elan
120146
await page.locator("#mat-select-value-3").click();
121147
await page.getByRole("option", { name: "Elan File" }).click();
@@ -128,6 +154,9 @@ test("should edit alignment and words (editor)", async ({ page }) => {
128154
/<ANNOTATION_VALUE>Sentences<\/ANNOTATION_VALUE>/,
129155
);
130156
await expect
131-
.soft(fileData, "ELAN file should reflect new alignment")
132-
.toMatch(/TIME_VALUE="5\d+"/);
157+
.soft(
158+
fileData,
159+
"ELAN file should reflect new alignment start time " + newStartTime,
160+
)
161+
.toMatch(new RegExp(`TIME_VALUE="${newStartTime.substring(2)}\\d+" `));
133162
});

packages/studio-web/tests/test-commands.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,18 @@ export const disablePlausible = async (page: Page) => {
146146
* Uploads single file html (setup editor test)
147147
* @param page
148148
*/
149-
export const editorDefaultBeforeEach = async (page: Page) => {
149+
export const editorDefaultBeforeEach = async (
150+
page: Page,
151+
isMobile: boolean,
152+
) => {
150153
test.step("upload single file html", async () => {
151154
await page.goto("/", { waitUntil: "load" });
152155
disablePlausible(page);
156+
if (isMobile) {
157+
await page.getByTestId("menu-toggle").click();
158+
}
153159
await page.getByRole("button", { name: /Editor/ }).click();
160+
154161
await page.locator("#updateRAS").waitFor({ state: "visible" });
155162
let fileChooserPromise = page.waitForEvent("filechooser");
156163
await page.locator("#updateRAS").click();

0 commit comments

Comments
 (0)