diff --git a/testing/content/files/en-us/learn/some_code/index.md b/testing/content/files/en-us/learn/some_code/index.md index 37557396e867..4c916e93d5a9 100644 --- a/testing/content/files/en-us/learn/some_code/index.md +++ b/testing/content/files/en-us/learn/some_code/index.md @@ -22,21 +22,3 @@ First some \
 blocks that are not peppered with HTML
 
 ```
 
-A real example found in the Kuma-HTML source.
-What the original author should have done is it to put the (html escaped)
-raw JS code in there. Not the HTML you get from Prism.
-
-```js
-// Display list of all BookInstances.
-exports.bookinstance_list = function(req, res, next) {
-
-  BookInstance.find()
-    .populate('book')
-    .exec(function (err, list_bookinstances) {
-      if (err) { return next(err); }
-      // Successful, so render
-      res.render('bookinstance_list', { title: 'Book Instance List', bookinstance_list: list_bookinstances });
-    });
-
-};
-```
diff --git a/testing/content/files/en-us/web/brokenlinks/index.md b/testing/content/files/en-us/web/brokenlinks/index.md
index 4f3adeea5ba7..f3386cf7ac5a 100644
--- a/testing/content/files/en-us/web/brokenlinks/index.md
+++ b/testing/content/files/en-us/web/brokenlinks/index.md
@@ -10,11 +10,11 @@ slug: Web/BrokenLinks
 
 `/en-US/docs/Web/CSS/dumber`
 
-[Too verbose!](/en-US/docs/Web/API/Blob)
+[Too verbose!](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
 
-[Also, too verbose but with anchor](/en-US/docs/Web/API/Blob#Anchor)
+[Also, too verbose but with anchor](https://developer.mozilla.org/en-US/docs/Web/API/Blob#Anchor)
 
-[Also, too verbose but with query string](/en-US/docs/Web/API/Blob?a=b)
+[Also, too verbose but with query string](https://developer.mozilla.org/en-US/docs/Web/API/Blob?a=b)
 
 [This should have a suggestion and the suggestion should
 keep the `#fragment` on the suggested href.](/en-US/docs/Web/HTML/Element/anchor#fragment)
diff --git a/testing/content/files/en-us/web/check_notecards/index.md b/testing/content/files/en-us/web/check_notecards/index.md
index 823d9671f415..42e266248a5b 100644
--- a/testing/content/files/en-us/web/check_notecards/index.md
+++ b/testing/content/files/en-us/web/check_notecards/index.md
@@ -4,8 +4,25 @@ slug: Web/Check_notecards
 ---
 This page exists to test the formatNotecards utility for transforming notecards from h4 to strong
 
-> **Note:** #### Some headingNo paragraph here.Paragraph 2
+## Note
 
-

Some heading

Paragraph 1

Paragraph 2

+> **Note:** No paragraph here. +> +> Paragraph 2 -

Some heading

Paragraph 1

Foo bar

Paragraph 2

+## Warning + +> **Warning:** +> +> Paragraph 1 +> +> Paragraph 2 + +## Callout + +> **Callout:** **Some heading** +> +> Paragraph 1 +> Continues +> +> Paragraph 2 diff --git a/testing/content/files/en-us/web/empty_image/index.md b/testing/content/files/en-us/web/empty_image/index.md index 1b895bc86cba..63c0d12bb6d7 100644 --- a/testing/content/files/en-us/web/empty_image/index.md +++ b/testing/content/files/en-us/web/empty_image/index.md @@ -3,7 +3,7 @@ title: Empty tag slug: Web/Empty_image --- Check out this image: -![]() +![Test]() Pretty nihilistic, eh? This one is based on make sure we've solved: diff --git a/testing/content/files/en-us/web/fixable_flaws/bad_pre_tags/index.md b/testing/content/files/en-us/web/fixable_flaws/bad_pre_tags/index.md deleted file mode 100644 index ca4bc9da925d..000000000000 --- a/testing/content/files/en-us/web/fixable_flaws/bad_pre_tags/index.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: Fixable flawed
 tags
-slug: Web/Fixable_Flaws/Bad_pre_tags
----
-Fixable pre tag...
-
-```html
-
code
-```
diff --git a/testing/content/files/en-us/web/foo/index.md b/testing/content/files/en-us/web/foo/index.md
index 4eb0d1303e54..1973ec82bfcf 100644
--- a/testing/content/files/en-us/web/foo/index.md
+++ b/testing/content/files/en-us/web/foo/index.md
@@ -13,7 +13,11 @@ This becomes the summary.
 
 Let's include some other pages:
 
-{{page("web/fubar")}}{{page("web/fixable_flaws")}}![Screenshot of colors](screenshot.png)
+{{page("web/fubar")}}
+
+{{page("web/fixable_flaws")}}
+
+![Screenshot of colors](screenshot.png)
 
 
A perfectly normal image
diff --git a/testing/content/files/en-us/web/fubar/index.md b/testing/content/files/en-us/web/fubar/index.md index 3406ab092fb3..82b6c960cf6e 100644 --- a/testing/content/files/en-us/web/fubar/index.md +++ b/testing/content/files/en-us/web/fubar/index.md @@ -7,4 +7,8 @@ tags: --- Let's include some other pages: -{{page("web/fixable_flaws")}}{{page("does-not-exist")}}{{ EmbedLiveSample('example', '300', '300', "", "does/not/exist") }} +{{page("web/fixable_flaws")}} + +{{page("does-not-exist")}} + +{{ EmbedLiveSample('example', '300', '300', "", "does/not/exist") }} diff --git a/testing/content/files/en-us/web/heading_links/index.md b/testing/content/files/en-us/web/heading_links/index.md deleted file mode 100644 index 65eeb583daf3..000000000000 --- a/testing/content/files/en-us/web/heading_links/index.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: Naughty headings with tags in them -slug: Web/Heading_links ---- -This page exists to demonstrate the `heading_links` flaw. - -## [One](#something) - -### Two - -## `Three` diff --git a/testing/content/files/en-us/web/seo_summarized/index.md b/testing/content/files/en-us/web/seo_summarized/index.md index 0f64412ed9e4..ae8ce55c2fe6 100644 --- a/testing/content/files/en-us/web/seo_summarized/index.md +++ b/testing/content/files/en-us/web/seo_summarized/index.md @@ -2,4 +2,6 @@ title: A page slug: Web/SEO_Summarized --- -This is going to be the summary. But this is not. +This is going to be the summary. + +But this is not. diff --git a/testing/tests/destructive.test.ts b/testing/tests/destructive.test.ts index 3f62535d735d..f1b14268ed8d 100644 --- a/testing/tests/destructive.test.ts +++ b/testing/tests/destructive.test.ts @@ -99,10 +99,8 @@ describe("fixing flaws", () => { .split("\n") .filter((line) => regexPattern.test(line)); expect(dryRunNotices).toHaveLength(2); - expect(dryRunNotices[0]).toContain(path.join(pattern, "bad_pre_tags")); - expect(dryRunNotices[1]).toContain(path.join(pattern, "deprecated_macros")); - expect(dryRunNotices[2]).toContain(path.join(pattern, "images")); - expect(dryRunNotices[3]).toContain(pattern); + expect(dryRunNotices[0]).toContain(path.join(pattern, "deprecated_macros")); + expect(dryRunNotices[1]).toContain(pattern); const dryrunFiles = getChangedFiles(tempContentDir); expect(dryrunFiles).toHaveLength(0); }); @@ -126,17 +124,6 @@ describe("fixing flaws", () => { const files = getChangedFiles(tempContentDir); expect(files).toHaveLength(2); - const imagesFile = files.find((f) => - f.includes(path.join(pattern, "images")) - ); - const newRawHtmlImages = fs.readFileSync(imagesFile, "utf-8"); - expect(newRawHtmlImages).toContain('src="fixable.png"'); - - const badPreTagFile = files.find((f) => - f.includes(path.join(pattern, "bad_pre_tags")) - ); - const newRawHtmlPreWithHTML = fs.readFileSync(badPreTagFile, "utf-8"); - expect(newRawHtmlPreWithHTML).not.toContain(""); const deprecatedMacrosFile = files.find((f) => f.includes(path.join(pattern, "deprecated_macros")) @@ -147,17 +134,14 @@ describe("fixing flaws", () => { ); expect(newRawHtmlDeprecatedMacros).not.toContain("{{"); - const regularFile = files.find( - (f) => - f !== imagesFile && f !== badPreTagFile && f !== deprecatedMacrosFile - ); - const newRawHtml = fs.readFileSync(regularFile, "utf-8"); - expect(newRawHtml).toContain("{{CSSxRef('number')}}"); - expect(newRawHtml).toContain('{{htmlattrxref("href", "a")}}'); + const regularFile = files.find((f) => f !== deprecatedMacrosFile); + const newRawMd = fs.readFileSync(regularFile, "utf-8"); + expect(newRawMd).toContain("{{CSSxRef('number')}}"); + expect(newRawMd).toContain('{{htmlattrxref("href", "a")}}'); // Broken links that get fixed. - expect(newRawHtml).toContain('href="/en-US/docs/Web/CSS/number"'); - expect(newRawHtml).toContain("href='/en-US/docs/Web/CSS/number'"); - expect(newRawHtml).toContain('href="/en-US/docs/Glossary/Bézier_curve"'); - expect(newRawHtml).toContain('href="/en-US/docs/Web/Foo"'); + expect(newRawMd).toContain("(/en-US/docs/Web/CSS/number)"); + expect(newRawMd).toContain("(/en-US/docs/Web/CSS/number)"); + expect(newRawMd).toContain("(/en-US/docs/Glossary/Bézier_curve)"); + expect(newRawMd).toContain("(/en-US/docs/Web/Foo)"); }); }); diff --git a/testing/tests/index.test.ts b/testing/tests/index.test.ts index d133b12e3710..d5d884c50cc3 100644 --- a/testing/tests/index.test.ts +++ b/testing/tests/index.test.ts @@ -136,10 +136,10 @@ test("content built foo page", () => { ) ); expect(doc.flaws.macros[4].line).toBe(10); - expect(doc.flaws.macros[4].column).toBe(6); + expect(doc.flaws.macros[4].column).toBe(1); // Check that the line numbers in the source context have been adjusted by the offset. expect(doc.flaws.macros[4].sourceContext).toEqual( - expect.stringContaining('
{{page("does-not-exist")}}
') + expect.stringContaining('{{page("does-not-exist")}}') ); expect(doc.flaws.macros[4].filepath).toMatch( /\/en-us\/web\/fubar\/index\.md$/ @@ -151,11 +151,11 @@ test("content built foo page", () => { ) ); expect(doc.flaws.macros[5].line).toBe(11); - expect(doc.flaws.macros[5].column).toBe(6); + expect(doc.flaws.macros[5].column).toBe(1); // Check that the line numbers in the source context have been adjusted by the offset. expect(doc.flaws.macros[5].sourceContext).toEqual( expect.stringContaining( - `
{{ EmbedLiveSample('example', '300', '300', "", "does/not/exist") }}
` + `{{ EmbedLiveSample('example', '300', '300', "", "does/not/exist") }}` ) ); expect(doc.flaws.macros[5].filepath).toMatch( @@ -323,7 +323,7 @@ test("content built French Embeddable page", () => { 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 4 possible)" + "Differences in the important macros (0 in common of 3 possible)" ); expect(flaw.fixable).toBeFalsy(); expect(flaw.suggestion).toBeFalsy(); @@ -492,23 +492,23 @@ test("content built bar page", () => { expect(doc.flaws.macros).toHaveLength(12); 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[0].line).toBe(10); + expect(doc.flaws.macros[0].column).toBe(7); 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].line).toBe(11); + expect(doc.flaws.macros[1].column).toBe(7); 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[2].line).toBe(13); + expect(doc.flaws.macros[2].column).toBe(7); 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].line).toBe(14); + expect(doc.flaws.macros[3].column).toBe(7); 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"); @@ -516,53 +516,53 @@ test("content built bar page", () => { expect(doc.flaws.macros[4].macroSource).toBe( '{{htmlattrxref("href", "bigfoot")}}' ); - expect(doc.flaws.macros[4].line).toBe(15); - expect(doc.flaws.macros[4].column).toBe(6); + expect(doc.flaws.macros[4].line).toBe(16); + expect(doc.flaws.macros[4].column).toBe(7); expect(doc.flaws.macros[5].name).toBe("MacroRedirectedLinkError"); expect(doc.flaws.macros[5].macroSource).toBe( '{{htmlattrxref("href", "anchor")}}' ); - expect(doc.flaws.macros[5].line).toBe(16); - expect(doc.flaws.macros[5].column).toBe(6); + expect(doc.flaws.macros[5].line).toBe(17); + expect(doc.flaws.macros[5].column).toBe(7); expect(doc.flaws.macros[5].redirectInfo).toBeDefined(); expect(doc.flaws.macros[5].redirectInfo.current).toBe("anchor"); expect(doc.flaws.macros[5].redirectInfo.suggested).toBe("a"); expect(doc.flaws.macros[6].name).toBe("MacroBrokenLinkError"); expect(doc.flaws.macros[6].macroSource).toBe('{{jsxref("bigfoot")}}'); - expect(doc.flaws.macros[6].line).toBe(18); - expect(doc.flaws.macros[6].column).toBe(6); + expect(doc.flaws.macros[6].line).toBe(19); + expect(doc.flaws.macros[6].column).toBe(7); expect(doc.flaws.macros[7].name).toBe("MacroRedirectedLinkError"); expect(doc.flaws.macros[7].macroSource).toBe('{{jsxref("Stern_mode")}}'); - expect(doc.flaws.macros[7].line).toBe(19); - expect(doc.flaws.macros[7].column).toBe(6); + expect(doc.flaws.macros[7].line).toBe(20); + expect(doc.flaws.macros[7].column).toBe(7); expect(doc.flaws.macros[7].redirectInfo).toBeDefined(); expect(doc.flaws.macros[7].redirectInfo.current).toBe("Stern_mode"); expect(doc.flaws.macros[7].redirectInfo.suggested).toBe("Strict_mode"); expect(doc.flaws.macros[8].name).toBe("MacroRedirectedLinkError"); expect(doc.flaws.macros[8].macroSource).toBe('{{jsxref("Flag")}}'); - expect(doc.flaws.macros[8].line).toBe(21); - expect(doc.flaws.macros[8].column).toBe(6); + expect(doc.flaws.macros[8].line).toBe(22); + expect(doc.flaws.macros[8].column).toBe(7); 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(22); - expect(doc.flaws.macros[9].column).toBe(6); + expect(doc.flaws.macros[9].line).toBe(23); + expect(doc.flaws.macros[9].column).toBe(7); 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"); expect(doc.flaws.macros[10].name).toBe("MacroRedirectedLinkError"); expect(doc.flaws.macros[10].macroSource).toBe('{{JSXref("Flag")}}'); - expect(doc.flaws.macros[10].line).toBe(23); - expect(doc.flaws.macros[10].column).toBe(6); + expect(doc.flaws.macros[10].line).toBe(24); + expect(doc.flaws.macros[10].column).toBe(7); expect(doc.flaws.macros[10].redirectInfo).toBeDefined(); expect(doc.flaws.macros[10].redirectInfo.current).toBe("Flag"); expect(doc.flaws.macros[10].redirectInfo.suggested).toBe("Boolean"); expect(doc.flaws.macros[11].name).toBe("MacroRedirectedLinkError"); expect(doc.flaws.macros[11].macroSource).toBe('{{JSXref("Flag")}}'); - expect(doc.flaws.macros[11].line).toBe(24); - expect(doc.flaws.macros[11].column).toBe(6); + expect(doc.flaws.macros[11].line).toBe(25); + expect(doc.flaws.macros[11].column).toBe(7); expect(doc.flaws.macros[11].redirectInfo).toBeDefined(); expect(doc.flaws.macros[11].redirectInfo.current).toBe("Flag"); expect(doc.flaws.macros[11].redirectInfo.suggested).toBe("Boolean"); @@ -665,8 +665,8 @@ test("broken links flaws", () => { // Map them by 'href' const map = new Map(flaws.broken_links.map((x) => [x.href, x])); expect(map.get("/en-US/docs/Hopeless/Case").suggestion).toBeNull(); - expect(map.get("/en-US/docs/Web/CSS/dumber").line).toBe(10); - expect(map.get("/en-US/docs/Web/CSS/dumber").column).toBe(13); + expect(map.get("/en-US/docs/Web/CSS/dumber").line).toBe(9); + expect(map.get("/en-US/docs/Web/CSS/dumber").column).toBe(1); expect( map.get("https://developer.mozilla.org/en-US/docs/Web/API/Blob").suggestion ).toBe("/en-US/docs/Web/API/Blob"); @@ -904,8 +904,8 @@ test("broken anchor links flaws", () => { expect(map.get("#Heading1").suggestion).toBe("#heading1"); expect(map.get("#Heading1").explanation).toBe("Anchor not lowercase"); expect(map.get("#Heading1").fixable).toBe(true); - expect(map.get("#Heading1").line).toBe(7); - expect(map.get("#Heading1").column).toBe(16); + expect(map.get("#Heading1").line).toBe(5); + expect(map.get("#Heading1").column).toBe(3); expect(map.get("/en-US/docs/Web/Foo#Heading2").suggestion).toBe( "/en-US/docs/Web/Foo#heading2" @@ -914,8 +914,8 @@ test("broken anchor links flaws", () => { "Anchor not lowercase" ); expect(map.get("/en-US/docs/Web/Foo#Heading2").fixable).toBe(true); - expect(map.get("/en-US/docs/Web/Foo#Heading2").line).toBe(8); - expect(map.get("/en-US/docs/Web/Foo#Heading2").column).toBe(16); + expect(map.get("/en-US/docs/Web/Foo#Heading2").line).toBe(6); + expect(map.get("/en-US/docs/Web/Foo#Heading2").column).toBe(3); expect(map.get("/en-US/docs/Web/Fuu#Anchor").suggestion).toBe( "/en-US/docs/Web/Foo#anchor" @@ -924,8 +924,8 @@ test("broken anchor links flaws", () => { "Can't resolve /en-US/docs/Web/Fuu#Anchor" ); expect(map.get("/en-US/docs/Web/Fuu#Anchor").fixable).toBe(true); - expect(map.get("/en-US/docs/Web/Fuu#Anchor").line).toBe(11); - expect(map.get("/en-US/docs/Web/Fuu#Anchor").column).toBe(16); + expect(map.get("/en-US/docs/Web/Fuu#Anchor").line).toBe(9); + expect(map.get("/en-US/docs/Web/Fuu#Anchor").column).toBe(3); const htmlFile = path.join(builtFolder, "index.html"); const html = fs.readFileSync(htmlFile, "utf-8"); @@ -1037,31 +1037,7 @@ test("detect bad_bcd_links flaws from", () => { expect(flaw.query).toBe("api.Document.visibilityState"); }); -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", () => {
+test.skip("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 {
@@ -1146,32 +1122,6 @@ test("image flaws kitchen sink", () => {
   });
 });
 
-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);
-});
-
 test("linked to local files", () => {
   const builtFolder = path.join(
     buildRoot,
@@ -1197,7 +1147,7 @@ test("linked to local files", () => {
   });
 });
 
-test("image flaws with repeated external images", () => {
+test.skip("image flaws with repeated external images", () => {
   // This test exists because of https://github.com/mdn/yari/issues/2247
   // which showed that if a document has an external URL repeated more than
   // once, our flaw detection only found it once.
@@ -1313,7 +1263,7 @@ test("bcd table extraction followed by h3", () => {
   expect(doc.body[2].value.isH3).toBeFalsy();
   expect(doc.body[3].type).toBe("prose");
   expect(doc.body[4].type).toBe("prose");
-  expect(doc.body[4].value.isH3).toBeTruthy();
+  expect(doc.body[4].value.isH3).toBeFalsy();
 });
 
 test("specifications and bcd extraction", () => {
@@ -1335,93 +1285,8 @@ test("specifications and bcd extraction", () => {
     (doc.body[1] as SpecificationsSection).value.specifications[0]
       .bcdSpecificationURL
   ).toBeDefined();
-  expect(doc.body[2].type).toBe("prose");
-  expect(doc.body[3].type).toBe("browser_compatibility");
-  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); + expect(doc.body[2].type).toBe("browser_compatibility"); + expect(doc.body[3].type).toBe("prose"); }); test("img tags should always have their 'width' and 'height' set", () => { @@ -1481,7 +1346,7 @@ test("/Web/Embeddable should have 3 valid live samples", () => { const htmlFile = path.join(builtFolder, "index.html"); const html = fs.readFileSync(htmlFile, "utf-8"); const $ = cheerio.load(html); - expect($("iframe")).toHaveLength(3); + expect($("iframe")).toHaveLength(2); const jsonFile = path.join(builtFolder, "index.json"); const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { @@ -1497,7 +1362,7 @@ test("/Web/Embeddable should have 3 valid live samples", () => { const startOffset = "_sample_.".length; return f.substr(startOffset, f.length - startOffset - ".html".length); }) - ).toEqual(expect.arrayContaining(["colorpicker_tool", "keyboard", "meter"])); + ).toEqual(expect.arrayContaining(["colorpicker_tool", "keyboard"])); }); test("headings with HTML should be rendered as HTML", () => { @@ -1592,47 +1457,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"); @@ -1692,12 +1516,12 @@ test("unsafe HTML gets flagged as flaws and replace with its raw HTML", () => { const { doc } = JSON.parse(fs.readFileSync(jsonFile, "utf-8")) as { doc: Doc; }; - expect(doc.flaws.unsafe_html).toHaveLength(7); + expect(doc.flaws.unsafe_html).toHaveLength(5); const htmlFile = path.join(builtFolder, "index.html"); const html = fs.readFileSync(htmlFile, "utf-8"); const $ = cheerio.load(html); - expect($("code.unsafe-html")).toHaveLength(7); + expect($("code.unsafe-html")).toHaveLength(5); }); test("translated content broken links can fall back to en-us", () => { @@ -1752,14 +1576,19 @@ test("notecards are correctly transformed by the formatNotecards utility", () => expect($("div.notecard h4")).toHaveLength(0); expect($("div.notecard.note").html()).toBe( - "

Some heading: No paragraph here.

Paragraph 2

" + "\n

Note: No paragraph here.

\n

Paragraph 2

\n" ); expect($("div.notecard.warning").html()).toBe( - "

Some heading: Paragraph 1

Paragraph 2

" - ); - expect($("div.notecard.extra").html()).toBe( - "

Some heading: Paragraph 1

Foo bar

Paragraph 2

" - ); + "\n

Warning:

\n

Paragraph 1

\n

Paragraph 2

\n" + ); + expect($("div.callout").html()).toBe(` +

Some heading

+

+ Paragraph 1 + Continues +

+

Paragraph 2

+`); }); test("homepage links and flaws", () => { diff --git a/testing/translated-content/files/fr/web/embeddable/index.html b/testing/translated-content/files/fr/web/embeddable/index.html deleted file mode 100644 index 8db28a5c6dc1..000000000000 --- a/testing/translated-content/files/fr/web/embeddable/index.html +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: Incorporer un échantillon en direct avec et sans nom -slug: Web/Embeddable ---- - -

- This make exists to demonstrate that the French content has a difference in - the EmbedLiveSample macro use. -

- -
{{EmbedInteractiveExample("pages/css/animation.html", "taller")}}
diff --git a/testing/translated-content/files/fr/web/embeddable/index.md b/testing/translated-content/files/fr/web/embeddable/index.md new file mode 100644 index 000000000000..88b34c82cdec --- /dev/null +++ b/testing/translated-content/files/fr/web/embeddable/index.md @@ -0,0 +1,9 @@ +--- +title: Incorporer un échantillon en direct avec et sans nom +slug: Web/Embeddable +--- + +This make exists to demonstrate that the French content has a difference in the +`EmbedLiveSample` macro use. + +{{EmbedInteractiveExample("pages/css/animation.html", "taller")}} diff --git a/testing/translated-content/files/fr/web/foo/index.html b/testing/translated-content/files/fr/web/foo/index.html deleted file mode 100644 index 67a34f931c1f..000000000000 --- a/testing/translated-content/files/fr/web/foo/index.html +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: ": Une page de test" -slug: Web/Foo -translation_of: Web/Foo ---- - -

Foë

- -
- Capture d'écran des couleurs -
Une image parfaitement normale
-
- -

- This here demonstrates what happens when translated links exist but they're - actually broken. And in this case, what should happen is that it can fall back - on the en-US equivalent of those URLs. -

- diff --git a/testing/translated-content/files/fr/web/foo/index.md b/testing/translated-content/files/fr/web/foo/index.md new file mode 100644 index 000000000000..779c53962e5b --- /dev/null +++ b/testing/translated-content/files/fr/web/foo/index.md @@ -0,0 +1,16 @@ +--- +title: ": Une page de test" +slug: Web/Foo +translation_of: Web/Foo +--- + +Foë + +![Capture d'écran des couleurs](screenshot.png) + +This here demonstrates what happens when translated links exist but they're +actually broken. And in this case, what should happen is that it can fall back +on the en-US equivalent of those URLs. + +- [The "dumber" page](/fr/docs/Web/CSS/dumber) +- [The _number_ page](/fr/docs/Web/CSS/number) diff --git a/testing/translated-content/files/fr/web/spec_section_extraction/index.html b/testing/translated-content/files/fr/web/spec_section_extraction/index.html deleted file mode 100644 index ae14c9499226..000000000000 --- a/testing/translated-content/files/fr/web/spec_section_extraction/index.html +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: Extraction de sections de spécifications -slug: Web/Spec_Section_Extraction ---- - -

- The purpose of this fixture is to test that this translated document can - benefit from the browser-compat front-matter in it's en-US - parent. -

- -

Spécifications

- -

{{Specifications}}

- -

Compatibilité des navigateur

- -

{{Compat}}

diff --git a/testing/translated-content/files/fr/web/spec_section_extraction/index.md b/testing/translated-content/files/fr/web/spec_section_extraction/index.md new file mode 100644 index 000000000000..9c88db657b98 --- /dev/null +++ b/testing/translated-content/files/fr/web/spec_section_extraction/index.md @@ -0,0 +1,15 @@ +--- +title: Extraction de sections de spécifications +slug: Web/Spec_Section_Extraction +--- + +The purpose of this fixture is to test that this translated document can benefit +from the `browser-compat` front-matter in it's en-US parent. + +## Spécifications + +{{Specifications}} + +## Compatibilité des navigateur + +{{Compat}} diff --git a/testing/translated-content/files/zh-tw/web/foo/index.html b/testing/translated-content/files/zh-tw/web/foo/index.html deleted file mode 100644 index 65b6e837d548..000000000000 --- a/testing/translated-content/files/zh-tw/web/foo/index.html +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: ": 測試網頁" -slug: Web/Foo -translation_of: Web/Foo ---- - -

- Peter's note. I don't know how to express anything in Chinese beyond Google - Translate -

- -
- 顏色的屏幕截圖 -
顏色的屏幕截圖
-
diff --git a/testing/translated-content/files/zh-tw/web/foo/index.md b/testing/translated-content/files/zh-tw/web/foo/index.md new file mode 100644 index 000000000000..55c8689b9299 --- /dev/null +++ b/testing/translated-content/files/zh-tw/web/foo/index.md @@ -0,0 +1,10 @@ +--- +title: ": 測試網頁" +slug: Web/Foo +translation_of: Web/Foo +--- + +Peter's note. I don't know how to express anything in Chinese beyond Google +Translate + +![顏色的屏幕截圖](screenshot.png)