fix all docs tests

This commit is contained in:
sebastien 2025-07-04 16:42:52 +02:00
parent 35e676096c
commit f8d1d49a82
2 changed files with 66 additions and 43 deletions

View file

@ -3316,23 +3316,6 @@ exports[`versioned website (community) content: route config 1`] = `
] ]
`; `;
exports[`versioned website (community) getPathToWatch 1`] = `
[
"community_sidebars.json",
"i18n/en/docusaurus-plugin-content-docs-community/current/**/*.{md,mdx}",
"community/**/*.{md,mdx}",
"i18n/en/docusaurus-plugin-content-docs-community/current/tags.yml",
"community/tags.yml",
"community/**/_category_.{json,yml,yaml}",
"community_versioned_sidebars/version-1.0.0-sidebars.json",
"i18n/en/docusaurus-plugin-content-docs-community/version-1.0.0/**/*.{md,mdx}",
"community_versioned_docs/version-1.0.0/**/*.{md,mdx}",
"i18n/en/docusaurus-plugin-content-docs-community/version-1.0.0/tags.yml",
"community_versioned_docs/version-1.0.0/tags.yml",
"community_versioned_docs/version-1.0.0/**/_category_.{json,yml,yaml}",
]
`;
exports[`versioned website content 1`] = ` exports[`versioned website content 1`] = `
{ {
"description": "This is next version of bar.", "description": "This is next version of bar.",

View file

@ -583,6 +583,13 @@ describe('versioned website (community)', () => {
options, options,
plugin, plugin,
pluginContentDir, pluginContentDir,
getPathsToWatch: () => {
const pathToWatch = plugin.getPathsToWatch!();
return pathToWatch.map((filepath) =>
posixPath(path.relative(siteDir, filepath)),
);
},
}; };
} }
@ -599,14 +606,46 @@ describe('versioned website (community)', () => {
mock.mockRestore(); mock.mockRestore();
}); });
it('getPathToWatch', async () => { describe('getPathToWatch', () => {
const {siteDir, plugin} = await loadSite(); it('translate: false', async () => {
const pathToWatch = plugin.getPathsToWatch!(); const {getPathsToWatch} = await loadSite({translate: false});
const matchPattern = pathToWatch.map((filepath) => expect(getPathsToWatch()).toMatchInlineSnapshot(`
posixPath(path.relative(siteDir, filepath)), [
); "community_sidebars.json",
expect(matchPattern).not.toEqual([]); "community/**/*.{md,mdx}",
expect(matchPattern).toMatchSnapshot(); "community/tags.yml",
"community/**/_category_.{json,yml,yaml}",
"community_versioned_sidebars/version-1.0.0-sidebars.json",
"community_versioned_docs/version-1.0.0/**/*.{md,mdx}",
"community_versioned_docs/version-1.0.0/tags.yml",
"community_versioned_docs/version-1.0.0/**/_category_.{json,yml,yaml}",
]
`);
});
it('translate: true', async () => {
const {getPathsToWatch} = await loadSite({translate: true});
expect(getPathsToWatch()).toMatchInlineSnapshot(`
[
"community_sidebars.json",
"i18n/en/docusaurus-plugin-content-docs-community/current/**/*.{md,mdx}",
"community/**/*.{md,mdx}",
"i18n/en/docusaurus-plugin-content-docs-community/current/tags.yml",
"community/tags.yml",
"community/**/_category_.{json,yml,yaml}",
"community_versioned_sidebars/version-1.0.0-sidebars.json",
"i18n/en/docusaurus-plugin-content-docs-community/version-1.0.0/**/*.{md,mdx}",
"community_versioned_docs/version-1.0.0/**/*.{md,mdx}",
"i18n/en/docusaurus-plugin-content-docs-community/version-1.0.0/tags.yml",
"community_versioned_docs/version-1.0.0/tags.yml",
"community_versioned_docs/version-1.0.0/**/_category_.{json,yml,yaml}",
]
`);
});
it('returns patterns matching docs', async () => {
const {getPathsToWatch} = await loadSite();
const matchPattern = getPathsToWatch();
expect(isMatch('community/team.md', matchPattern)).toBe(true); expect(isMatch('community/team.md', matchPattern)).toBe(true);
expect( expect(
isMatch('community_versioned_docs/version-1.0.0/team.md', matchPattern), isMatch('community_versioned_docs/version-1.0.0/team.md', matchPattern),
@ -628,6 +667,7 @@ describe('versioned website (community)', () => {
isMatch('community_versioned_docs/version-1.0.0/team.js', matchPattern), isMatch('community_versioned_docs/version-1.0.0/team.js', matchPattern),
).toBe(false); ).toBe(false);
}); });
});
it('content', async () => { it('content', async () => {
const {plugin, pluginContentDir} = await loadSite(); const {plugin, pluginContentDir} = await loadSite();