|
| 1 | +import { test, expect } from "@playwright/test"; |
| 2 | +import { testAssetsPath, disablePlausible } from "../test-commands"; |
| 3 | +test.describe.configure({ mode: "parallel" }); |
| 4 | +test("should check editor UI", async ({ page, isMobile }) => { |
| 5 | + await page.goto("/", { waitUntil: "load" }); |
| 6 | + |
| 7 | + await disablePlausible(page); |
| 8 | + if (isMobile) { |
| 9 | + await page.getByTestId("menu-toggle").click(); |
| 10 | + } |
| 11 | + await page.getByRole("button", { name: /Editor/ }).click(); |
| 12 | + await expect( |
| 13 | + page.getByRole("button", { name: "Take the tour!" }), |
| 14 | + "Tour button is visible", |
| 15 | + ).toBeVisible(); |
| 16 | + await expect( |
| 17 | + page.locator("#updateRAS"), |
| 18 | + "Choose file is visible", |
| 19 | + ).toBeVisible(); |
| 20 | + let fileChooserPromise = page.waitForEvent("filechooser"); |
| 21 | + await page.locator("#updateRAS").click(); |
| 22 | + let fileChooser = await fileChooserPromise; |
| 23 | + fileChooser.setFiles(testAssetsPath + "sentence-paragr.html"); |
| 24 | + //check audio bar |
| 25 | + /** |
| 26 | + * We are using css classes instead of test-id because this is an external plugin |
| 27 | + * failure here means the plugin version has changed we should test impact on our app |
| 28 | + */ |
| 29 | + |
| 30 | + await expect( |
| 31 | + page.locator("#audioToolbar"), |
| 32 | + "audio bar should exist", |
| 33 | + ).toHaveCount(1); |
| 34 | + await expect( |
| 35 | + page.locator("segment.wavesurfer-segment"), |
| 36 | + "should seven audio segments", |
| 37 | + ).toHaveCount(7); |
| 38 | + await expect( |
| 39 | + page.locator("segment.wavesurfer-segment:first-of-type > .segment-content"), |
| 40 | + "audio segments text should be editable", |
| 41 | + ).toHaveAttribute("contenteditable", "true"); |
| 42 | + await expect( |
| 43 | + page.locator( |
| 44 | + "segment.wavesurfer-segment:first-of-type > .wavesurfer-handle", |
| 45 | + ), |
| 46 | + "audio segments boundaries should exist", |
| 47 | + ).toHaveCount(2); |
| 48 | + |
| 49 | + //check readalong |
| 50 | + await expect( |
| 51 | + page.locator("#readalongContainer"), |
| 52 | + "should check that readalong is loading", |
| 53 | + ).not.toBeEmpty(); |
| 54 | + const header = page.locator( |
| 55 | + "#readalongContainer span[slot=read-along-header]", |
| 56 | + ); |
| 57 | + await expect(header, "should have correct title").toContainText( |
| 58 | + "Sentence Paragraph Page", |
| 59 | + ); |
| 60 | + await expect(header, "should have editable title").toHaveAttribute( |
| 61 | + "contenteditable", |
| 62 | + "true", |
| 63 | + ); |
| 64 | + const subheader = page.locator( |
| 65 | + "#readalongContainer span[slot=read-along-subheader]", |
| 66 | + ); |
| 67 | + await expect(subheader, "should have correct subtitle").toContainText( |
| 68 | + "by me", |
| 69 | + ); |
| 70 | + await expect(subheader, "should have editable subtitle").toHaveAttribute( |
| 71 | + "contenteditable", |
| 72 | + "true", |
| 73 | + ); |
| 74 | + await page.locator("#t0b0d0p1s0").scrollIntoViewIfNeeded(); |
| 75 | + await expect( |
| 76 | + page.locator("#t0b0d0p0s0").getByLabel("Remove translation"), |
| 77 | + "should have translation for first paragraph first sentence", |
| 78 | + ).toBeVisible(); |
| 79 | + await expect( |
| 80 | + page.locator("#t0b0d0p0s1").getByRole("button", { name: "add" }), |
| 81 | + "should not have translation for first paragraph second sentence", |
| 82 | + ).toBeVisible(); |
| 83 | + await expect( |
| 84 | + page.locator("#t0b0d0p1s0").getByLabel("Remove translation"), |
| 85 | + "should have translation for second paragraph ", |
| 86 | + ).toBeVisible(); |
| 87 | + await expect( |
| 88 | + page.locator("#fileElem--t0b0d0"), |
| 89 | + "should not have image on first page", |
| 90 | + ).toHaveCount(1); |
| 91 | + await expect( |
| 92 | + page.locator("#t0b0d1 img"), |
| 93 | + "should have image on second page", |
| 94 | + ).toHaveCount(1); |
| 95 | +}); |
0 commit comments