Skip to content

Commit

Permalink
test(testing): update expectations, remove some cases
Browse files Browse the repository at this point in the history
Some flaws do not seem to support Markdown:
- bad_pre
- images
- sectioning
- (possibly others)
  • Loading branch information
caugner committed Dec 13, 2022
1 parent 4258eed commit 3930a98
Show file tree
Hide file tree
Showing 19 changed files with 154 additions and 370 deletions.
18 changes: 0 additions & 18 deletions testing/content/files/en-us/learn/some_code/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,3 @@ First some \<pre> blocks that are not peppered with HTML
</div>
```

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 });
});

};
```
6 changes: 3 additions & 3 deletions testing/content/files/en-us/web/brokenlinks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 20 additions & 3 deletions testing/content/files/en-us/web/check_notecards/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<div class="notecard warning"><h4>Some heading</h4><p>Paragraph 1</p><p>Paragraph 2</p></div>
> **Note:** No paragraph here.
>
> Paragraph 2
<div class="notecard extra"><h4>Some heading</h4><p>Paragraph 1</p><span>Foo bar</span><p>Paragraph 2</p></div>
## Warning

> **Warning:**
>
> Paragraph 1
>
> Paragraph 2
## Callout

> **Callout:** **Some heading**
>
> Paragraph 1
> Continues
>
> Paragraph 2
2 changes: 1 addition & 1 deletion testing/content/files/en-us/web/empty_image/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Empty <img> tag
slug: Web/Empty_image
---
Check out this image:
![]()
![Test]()
Pretty nihilistic, eh?

This one is based on make sure we've solved:
Expand Down

This file was deleted.

6 changes: 5 additions & 1 deletion testing/content/files/en-us/web/foo/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<figcaption>A perfectly normal image</figcaption>

Expand Down
6 changes: 5 additions & 1 deletion testing/content/files/en-us/web/fubar/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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") }}
11 changes: 0 additions & 11 deletions testing/content/files/en-us/web/heading_links/index.md

This file was deleted.

4 changes: 3 additions & 1 deletion testing/content/files/en-us/web/seo_summarized/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
36 changes: 10 additions & 26 deletions testing/tests/destructive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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("<code>");

const deprecatedMacrosFile = files.find((f) =>
f.includes(path.join(pattern, "deprecated_macros"))
Expand All @@ -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)");
});
});
Loading

0 comments on commit 3930a98

Please sign in to comment.