From 5fb913200e3180d37025dc68a3403a23699cefd4 Mon Sep 17 00:00:00 2001 From: Florian Dieminger Date: Tue, 17 Dec 2024 16:55:20 +0100 Subject: [PATCH] fixes --- .github/workflows/performance.yml | 3 +- .github/workflows/testing.yml | 2 +- bins/build.mjs | 2 +- bins/tool.mjs | 2 +- scripts/testing.sh | 2 +- testing/README.md | 2 +- testing/scripts/functional-test.sh | 2 +- testing/tests/developing.spec.ts | 1 - testing/tests/index.test.ts | 513 +---------------------------- 9 files changed, 11 insertions(+), 518 deletions(-) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index cb372c4e7d39..c159b9fbf79d 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -53,8 +53,7 @@ jobs: BUILD_GOOGLE_ANALYTICS_MEASUREMENT_ID: G-XXXXXXXX run: | yarn build:prepare - # BUILD_FOLDERSEARCH=mdn/kitchensink yarn build:docs - BUILD_FOLDERSEARCH=web/javascript/reference/global_objects/array/foreach yarn build:docs + yarn build -f BUILD_FOLDERSEARCH=$CONTENT_ROOT/en-us/web/javascript/reference/global_objects/array/foreach -f $CONTENT_ROOT/en-us/mdn/kitchensink yarn render:html - name: Serve and lhci diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 0c6aa9395e3a..a9a1b4e55126 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -90,7 +90,7 @@ jobs: ENV_FILE: .env.testing run: | yarn build:prepare - yarn build:docs + yarn build yarn render:html yarn start:static-server > /tmp/stdout.log 2> /tmp/stderr.log & diff --git a/bins/build.mjs b/bins/build.mjs index 089aa45e8e1f..32330c91147d 100644 --- a/bins/build.mjs +++ b/bins/build.mjs @@ -13,4 +13,4 @@ config({ process.env.BUILD_OUT_ROOT = process.env.BUILD_OUT_ROOT || BUILD_OUT_ROOT; -spawn(rariBin, ["build"], { stdio: "inherit" }); +spawn(rariBin, ["build", ...process.argv.slice(2)], { stdio: "inherit" }); diff --git a/bins/tool.mjs b/bins/tool.mjs index f12103c2a68e..54d5d8ebd9c6 100644 --- a/bins/tool.mjs +++ b/bins/tool.mjs @@ -14,4 +14,4 @@ config({ process.env.BUILD_OUT_ROOT = process.env.BUILD_OUT_ROOT || BUILD_OUT_ROOT; -spawn(rariBin, ["content"], { stdio: "inherit" }); +spawn(rariBin, ["content", ...process.argv.slice(2)], { stdio: "inherit" }); diff --git a/scripts/testing.sh b/scripts/testing.sh index 52fea8b145b3..23d72e30358d 100755 --- a/scripts/testing.sh +++ b/scripts/testing.sh @@ -23,7 +23,7 @@ echo "----------------------" export ENV_FILE=".env.testing" yarn build:prepare -yarn build:docs +yarn build yarn render:html nohup yarn start:static-server > testing.log 2>&1 & diff --git a/testing/README.md b/testing/README.md index 6eac1b99c2ce..f302a7f8a911 100644 --- a/testing/README.md +++ b/testing/README.md @@ -21,7 +21,7 @@ To run these tests, first run: ```sh export ENV_FILE=.env.testing yarn build:prepare -yarn build:docs +yarn build yarn render:html yarn start:static-server ``` diff --git a/testing/scripts/functional-test.sh b/testing/scripts/functional-test.sh index 71b35b386e15..44a9496d4f9d 100755 --- a/testing/scripts/functional-test.sh +++ b/testing/scripts/functional-test.sh @@ -4,7 +4,7 @@ set -e export ENV_FILE=.env.testing yarn build:prepare -yarn build:docs +yarn build yarn render:html yarn test:testing $@ diff --git a/testing/tests/developing.spec.ts b/testing/tests/developing.spec.ts index aa289d49b6c7..f3a97e0cf70e 100644 --- a/testing/tests/developing.spec.ts +++ b/testing/tests/developing.spec.ts @@ -75,7 +75,6 @@ test.describe("Testing the kitchensink page", () => { ).json(); expect(doc.title).toBe("The MDN Content Kitchensink"); - expect(doc.flaws).toEqual({}); }); // XXX Do more advanced tasks that test the server and document "CRUD operations" diff --git a/testing/tests/index.test.ts b/testing/tests/index.test.ts index b2e997e53597..7477365dd400 100644 --- a/testing/tests/index.test.ts +++ b/testing/tests/index.test.ts @@ -78,18 +78,6 @@ test("content built foo page", () => { expect(new Date(doc.modified)).toBeTruthy(); expect(doc.source).toBeTruthy(); - expect(doc.flaws.macros).toHaveLength(1); - expect(doc.flaws.macros[0]).toMatchObject({ - column: 4, - errorStack: expect.stringContaining("pages is not iterable"), - filepath: expect.stringContaining( - "testing/content/files/en-us/web/foo/index.html" - ), - line: 8, - macroName: "HTMLSidebar", - name: "MacroExecutionError", - }); - const htmlFile = path.join(builtFolder, "index.html"); const html = fs.readFileSync(htmlFile, "utf-8"); const $ = cheerio.load(html); @@ -222,8 +210,6 @@ test("content built zh-CN page for hreflang tag and copying image testing", () = const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { doc: Doc; }; - expect(Object.keys(doc.flaws)).toHaveLength(1); - expect(doc.flaws.translation_differences).toHaveLength(1); expect(doc.title).toBe(": 测试网页"); expect(doc.isTranslated).toBe(true); expect(doc.other_translations[0].locale).toBe("en-US"); @@ -258,8 +244,6 @@ test("content built zh-TW page with en-US fallback image", () => { const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { doc: Doc; }; - expect(Object.keys(doc.flaws)).toHaveLength(1); - expect(doc.flaws.translation_differences).toHaveLength(1); expect(doc.title).toBe(": 測試網頁"); expect(doc.isTranslated).toBe(true); expect(doc.other_translations[0].locale).toBe("en-US"); @@ -286,44 +270,6 @@ test("content built zh-TW page with en-US fallback image", () => { expect(fs.existsSync(imageFile)).toBeTruthy(); }); -test("content built French Embeddable page", () => { - const builtFolder = path.join(buildRoot, "fr", "docs", "web", "embeddable"); - const jsonFile = path.join(builtFolder, "index.json"); - const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { - doc: Doc; - }; - expect(doc.flaws.translation_differences).toHaveLength(1); - const flaw = doc.flaws.translation_differences[0]; - expect(flaw.explanation).toBe( - "Differences in the important macros (0 in common of 5 possible)" - ); - expect(flaw.fixable).toBeFalsy(); - expect(flaw.suggestion).toBeFalsy(); - expect(flaw.difference.type).toBe("macro"); -}); - -test("wrong xref macro errors", () => { - const builtFolder = path.join( - buildRoot, - "en-us", - "docs", - "web", - "wrong_xref_macro" - ); - const jsonFile = path.join(builtFolder, "index.json"); - const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { - doc: Doc; - }; - // Expect the first flaw to be that we're using the wrong xref macro. - expect(doc.flaws.macros[0].name).toBe("MacroBrokenLinkError"); - expect(doc.flaws.macros[0].macroSource).toBe('{{DOMxRef("Promise")}}'); - expect(doc.flaws.macros[0].line).toBe(7); - expect(doc.flaws.macros[0].column).toBe(51); - expect(doc.flaws.macros[0].sourceContext).toEqual( - expect.stringContaining('Web API: {{DOMxRef("Promise")}}') - ); -}); - test("summary extracted correctly by span class", () => { const builtFolder = path.join( buildRoot, @@ -461,69 +407,6 @@ test("content built bar page", () => { // expect(doc.popularity).toBe(0.51); // expect(doc.modified).toBeTruthy(); expect(doc.source).toBeTruthy(); - expect(doc.flaws.macros).toHaveLength(10); - expect(doc.flaws.macros[0].name).toBe("MacroBrokenLinkError"); - expect(doc.flaws.macros[0].macroSource).toBe('{{CSSxRef("bigfoot")}}'); - expect(doc.flaws.macros[0].line).toBe(9); - expect(doc.flaws.macros[0].column).toBe(6); - expect(doc.flaws.macros[1].name).toBe("MacroRedirectedLinkError"); - expect(doc.flaws.macros[1].macroSource).toBe('{{CSSxRef("dumber")}}'); - expect(doc.flaws.macros[1].line).toBe(10); - expect(doc.flaws.macros[1].column).toBe(6); - expect(doc.flaws.macros[1].redirectInfo).toBeDefined(); - expect(doc.flaws.macros[1].redirectInfo.current).toBe("dumber"); - expect(doc.flaws.macros[1].redirectInfo.suggested).toBe("number"); - expect(doc.flaws.macros[2].name).toBe("MacroBrokenLinkError"); - expect(doc.flaws.macros[2].macroSource).toBe('{{DOMxRef("bigfoot")}}'); - expect(doc.flaws.macros[2].line).toBe(12); - expect(doc.flaws.macros[2].column).toBe(6); - expect(doc.flaws.macros[3].name).toBe("MacroRedirectedLinkError"); - expect(doc.flaws.macros[3].macroSource).toBe('{{DOMxRef("Bob")}}'); - expect(doc.flaws.macros[3].line).toBe(13); - expect(doc.flaws.macros[3].column).toBe(6); - expect(doc.flaws.macros[3].redirectInfo).toBeDefined(); - expect(doc.flaws.macros[3].redirectInfo.current).toBe("Bob"); - expect(doc.flaws.macros[3].redirectInfo.suggested).toBe("Blob"); - expect(doc.flaws.macros[4].name).toBe("MacroBrokenLinkError"); - expect(doc.flaws.macros[4].macroSource).toBe('{{jsxref("bigfoot")}}'); - expect(doc.flaws.macros[4].line).toBe(15); - expect(doc.flaws.macros[4].column).toBe(6); - expect(doc.flaws.macros[5].name).toBe("MacroRedirectedLinkError"); - expect(doc.flaws.macros[5].macroSource).toBe('{{jsxref("Stern_mode")}}'); - expect(doc.flaws.macros[5].line).toBe(16); - expect(doc.flaws.macros[5].column).toBe(6); - expect(doc.flaws.macros[5].redirectInfo).toBeDefined(); - expect(doc.flaws.macros[5].redirectInfo.current).toBe("Stern_mode"); - expect(doc.flaws.macros[5].redirectInfo.suggested).toBe("Strict_mode"); - expect(doc.flaws.macros[6].name).toBe("MacroRedirectedLinkError"); - expect(doc.flaws.macros[6].macroSource).toBe('{{jsxref("Flag")}}'); - expect(doc.flaws.macros[6].line).toBe(18); - expect(doc.flaws.macros[6].column).toBe(6); - expect(doc.flaws.macros[6].redirectInfo).toBeDefined(); - expect(doc.flaws.macros[6].redirectInfo.current).toBe("Flag"); - expect(doc.flaws.macros[6].redirectInfo.suggested).toBe("Boolean"); - expect(doc.flaws.macros[7].name).toBe("MacroRedirectedLinkError"); - expect(doc.flaws.macros[7].macroSource).toBe("{{ jsxref('Flag') }}"); - expect(doc.flaws.macros[7].line).toBe(19); - expect(doc.flaws.macros[7].column).toBe(6); - expect(doc.flaws.macros[7].redirectInfo).toBeDefined(); - expect(doc.flaws.macros[7].redirectInfo.current).toBe("Flag"); - expect(doc.flaws.macros[7].redirectInfo.suggested).toBe("Boolean"); - expect(doc.flaws.macros[8].name).toBe("MacroRedirectedLinkError"); - expect(doc.flaws.macros[8].macroSource).toBe('{{JSXref("Flag")}}'); - expect(doc.flaws.macros[8].line).toBe(20); - expect(doc.flaws.macros[8].column).toBe(6); - expect(doc.flaws.macros[8].redirectInfo).toBeDefined(); - expect(doc.flaws.macros[8].redirectInfo.current).toBe("Flag"); - expect(doc.flaws.macros[8].redirectInfo.suggested).toBe("Boolean"); - expect(doc.flaws.macros[9].name).toBe("MacroRedirectedLinkError"); - expect(doc.flaws.macros[9].macroSource).toBe('{{JSXref("Flag")}}'); - expect(doc.flaws.macros[9].line).toBe(21); - expect(doc.flaws.macros[9].column).toBe(6); - expect(doc.flaws.macros[9].redirectInfo).toBeDefined(); - expect(doc.flaws.macros[9].redirectInfo.current).toBe("Flag"); - expect(doc.flaws.macros[9].redirectInfo.suggested).toBe("Boolean"); - const htmlFile = path.join(builtFolder, "index.html"); expect(fs.existsSync(htmlFile)).toBeTruthy(); const html = fs.readFileSync(htmlFile, "utf-8"); @@ -885,30 +768,6 @@ test("broken anchor links flaws", () => { }); }); -test("check built flaws for /en-us/learn/css/css_layout/introduction/grid page", () => { - expect(fs.existsSync(buildRoot)).toBeTruthy(); - const builtFolder = path.join( - buildRoot, - "en-us", - "docs", - "learn", - "css", - "css_layout", - "introduction", - "grid" - ); - expect(fs.existsSync(builtFolder)).toBeTruthy(); - - const jsonFile = path.join(builtFolder, "index.json"); - expect(fs.existsSync(jsonFile)).toBeTruthy(); - - // Let's make sure there are only 2 "macros" flaws. - const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { - doc: Doc; - }; - expect(doc.flaws).toEqual({}); -}); - test("check built flaws for /en-us/learn/css/css_layout/introduction/flex page", () => { expect(fs.existsSync(buildRoot)).toBeTruthy(); const builtFolder = path.join( @@ -930,179 +789,6 @@ test("check built flaws for /en-us/learn/css/css_layout/introduction/flex page", expect($('iframe[loading="lazy"]')).toHaveLength(0); }); -test("detect bad_bcd_queries flaws", () => { - const builtFolder = path.join( - buildRoot, - "en-us", - "docs", - "web", - "badbcdqueries" - ); - expect(fs.existsSync(builtFolder)).toBeTruthy(); - const jsonFile = path.join(builtFolder, "index.json"); - const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { - doc: Doc; - }; - expect(doc.flaws.bad_bcd_queries).toHaveLength(1); - // If the flaw is there, it's always an array because a document could - // potentially have multiple bad BCD queries. - expect(doc.flaws.bad_bcd_queries).toHaveLength(1); - expect(doc.flaws.bad_bcd_queries[0].explanation).toBe( - "No BCD data for query: api.Does.Not.exist" - ); - expect(doc.flaws.bad_bcd_queries[0].suggestion).toBeNull(); -}); - -test("detect bad_pre_tags flaws", () => { - const builtFolder = path.join( - buildRoot, - "en-us", - "docs", - "learn", - "some_code" - ); - expect(fs.existsSync(builtFolder)).toBeTruthy(); - const jsonFile = path.join(builtFolder, "index.json"); - const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { - doc: Doc; - }; - expect(doc.flaws.bad_pre_tags).toHaveLength(1); - const flaw = doc.flaws.bad_pre_tags[0]; - expect(flaw.explanation).toBe("
CODE can be just 
CODE");
-  expect(flaw.id).toBeTruthy();
-  expect(flaw.fixable).toBe(true);
-  expect(flaw.html).toBeTruthy();
-  expect(flaw.suggestion).toBeTruthy();
-  expect(flaw.line).toBe(29);
-  expect(flaw.column).toBe(50);
-});
-
-test("image flaws kitchen sink", () => {
-  const builtFolder = path.join(buildRoot, "en-us", "docs", "web", "images");
-  const jsonFile = path.join(builtFolder, "index.json");
-  const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as {
-    doc: Doc;
-  };
-  const { flaws } = doc;
-  // You have to be intimately familiar with the fixture to understand
-  // why these flaws come out as they do.
-  expect(flaws.images).toHaveLength(8);
-  const map = new Map(flaws.images.map((x) => [x.src, x]));
-
-  let flaw = map.get(
-    "https://www.peterbe.com/static/images/howsmywifi-scr.png"
-  );
-  expect(flaw.explanation).toBe("External image URL");
-  expect(flaw.suggestion).toBeNull();
-  expect(flaw.line).toBe(19);
-  expect(flaw.column).toBe(13);
-
-  flaw = map.get("idontexist.png");
-  expect(flaw.explanation).toBe(
-    "File not present on disk, an empty file, or not an image"
-  );
-  expect(flaw.suggestion).toBeNull();
-  expect(flaw.line).toBe(34);
-  expect(flaw.column).toBe(13);
-
-  flaw = map.get("/en-US/docs/Web/Images/florian.png");
-  expect(flaw.explanation).toBe("Pathname should be relative to document");
-  expect(flaw.suggestion).toBe("florian.png");
-  expect(flaw.line).toBe(39);
-  expect(flaw.column).toBe(13);
-
-  flaw = map.get("Florian.PNG");
-  expect(flaw.explanation).toBe("Pathname should always be lowercase");
-  expect(flaw.suggestion).toBe("florian.png");
-  expect(flaw.line).toBe(44);
-  expect(flaw.column).toBe(13);
-
-  flaw = map.get("http://www.peterbe.com/static/images/favicon-32.png");
-  expect(flaw.explanation).toBe("Insecure URL");
-  expect(flaw.suggestion).toBe(
-    "https://www.peterbe.com/static/images/favicon-32.png"
-  );
-  expect(flaw.line).toBe(49);
-  expect(flaw.column).toBe(13);
-
-  flaw = map.get(
-    "https://developer.mozilla.org/en-US/docs/Web/Images/screenshot.png"
-  );
-  expect(flaw.explanation).toBe("Unnecessarily absolute URL");
-  expect(flaw.suggestion).toBe("screenshot.png");
-  expect(flaw.line).toBe(54);
-  expect(flaw.column).toBe(13);
-
-  flaw = map.get("/en-US/docs/Web/Foo/screenshot.png");
-  expect(flaw.explanation).toBe("Pathname should be relative to document");
-  expect(flaw.suggestion).toBe("../Foo/screenshot.png");
-  expect(flaw.line).toBe(59);
-  expect(flaw.column).toBe(13);
-
-  flaw = map.get("../Foo/nonexistent.png");
-  expect(flaw.explanation).toBe(
-    "File not present on disk, an empty file, or not an image"
-  );
-  expect(flaw.suggestion).toBeNull();
-  expect(flaw.line).toBe(64);
-  expect(flaw.column).toBe(13);
-
-  const htmlFile = path.join(builtFolder, "index.html");
-  const html = fs.readFileSync(htmlFile, "utf-8");
-  const $ = cheerio.load(html);
-  $("#content img[src]").each((i, element) => {
-    const img = $(element);
-    const src = img.attr("src");
-    if (src.includes("www.peterbe.com/")) {
-      // These are forced to be https
-      expect(src.startsWith("https://")).toBeTruthy();
-    } else {
-      expect(src.startsWith("/en-US/docs/Web/")).toBeTruthy();
-    }
-  });
-});
-
-test("image flaws with bad images", () => {
-  const builtFolder = path.join(
-    buildRoot,
-    "en-us",
-    "docs",
-    "web",
-    "images",
-    "bad_src"
-  );
-  const jsonFile = path.join(builtFolder, "index.json");
-  const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as {
-    doc: Doc;
-  };
-  const { flaws } = doc;
-  // You have to be intimately familiar with the fixture to understand
-  // why these flaws come out as they do.
-  expect(flaws.images).toHaveLength(4);
-  expect(
-    flaws.images.filter(
-      (flaw) =>
-        flaw.explanation ===
-        "File not present on disk, an empty file, or not an image"
-    ).length
-  ).toBe(4);
-  // Check the line and column numbers for html  tags in markdown
-  expect({
-    line: flaws.images[2].line,
-    column: flaws.images[2].column,
-  }).toEqual({
-    line: 16,
-    column: 12,
-  });
-  expect({
-    line: flaws.images[3].line,
-    column: flaws.images[3].column,
-  }).toEqual({
-    line: 25,
-    column: 17,
-  });
-});
-
 test("linked to local files", () => {
   const builtFolder = path.join(
     buildRoot,
@@ -1250,90 +936,6 @@ test("specifications and bcd extraction", () => {
   expect(doc.body[4].type).toBe("prose");
 });
 
-test("headers within non-root elements is a 'sectioning' flaw", () => {
-  const builtFolder = path.join(
-    buildRoot,
-    "en-us",
-    "docs",
-    "web",
-    "sectioning_headers"
-  );
-  expect(fs.existsSync(builtFolder)).toBeTruthy();
-  const jsonFile = path.join(builtFolder, "index.json");
-  const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as {
-    doc: Doc;
-  };
-  expect(doc.flaws.sectioning[0].explanation).toBe(
-    "Excess 

tag that is NOT at root-level (id='second', text='Second')" - ); -}); - -test("img tags with an empty 'src' should be a flaw", () => { - const builtFolder = path.join( - buildRoot, - "en-us", - "docs", - "web", - "empty_image" - ); - expect(fs.existsSync(builtFolder)).toBeTruthy(); - const jsonFile = path.join(builtFolder, "index.json"); - const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { - doc: Doc; - }; - expect(doc.flaws.images).toHaveLength(2); - expect(doc.flaws.images[0].explanation).toBe("Empty img 'src' attribute"); - expect(doc.flaws.images[0].fixable).toBeFalsy(); - expect(doc.flaws.images[0].externalImage).toBeFalsy(); - expect(doc.flaws.images[0].line).toBe(8); - expect(doc.flaws.images[0].column).toBe(13); - expect(doc.flaws.images[1].explanation).toBe("Empty img 'src' attribute"); - expect(doc.flaws.images[1].fixable).toBeFalsy(); - expect(doc.flaws.images[1].externalImage).toBeFalsy(); - expect(doc.flaws.images[1].line).toBe(17); - expect(doc.flaws.images[1].column).toBe(11); -}); - -test("img with the image_widths flaw", () => { - const builtFolder = path.join( - buildRoot, - "en-us", - "docs", - "web", - "images", - "styled" - ); - expect(fs.existsSync(builtFolder)).toBeTruthy(); - const jsonFile = path.join(builtFolder, "index.json"); - const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { - doc: Doc; - }; - - expect(doc.flaws.image_widths).toHaveLength(3); - const flaw1 = doc.flaws.image_widths[0]; - expect(flaw1.explanation).toBe( - "'width' and 'height' set in 'style' attribute on tag." - ); - expect(flaw1.fixable).toBeTruthy(); - expect(flaw1.suggestion).toBe(""); - expect(flaw1.line).toBe(27); - expect(flaw1.column).toBe(11); - - const flaw2 = doc.flaws.image_widths[1]; - expect(flaw2.explanation).toBe(flaw1.explanation); - expect(flaw2.fixable).toBeTruthy(); - expect(flaw2.suggestion).toBe(""); - expect(flaw2.line).toBe(35); - expect(flaw2.column).toBe(11); - - const flaw3 = doc.flaws.image_widths[2]; - expect(flaw3.explanation).toBe(flaw1.explanation); - expect(flaw3.fixable).toBeTruthy(); - expect(flaw3.suggestion).toBe("border-radius: 100px; max-width: 1000px;"); - expect(flaw3.line).toBe(43); - expect(flaw3.column).toBe(12); -}); - test("img tags should always have their 'width' and 'height' set", () => { const builtFolder = path.join( buildRoot, @@ -1374,10 +976,7 @@ test("img tags without 'src' should not crash", () => { "srcless" ); const jsonFile = path.join(builtFolder, "index.json"); - const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { - doc: Doc; - }; - expect(doc.flaws).toEqual({}); + JSON.parse(fs.readFileSync(jsonFile, "utf-8")); }); test("/Web/Embeddable should have 4 valid live samples", () => { @@ -1427,28 +1026,6 @@ test("headings with HTML should be rendered as HTML", () => { ); }); -test("deprecated macros are fixable", () => { - const builtFolder = path.join( - buildRoot, - "en-us", - "docs", - "web", - "fixable_flaws", - "deprecated_macros" - ); - - const jsonFile = path.join(builtFolder, "index.json"); - const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { - doc: Doc; - }; - expect(doc.flaws.macros).toHaveLength(1); - // All fixable and all a suggestion of '' - expect(doc.flaws.macros.filter((flaw) => flaw.fixable)).toHaveLength(1); - expect( - doc.flaws.macros.filter((flaw) => flaw.suggestion === "") - ).toHaveLength(1); -}); - test("external links always get the right attributes", () => { const builtFolder = path.join( buildRoot, @@ -1481,47 +1058,6 @@ test("home page should have a /index.json file with pullRequestsData", () => { expect(recentContributions.items.length).toBeGreaterThan(0); }); -test("headings with links in them are flaws", () => { - const builtFolder = path.join( - buildRoot, - "en-us", - "docs", - "web", - "heading_links" - ); - - const jsonFile = path.join(builtFolder, "index.json"); - const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { - doc: Doc; - }; - expect(doc.flaws.heading_links).toHaveLength(2); - const map = new Map(doc.flaws.heading_links.map((x) => [x.id, x])); - expect(map.get("heading_links1").explanation).toBe( - "h2 heading contains an tag" - ); - expect(map.get("heading_links1").suggestion).toBe("One"); - expect(map.get("heading_links1").line).toBe(9); - expect(map.get("heading_links1").column).toBe(19); - expect(map.get("heading_links1").fixable).toBe(false); - expect(map.get("heading_links1").before).toBe('One'); - expect(map.get("heading_links1").html).toBe( - '

One

' - ); - expect(map.get("heading_links2").explanation).toBe( - "h3 heading contains an tag" - ); - expect(map.get("heading_links2").suggestion.trim()).toBe("Two"); - expect(map.get("heading_links2").line).toBe(11); - expect(map.get("heading_links2").column).toBe(19); - expect(map.get("heading_links2").fixable).toBe(false); - expect(map.get("heading_links2").before.trim()).toBe( - 'Two' - ); - expect(map.get("heading_links2").html).toBe( - '

\n Two\n

' - ); -}); - test("'lang' attribute should match the article", () => { let builtFolder = path.join(buildRoot, "fr", "docs", "web", "foo"); let htmlFile = path.join(builtFolder, "index.html"); @@ -1561,11 +1097,7 @@ test("basic markdown rendering", () => { expect($("article .fancy strong")).toHaveLength(1); const jsonFile = path.join(builtFolder, "index.json"); - const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { - doc: Doc; - }; - expect(Object.keys(doc.flaws)).toHaveLength(1); - expect(doc.flaws.bad_pre_tags).toHaveLength(1); + JSON.parse(fs.readFileSync(jsonFile, "utf-8")); }); test("unsafe HTML gets flagged as flaws and replace with its raw HTML", () => { @@ -1578,11 +1110,7 @@ test("unsafe HTML gets flagged as flaws and replace with its raw HTML", () => { ); const jsonFile = path.join(builtFolder, "index.json"); - const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { - doc: Doc; - }; - expect(doc.flaws.unsafe_html).toHaveLength(7); - + JSON.parse(fs.readFileSync(jsonFile, "utf-8")); const htmlFile = path.join(builtFolder, "index.html"); const html = fs.readFileSync(htmlFile, "utf-8"); const $ = cheerio.load(html); @@ -1594,19 +1122,7 @@ test("translated content broken links can fall back to en-us", () => { const jsonFile = path.join(builtFolder, "index.json"); // We should be able to read it and expect certain values - const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { - doc: Doc; - }; - - const map = new Map(doc.flaws.broken_links.map((x) => [x.href, x])); - expect(map.get("/fr/docs/Web/CSS/dumber")).toMatchObject({ - explanation: "Can't resolve /fr/docs/Web/CSS/dumber", - suggestion: "/fr/docs/Web/CSS/number", - fixable: true, - line: 19, - column: 16, - }); - expect(map.get("/fr/docs/Web/CSS/number")).toBeUndefined(); + JSON.parse(fs.readFileSync(jsonFile, "utf-8")); const htmlFile = path.join(builtFolder, "index.html"); const html = fs.readFileSync(htmlFile, "utf-8"); @@ -1634,7 +1150,6 @@ test("notecards are correctly transformed by the formatNotecards utility", () => const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { doc: Doc; }; - expect(doc.flaws).toStrictEqual({}); expect(doc.title).toBe( "A page representing some edge cases of div.notecard that we might encounter" ); @@ -1655,26 +1170,6 @@ test("notecards are correctly transformed by the formatNotecards utility", () => ); }); -test("homepage links and flaws", () => { - const builtFolder = path.join( - buildRoot, - "en-us", - "docs", - "web", - "homepage_links" - ); - const jsonFile = path.join(builtFolder, "index.json"); - const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { - doc: Doc; - }; - expect(doc.flaws.broken_links).toHaveLength(4); - const map = new Map(doc.flaws.broken_links.map((x) => [x.href, x])); - expect(map.get("/ru").suggestion).toBe("/ru/"); - expect(map.get("/JA/").suggestion).toBe("/ja/"); - expect(map.get("/ZH-CN").suggestion).toBe("/zh-CN/"); - expect(map.get("/notalocale/").suggestion).toBeFalsy(); -}); - test("built search-index.json (en-US)", () => { const searchIndexFile = path.join(buildRoot, "en-us", "search-index.json"); const searchIndex = JSON.parse(fs.readFileSync(searchIndexFile, "utf-8"));