import { parseHTML } from 'linkedom'; import { expect } from 'chai'; import { loadFixture } from '../../../astro/test/test-utils.js'; async function getFixture(name) { return await loadFixture({ root: new URL(`./fixtures/${name}/`, import.meta.url), }); } describe('Markdoc - render html', () => { let fixture; before(async () => { fixture = await getFixture('render-html'); }); describe('dev', () => { let devServer; before(async () => { devServer = await fixture.startDevServer(); }); after(async () => { await devServer.stop(); }); it('renders content - simple', async () => { const res = await fixture.fetch('/simple'); const html = await res.text(); renderSimpleChecks(html); }); it('renders content - nested-html', async () => { const res = await fixture.fetch('/nested-html'); const html = await res.text(); renderNestedHTMLChecks(html); }); it('renders content - components interleaved with html', async () => { const res = await fixture.fetch('/components'); const html = await res.text(); renderComponentsHTMLChecks(html); }); it('renders content - randomly cased html attributes', async () => { const res = await fixture.fetch('/randomly-cased-html-attributes'); const html = await res.text(); renderRandomlyCasedHTMLAttributesChecks(html); }); }); describe('build', () => { before(async () => { await fixture.build(); }); it('renders content - simple', async () => { const html = await fixture.readFile('/simple/index.html'); renderSimpleChecks(html); }); it('renders content - nested-html', async () => { const html = await fixture.readFile('/nested-html/index.html'); renderNestedHTMLChecks(html); }); it('renders content - components interleaved with html', async () => { const html = await fixture.readFile('/components/index.html'); renderComponentsHTMLChecks(html); }); it('renders content - randomly cased html attributes', async () => { const html = await fixture.readFile('/randomly-cased-html-attributes/index.html'); renderRandomlyCasedHTMLAttributesChecks(html); }); }); }); /** @param {string} html */ function renderSimpleChecks(html) { const { document } = parseHTML(html); const h2 = document.querySelector('h2'); expect(h2.textContent).to.equal('Simple post header'); const spanInsideH2 = document.querySelector('h2 > span'); expect(spanInsideH2.textContent).to.equal('post'); expect(spanInsideH2.className).to.equal('inside-h2'); expect(spanInsideH2.style.color).to.equal('fuscia'); const p1 = document.querySelector('article > p:nth-of-type(1)'); expect(p1.children.length).to.equal(1); expect(p1.textContent).to.equal('This is a simple Markdoc post.'); const p2 = document.querySelector('article > p:nth-of-type(2)'); expect(p2.children.length).to.equal(0); expect(p2.textContent).to.equal('This is a paragraph!'); const p3 = document.querySelector('article > p:nth-of-type(3)'); expect(p3.children.length).to.equal(1); expect(p3.textContent).to.equal('This is a span inside a paragraph!'); } /** @param {string} html */ function renderNestedHTMLChecks(html) { const { document } = parseHTML(html); const p1 = document.querySelector('p:nth-of-type(1)'); expect(p1.id).to.equal('p1'); expect(p1.textContent).to.equal('before inner after'); expect(p1.children.length).to.equal(1); const p1Span1 = p1.querySelector('span'); expect(p1Span1.textContent).to.equal('inner'); expect(p1Span1.id).to.equal('inner1'); expect(p1Span1.className).to.equal('inner-class'); expect(p1Span1.style.color).to.equal('hotpink'); const p2 = document.querySelector('p:nth-of-type(2)'); expect(p2.id).to.equal('p2'); expect(p2.textContent).to.equal('\n before\n inner\n after\n'); expect(p2.children.length).to.equal(1); const divL1 = document.querySelector('div:nth-of-type(1)'); expect(divL1.id).to.equal('div-l1'); expect(divL1.children.length).to.equal(2); const divL2_1 = divL1.querySelector('div:nth-of-type(1)'); expect(divL2_1.id).to.equal('div-l2-1'); expect(divL2_1.children.length).to.equal(1); const p3 = divL2_1.querySelector('p:nth-of-type(1)'); expect(p3.id).to.equal('p3'); expect(p3.textContent).to.equal('before inner after'); expect(p3.children.length).to.equal(1); const divL2_2 = divL1.querySelector('div:nth-of-type(2)'); expect(divL2_2.id).to.equal('div-l2-2'); expect(divL2_2.children.length).to.equal(2); const p4 = divL2_2.querySelector('p:nth-of-type(1)'); expect(p4.id).to.equal('p4'); expect(p4.textContent).to.equal('before inner after'); expect(p4.children.length).to.equal(1); const p5 = divL2_2.querySelector('p:nth-of-type(2)'); expect(p5.id).to.equal('p5'); expect(p5.textContent).to.equal('before inner after'); expect(p5.children.length).to.equal(1); } /** * * @param {string} html */ function renderRandomlyCasedHTMLAttributesChecks(html) { const { document } = parseHTML(html); const td1 = document.querySelector('#td1'); const td2 = document.querySelector('#td1'); const td3 = document.querySelector('#td1'); const td4 = document.querySelector('#td1'); // all four 's which had randomly cased variants of colspan/rowspan should all be rendered lowercased at this point expect(td1.getAttribute('colspan')).to.equal('3'); expect(td1.getAttribute('rowspan')).to.equal('2'); expect(td2.getAttribute('colspan')).to.equal('3'); expect(td2.getAttribute('rowspan')).to.equal('2'); expect(td3.getAttribute('colspan')).to.equal('3'); expect(td3.getAttribute('rowspan')).to.equal('2'); expect(td4.getAttribute('colspan')).to.equal('3'); expect(td4.getAttribute('rowspan')).to.equal('2'); } /** * Asserts that the rendered HTML tags with interleaved Markdoc tags (both block and inline) rendered in the expected nested graph of elemements * * @param {string} html */ function renderComponentsHTMLChecks(html) { const { document } = parseHTML(html); const naturalP1 = document.querySelector('article > p:nth-of-type(1)'); expect(naturalP1.textContent).to.equal('This is a inline mark in regular Markdown markup.'); expect(naturalP1.children.length).to.equal(1); const p1 = document.querySelector('article > p:nth-of-type(2)'); expect(p1.id).to.equal('p1'); expect(p1.textContent).to.equal('This is a inline mark under some HTML'); expect(p1.children.length).to.equal(1); assertInlineMark(p1.children[0]); const div1p1 = document.querySelector('article > #div1 > p:nth-of-type(1)'); expect(div1p1.id).to.equal('div1-p1'); expect(div1p1.textContent).to.equal('This is a inline mark under some HTML'); expect(div1p1.children.length).to.equal(1); assertInlineMark(div1p1.children[0]); const div1p2 = document.querySelector('article > #div1 > p:nth-of-type(2)'); expect(div1p2.id).to.equal('div1-p2'); expect(div1p2.textContent).to.equal('This is a inline mark under some HTML'); expect(div1p2.children.length).to.equal(1); const div1p2span1 = div1p2.querySelector('span'); expect(div1p2span1.id).to.equal('div1-p2-span1'); expect(div1p2span1.textContent).to.equal('inline mark'); expect(div1p2span1.children.length).to.equal(1); assertInlineMark(div1p2span1.children[0]); const aside1 = document.querySelector('article > aside:nth-of-type(1)'); const aside1Title = aside1.querySelector('p.title'); expect(aside1Title.textContent.trim()).to.equal('Aside One'); const aside1Section = aside1.querySelector('section'); const aside1SectionP1 = aside1Section.querySelector('p:nth-of-type(1)'); expect(aside1SectionP1.textContent).to.equal( "I'm a Markdown paragraph inside an top-level aside tag" ); const aside1H2_1 = aside1Section.querySelector('h2:nth-of-type(1)'); expect(aside1H2_1.id).to.equal('im-an-h2-via-markdown-markup'); // automatic slug expect(aside1H2_1.textContent).to.equal("I'm an H2 via Markdown markup"); const aside1H2_2 = aside1Section.querySelector('h2:nth-of-type(2)'); expect(aside1H2_2.id).to.equal('h-two'); expect(aside1H2_2.textContent).to.equal("I'm an H2 via HTML markup"); const aside1SectionP2 = aside1Section.querySelector('p:nth-of-type(2)'); expect(aside1SectionP2.textContent).to.equal('Markdown bold vs HTML bold'); expect(aside1SectionP2.children.length).to.equal(2); const aside1SectionP2Strong1 = aside1SectionP2.querySelector('strong:nth-of-type(1)'); expect(aside1SectionP2Strong1.textContent).to.equal('Markdown bold'); const aside1SectionP2Strong2 = aside1SectionP2.querySelector('strong:nth-of-type(2)'); expect(aside1SectionP2Strong2.textContent).to.equal('HTML bold'); const article = document.querySelector('article'); expect(article.textContent).to.contain('RENDERED'); expect(article.textContent).to.not.contain('NOT RENDERED'); const section1 = document.querySelector('article > #section1'); const section1div1 = section1.querySelector('#div1'); const section1Aside1 = section1div1.querySelector('aside:nth-of-type(1)'); const section1Aside1Title = section1Aside1.querySelector('p.title'); expect(section1Aside1Title.textContent.trim()).to.equal('Nested un-indented Aside'); const section1Aside1Section = section1Aside1.querySelector('section'); const section1Aside1SectionP1 = section1Aside1Section.querySelector('p:nth-of-type(1)'); expect(section1Aside1SectionP1.textContent).to.equal('regular Markdown markup'); const section1Aside1SectionP4 = section1Aside1Section.querySelector('p:nth-of-type(2)'); expect(section1Aside1SectionP4.textContent).to.equal('nested inline mark content'); expect(section1Aside1SectionP4.children.length).to.equal(1); assertInlineMark(section1Aside1SectionP4.children[0]); const section1div2 = section1.querySelector('#div2'); const section1Aside2 = section1div2.querySelector('aside:nth-of-type(1)'); const section1Aside2Title = section1Aside2.querySelector('p.title'); expect(section1Aside2Title.textContent.trim()).to.equal('Nested indented Aside 💀'); const section1Aside2Section = section1Aside2.querySelector('section'); const section1Aside2SectionP1 = section1Aside2Section.querySelector('p:nth-of-type(1)'); expect(section1Aside2SectionP1.textContent).to.equal('regular Markdown markup'); const section1Aside1SectionP5 = section1Aside2Section.querySelector('p:nth-of-type(2)'); expect(section1Aside1SectionP5.id).to.equal('p5'); expect(section1Aside1SectionP5.children.length).to.equal(1); const section1Aside1SectionP5Span1 = section1Aside1SectionP5.children[0]; expect(section1Aside1SectionP5Span1.textContent).to.equal('inline mark'); expect(section1Aside1SectionP5Span1.children.length).to.equal(1); const section1Aside1SectionP5Span1Span1 = section1Aside1SectionP5Span1.children[0]; expect(section1Aside1SectionP5Span1Span1.textContent).to.equal(' mark'); } /** @param {HTMLElement | null | undefined} el */ function assertInlineMark(el) { expect(el).to.not.be.null; expect(el).to.not.be.undefined; expect(el.children.length).to.equal(0); expect(el.textContent).to.equal('inline mark'); expect(el.className).to.equal('mark'); expect(el.style.color).to.equal('hotpink'); } selected='selected'>fix-s-island-fallback Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/smoke/astro.build-main/update-contributors.mjs (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-03-01[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-28update ci branch nameGravatar Fred K. Schott 1-0/+2
2022-02-28Make smoke tests more deterministic (#2618)Gravatar Fred K. Schott 336-147/+34315
2022-02-28[ci] yarn formatGravatar natemoo-re 1-20/+20
2022-02-28[ci] release (#2683)astro@0.23.3Gravatar github-actions[bot] 31-54/+55
2022-02-28Fix typo (#2674)Gravatar Robin Millette 1-1/+1
2022-02-28[ci] update lockfile (#2676)Gravatar Fred K. Schott 1-6/+6
2022-02-28fix(runtime): do not render empty Fragment (#2667)Gravatar Mateus Esdras 1-0/+3
2022-02-28fix(hmr): HMR regression related to .astro updates (#2681)Gravatar Nate Moore 6-7/+24
2022-02-28Fix HTMLElement expression warning (#2675)Gravatar Jonathan Neal 1-1/+1
2022-02-28[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-27[ci] update lockfile (#2668)Gravatar Fred K. Schott 1-80/+80
2022-02-27[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-26[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-25[ci] yarn formatGravatar natemoo-re 1-20/+20
2022-02-25[ci] release (#2666)astro@0.23.2Gravatar github-actions[bot] 32-59/+57
2022-02-25[ci] yarn formatGravatar natemoo-re 2-12/+6
2022-02-25fix astro scoping of "@import" inside of style tags (#2656)Gravatar Fred K. Schott 3-6/+35
2022-02-25[ci] update lockfile (#2659)Gravatar Fred K. Schott 1-20/+20
2022-02-25feat: improve third-party Astro package compatability (#2665)Gravatar Nate Moore 3-6/+100
2022-02-25get new example working during buildGravatar Fred K. Schott 4-16/+21
2022-02-25[ci] yarn formatGravatar FredKSchott 1-7/+6
2022-02-25Add Non-HTML Pages example (#2637)Gravatar Joel Kuzmarski 11-0/+136
2022-02-25[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-24[ci] yarn formatGravatar natemoo-re 2-24/+24
2022-02-24[ci] release (#2641)astro@0.23.1@astrojs/markdown-remark@0.6.2Gravatar github-actions[bot] 38-90/+81
2022-02-24ensure utf8 encoding when serving html (#2654)Gravatar Fred K. Schott 3-4/+9
2022-02-24fix(core): Issue #2625. error with process.env.LANG larger than 5 (#2645)Gravatar Javier Cortés 2-1/+6
2022-02-24[ci] update lockfile (#2646)Gravatar Fred K. Schott 1-130/+124
2022-02-24chore: upgrade compiler (#2653)Gravatar Nate Moore 3-11/+11
2022-02-24[ci] yarn formatGravatar natemoo-re 2-5/+5
2022-02-24Add fine-grained HMR support (#2649)Gravatar Nate Moore 7-36/+37
2022-02-24[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-23Fixed incorrect types and imports (#2630)Gravatar Juan Martín Seery 27-35/+37
2022-02-23Add sass dev dep to blog-multiple-authors example (#2643)Gravatar Joel Kuzmarski 1-1/+2
2022-02-23Fix(component): align starting position in Markdown slot (#2631)Gravatar Shinobu Hayashi 4-6/+61
2022-02-23[ci] yarn formatGravatar matthewp 1-1/+1
2022-02-23Run all smoke tests with the static build (#2609)Gravatar Matthew Phillips 2-26/+32
2022-02-23[ci] collect statsGravatar FredKSchott 1-0/+1
2022-02-22[ci] update lockfile (#2624)Gravatar Fred K. Schott 1-171/+201
2022-02-22Fixed shiki import to work with "type": "module" (#2628)Gravatar Juan Martín Seery 3-5/+13