From 4b0f50a106bf1f0ffcd326120372774cd2a6e95a Mon Sep 17 00:00:00 2001 From: Delasie Torkornoo Date: Fri, 22 Nov 2024 15:54:27 -0500 Subject: [PATCH] test: now waiting for soundswallower model to load before test begins --- .../tests/studio-web/download-praat.spec.ts | 9 +++++---- .../tests/studio-web/download-srt.spec.ts | 9 +++++---- .../tests/studio-web/download-webvtt.spec.ts | 13 ++++++++----- packages/studio-web/tests/test-commands.ts | 10 +++++----- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/packages/studio-web/tests/studio-web/download-praat.spec.ts b/packages/studio-web/tests/studio-web/download-praat.spec.ts index 5af1aa17..47e31c48 100644 --- a/packages/studio-web/tests/studio-web/download-praat.spec.ts +++ b/packages/studio-web/tests/studio-web/download-praat.spec.ts @@ -19,14 +19,15 @@ test("should Download Praat ( file format)", async ({ page, browserName }) => { download2.suggestedFilename(), "should have the expected filename", ).toMatch(/readalong\.textgrid/); - /* TODO: figure out spacing issue + /* check output*/ const filePath = await download2.path(); const fileData = fs.readFileSync(filePath, { encoding: "utf8", flag: "r" }); const refFileData = fs.readFileSync( `${testAssetsPath}/ref/readalong.textgrid`, { encoding: "utf8", flag: "r" }, ); - await expect(fileData, "file content should match reference data").toEqual( - refFileData, - );*/ + await expect( + fileData.replace(/\r/g, ""), + "file content should match reference data", + ).toEqual(refFileData); }); diff --git a/packages/studio-web/tests/studio-web/download-srt.spec.ts b/packages/studio-web/tests/studio-web/download-srt.spec.ts index e51528bf..806d40f2 100644 --- a/packages/studio-web/tests/studio-web/download-srt.spec.ts +++ b/packages/studio-web/tests/studio-web/download-srt.spec.ts @@ -19,14 +19,15 @@ test("should Download SRT ( file format)", async ({ page, browserName }) => { download2.suggestedFilename(), "should have the expected filename", ).toMatch(/readalong\.srt/); - /* TODO: figure out spacing issue + /* TODO: figure out spacing issue*/ const filePath = await download2.path(); const fileData = fs.readFileSync(filePath, { encoding: "utf8", flag: "r" }); const refFileData = fs.readFileSync(`${testAssetsPath}/ref/readalong.srt`, { encoding: "utf8", flag: "r", }); - await expect(fileData, "file content should match reference data").toEqual( - refFileData, - );*/ + await expect( + fileData.replace(/\r/g, ""), + "file content should match reference data", + ).toEqual(refFileData); }); diff --git a/packages/studio-web/tests/studio-web/download-webvtt.spec.ts b/packages/studio-web/tests/studio-web/download-webvtt.spec.ts index 4816adec..87624227 100644 --- a/packages/studio-web/tests/studio-web/download-webvtt.spec.ts +++ b/packages/studio-web/tests/studio-web/download-webvtt.spec.ts @@ -1,5 +1,9 @@ import { test, expect } from "@playwright/test"; -import { testMakeAReadAlong, defaultBeforeEach } from "../test-commands"; +import { + testMakeAReadAlong, + defaultBeforeEach, + testAssetsPath, +} from "../test-commands"; import fs from "fs"; test("should Download WebVTT ( file format)", async ({ page, browserName }) => { @@ -17,8 +21,7 @@ test("should Download WebVTT ( file format)", async ({ page, browserName }) => { download2.suggestedFilename(), "should have the expected filename", ).toMatch(/readalong\.vtt/); - - /* TODO: figure out spacing issue + // check output const filePath = await download2.path(); const fileData = fs.readFileSync(filePath, { encoding: "utf8", flag: "r" }); const refFileData = fs.readFileSync(`${testAssetsPath}/ref/readalong.vtt`, { @@ -26,6 +29,6 @@ test("should Download WebVTT ( file format)", async ({ page, browserName }) => { flag: "r", }); await expect(refFileData, "file content should match reference data").toMatch( - fileData, - );*/ + fileData.replace(/\r/g, ""), + ); }); diff --git a/packages/studio-web/tests/test-commands.ts b/packages/studio-web/tests/test-commands.ts index b8716472..752f5e19 100644 --- a/packages/studio-web/tests/test-commands.ts +++ b/packages/studio-web/tests/test-commands.ts @@ -1,11 +1,9 @@ import { test, expect, Page } from "@playwright/test"; import process from "process"; -//for vscode -//export const testAssetsPath = "packages/studio-web/tests/fixtures/"; -//for nx + export const testAssetsPath = process.cwd().includes("packages") - ? "tests/fixtures/" - : "packages/studio-web/tests/fixtures/"; + ? "tests/fixtures/" // for nx + : "packages/studio-web/tests/fixtures/"; //for vscode export const testText = `This is a test. Sentence. @@ -106,7 +104,9 @@ export const defaultBeforeEach = async (page: Page, browserName: string) => { "The aligner feature is not stable for webkit", ); //await page.coverage.startJSCoverage(); + const waitForSoundSwallowerModel = page.waitForRequest(/noisedict\.txt/); await page.goto("/"); + await waitForSoundSwallowerModel; }); };