summaryrefslogtreecommitdiff
path: root/packages/integrations/markdoc/test/headings.test.js
diff options
context:
space:
mode:
authorGravatar Ben Holmes <hey@bholmes.dev> 2023-05-19 14:12:45 -0400
committerGravatar GitHub <noreply@github.com> 2023-05-19 14:12:45 -0400
commita9e1cd7e58794fe220539c2ed935c9eb96bab55a (patch)
tree07c298f7a21d61726f515dcae762fd0cbe277540 /packages/integrations/markdoc/test/headings.test.js
parent147373722b37126af949bb054a1cdfb0aed6c2ff (diff)
downloadastro-a9e1cd7e58794fe220539c2ed935c9eb96bab55a.tar.gz
astro-a9e1cd7e58794fe220539c2ed935c9eb96bab55a.tar.zst
astro-a9e1cd7e58794fe220539c2ed935c9eb96bab55a.zip
Fix: Heading ID CI flakiness (#7141)
* feat: use `ctx` object instead of leaky global * test: heading IDs stale caches * chore: changeset
Diffstat (limited to 'packages/integrations/markdoc/test/headings.test.js')
-rw-r--r--packages/integrations/markdoc/test/headings.test.js50
1 files changed, 40 insertions, 10 deletions
diff --git a/packages/integrations/markdoc/test/headings.test.js b/packages/integrations/markdoc/test/headings.test.js
index 5db50065c..5468e8c6b 100644
--- a/packages/integrations/markdoc/test/headings.test.js
+++ b/packages/integrations/markdoc/test/headings.test.js
@@ -27,7 +27,15 @@ describe('Markdoc - Headings', () => {
});
it('applies IDs to headings', async () => {
- const res = await fixture.fetch('/');
+ const res = await fixture.fetch('/headings');
+ const html = await res.text();
+ const { document } = parseHTML(html);
+
+ idTest(document);
+ });
+
+ it('generates the same IDs for other documents with the same headings', async () => {
+ const res = await fixture.fetch('/headings-stale-cache-check');
const html = await res.text();
const { document } = parseHTML(html);
@@ -35,7 +43,7 @@ describe('Markdoc - Headings', () => {
});
it('generates a TOC with correct info', async () => {
- const res = await fixture.fetch('/');
+ const res = await fixture.fetch('/headings');
const html = await res.text();
const { document } = parseHTML(html);
@@ -49,14 +57,21 @@ describe('Markdoc - Headings', () => {
});
it('applies IDs to headings', async () => {
- const html = await fixture.readFile('/index.html');
+ const html = await fixture.readFile('/headings/index.html');
+ const { document } = parseHTML(html);
+
+ idTest(document);
+ });
+
+ it('generates the same IDs for other documents with the same headings', async () => {
+ const html = await fixture.readFile('/headings-stale-cache-check/index.html');
const { document } = parseHTML(html);
idTest(document);
});
it('generates a TOC with correct info', async () => {
- const html = await fixture.readFile('/index.html');
+ const html = await fixture.readFile('/headings/index.html');
const { document } = parseHTML(html);
tocTest(document);
@@ -83,7 +98,15 @@ describe('Markdoc - Headings with custom Astro renderer', () => {
});
it('applies IDs to headings', async () => {
- const res = await fixture.fetch('/');
+ const res = await fixture.fetch('/headings');
+ const html = await res.text();
+ const { document } = parseHTML(html);
+
+ idTest(document);
+ });
+
+ it('generates the same IDs for other documents with the same headings', async () => {
+ const res = await fixture.fetch('/headings-stale-cache-check');
const html = await res.text();
const { document } = parseHTML(html);
@@ -91,7 +114,7 @@ describe('Markdoc - Headings with custom Astro renderer', () => {
});
it('generates a TOC with correct info', async () => {
- const res = await fixture.fetch('/');
+ const res = await fixture.fetch('/headings');
const html = await res.text();
const { document } = parseHTML(html);
@@ -99,7 +122,7 @@ describe('Markdoc - Headings with custom Astro renderer', () => {
});
it('renders Astro component for each heading', async () => {
- const res = await fixture.fetch('/');
+ const res = await fixture.fetch('/headings');
const html = await res.text();
const { document } = parseHTML(html);
@@ -113,21 +136,28 @@ describe('Markdoc - Headings with custom Astro renderer', () => {
});
it('applies IDs to headings', async () => {
- const html = await fixture.readFile('/index.html');
+ const html = await fixture.readFile('/headings/index.html');
+ const { document } = parseHTML(html);
+
+ idTest(document);
+ });
+
+ it('generates the same IDs for other documents with the same headings', async () => {
+ const html = await fixture.readFile('/headings-stale-cache-check/index.html');
const { document } = parseHTML(html);
idTest(document);
});
it('generates a TOC with correct info', async () => {
- const html = await fixture.readFile('/index.html');
+ const html = await fixture.readFile('/headings/index.html');
const { document } = parseHTML(html);
tocTest(document);
});
it('renders Astro component for each heading', async () => {
- const html = await fixture.readFile('/index.html');
+ const html = await fixture.readFile('/headings/index.html');
const { document } = parseHTML(html);
astroComponentTest(document);