From fcda45dea57e61fded05c042e813122063005edf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 1 Feb 2022 18:12:46 +1100 Subject: [PATCH] tests(core/seo): fix racy tests (#3999) --- tests/spec/core/seo-spec.js | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/tests/spec/core/seo-spec.js b/tests/spec/core/seo-spec.js index 26be240468..360b4878c2 100644 --- a/tests/spec/core/seo-spec.js +++ b/tests/spec/core/seo-spec.js @@ -16,15 +16,8 @@ describe("Core — Seo", () => { body: makeDefaultBody(), }; const doc = await makeRSDoc(ops); - await doc.respec.ready; - await new Promise(resolve => { - const check = () => { - const hasMetaDesc = doc.querySelectorAll("meta[name=description]"); - expect(hasMetaDesc).toHaveSize(0); - resolve(); - }; - window.requestIdleCallback ? window.requestIdleCallback(check) : check(); - }); + const hasMetaDesc = doc.querySelectorAll("meta[name=description]"); + expect(hasMetaDesc).toHaveSize(0); }); it("inserts a meta element for the description after processing", async () => { @@ -37,25 +30,9 @@ describe("Core — Seo", () => { body: makeDefaultBody(), }; const doc = await makeRSDoc(ops); - await doc.respec.ready; - await new Promise(resolve => { - const check = () => { - const hasMetaDesc = doc.querySelectorAll( - "meta[name=description]" - ).length; - // Firefox is buggy, short circuit - if (navigator.userAgent.includes("Firefox") && !hasMetaDesc) { - expect(true).toBe(true); - return; - } - expect(hasMetaDesc).toBe(1); - const meta = doc.head.querySelector("meta[name=description]"); - expect(meta.content).toBe("Pass"); - resolve(); - }; - window.requestIdleCallback - ? doc.defaultView.requestIdleCallback(check) - : check(); - }); + const hasMetaDesc = doc.querySelectorAll("meta[name=description]").length; + expect(hasMetaDesc).toBe(1); + const meta = doc.head.querySelector("meta[name=description]"); + expect(meta.content).toBe("Pass"); }); });