From 90cfade88c2b9a34d8a5fe711ce329732d690409 Mon Sep 17 00:00:00 2001 From: Ben Holmes Date: Wed, 3 Apr 2024 16:48:53 -0400 Subject: feat: automatic Markdoc partial resolution (#10649) * wip: react counter example * feat: resolve markdoc partials by file path * test: components within partials * test: html within partial * chore: changeset * fix: respect user configured partials * test: basic partials * chore: lock * chore: fix lock * chore: minor -> patch * fix: use --parallel for dev server timeout error * refactor: move component tests to separate file * fix: build indent fixture * fix: check before addWatchFile * refactor: rootRelative -> relativePartial * deps: use workspace react integration * refactor: split test files by fixture * refactor: switch to preact to avoid react prod build error * feat: use vite pluginContext * fix: handle missing ./ * chore: bump timeout --- .../integrations/markdoc/test/render-html.test.js | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'packages/integrations/markdoc/test/render-html.test.js') diff --git a/packages/integrations/markdoc/test/render-html.test.js b/packages/integrations/markdoc/test/render-html.test.js index 785599ae5..4780444bf 100644 --- a/packages/integrations/markdoc/test/render-html.test.js +++ b/packages/integrations/markdoc/test/render-html.test.js @@ -54,6 +54,13 @@ describe('Markdoc - render html', () => { renderRandomlyCasedHTMLAttributesChecks(html); }); + + it('renders content - html within partials', async () => { + const res = await fixture.fetch('/with-partial'); + const html = await res.text(); + + renderHTMLWithinPartialChecks(html); + }); }); describe('build', () => { @@ -84,6 +91,12 @@ describe('Markdoc - render html', () => { renderRandomlyCasedHTMLAttributesChecks(html); }); + + it('renders content - html within partials', async () => { + const html = await fixture.readFile('/with-partial/index.html'); + + renderHTMLWithinPartialChecks(html); + }); }); }); @@ -186,6 +199,16 @@ function renderRandomlyCasedHTMLAttributesChecks(html) { assert.equal(td4.getAttribute('rowspan'), '2'); } +/** + * @param {string} html + */ +function renderHTMLWithinPartialChecks(html) { + const { document } = parseHTML(html); + + const li = document.querySelector('ul > li#partial'); + assert.equal(li.textContent, 'List item'); +} + /** * Asserts that the rendered HTML tags with interleaved Markdoc tags (both block and inline) rendered in the expected nested graph of elemements * -- cgit v1.2.3