mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-23 14:06:59 +02:00
chore(v2): fix windows Jest tests (#3959)
* test(v2): Fix docusaurus-utils tests for windows * test(v2): Fix plugin-client-redirects test - add the posixPath in writeRedirectsFiles.ts * test(v2): Fix plugin-content-pages test add posixPath in test and index * test(v2): add window test configuration - add the window test configuration in nodejs-windows.yml * test(v2): revert plugin-content-pages test fix * test(v2): Fix mdx-loader/transformImage test * test(v2): add cleanPath in transformImage test * fix version path tests for windows * make versionMetadata test work on Windows * try to fix posix/win32 path issues * attempt to fix windows test * try to make source alias less win32 sensitive * try to make source alias less win32 sensitive * try to make source alias less win32 sensitive * try to make source alias less win32 sensitive * try to make source alias less win32 sensitive * try to make source alias less win32 sensitive * specific jest config for windows * attempt to fix windows testing issue * attempt to fix windows testing issue * attempt to fix windows testing issue * attempt to fix windows testing issue * attempt to fix windows testing issue * attempt to fix windows testing issue * attempt to fix windows testing issue * remove bad cleanPath fn * try to fix windows tests * try to fix windows tests * blog: try to fix windows tests by using same logic as on docs plugin * try to fix windows tests * try to fix windows tests * try to fix windows tests * try to fix windows tests * improve the Github CI setup for windows: make jobs run in parallel * revert GH action change Co-authored-by: Sachin Kumar Rajput <skr571999@gmail.com>
This commit is contained in:
parent
863a4d85d3
commit
141d062c3b
29 changed files with 189 additions and 131 deletions
|
@ -20,6 +20,7 @@ import {LoadContext} from '@docusaurus/types';
|
|||
import {DEFAULT_PLUGIN_ID} from '@docusaurus/core/lib/constants';
|
||||
import {DEFAULT_OPTIONS} from '../options';
|
||||
import {Optional} from 'utility-types';
|
||||
import {posixPath} from '@docusaurus/utils';
|
||||
|
||||
const fixtureDir = path.join(__dirname, '__fixtures__');
|
||||
|
||||
|
@ -89,10 +90,10 @@ function createTestUtils({
|
|||
lastUpdatedAt: undefined,
|
||||
sidebar_label: undefined,
|
||||
editUrl: undefined,
|
||||
source: path.join(
|
||||
source: path.posix.join(
|
||||
'@site',
|
||||
path.relative(siteDir, versionMetadata.docsDirPath),
|
||||
docFileSource,
|
||||
posixPath(path.relative(siteDir, versionMetadata.docsDirPath)),
|
||||
posixPath(docFileSource),
|
||||
),
|
||||
...expectedMetadata,
|
||||
});
|
||||
|
|
|
@ -140,11 +140,15 @@ describe('empty/no docs website', () => {
|
|||
pluginContentDocs(
|
||||
context,
|
||||
normalizePluginOptions(OptionsSchema, {
|
||||
path: '/path/does/not/exist/',
|
||||
path: `path/doesnt/exist`,
|
||||
}),
|
||||
),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"The docs folder does not exist for version [current]. A docs folder is expected to be found at /path/does/not/exist"`,
|
||||
).toThrowError(
|
||||
`The docs folder does not exist for version [current]. A docs folder is expected to be found at ${
|
||||
process.platform === 'win32'
|
||||
? 'path\\doesnt\\exist'
|
||||
: 'path/doesnt/exist'
|
||||
}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -248,9 +252,9 @@ describe('simple website', () => {
|
|||
permalink: '/docs/foo/bazSlug.html',
|
||||
},
|
||||
sidebar: 'docs',
|
||||
source: path.join(
|
||||
source: path.posix.join(
|
||||
'@site',
|
||||
path.relative(siteDir, currentVersion.docsDirPath),
|
||||
posixPath(path.relative(siteDir, currentVersion.docsDirPath)),
|
||||
'hello.md',
|
||||
),
|
||||
title: 'Hello, World !',
|
||||
|
@ -270,9 +274,9 @@ describe('simple website', () => {
|
|||
permalink: '/docs/foo/bar',
|
||||
slug: '/foo/bar',
|
||||
sidebar: 'docs',
|
||||
source: path.join(
|
||||
source: path.posix.join(
|
||||
'@site',
|
||||
path.relative(siteDir, currentVersion.docsDirPath),
|
||||
posixPath(path.relative(siteDir, currentVersion.docsDirPath)),
|
||||
'foo',
|
||||
'bar.md',
|
||||
),
|
||||
|
@ -418,9 +422,9 @@ describe('versioned website', () => {
|
|||
isDocsHomePage: false,
|
||||
permalink: '/docs/next/foo/barSlug',
|
||||
slug: '/foo/barSlug',
|
||||
source: path.join(
|
||||
source: path.posix.join(
|
||||
'@site',
|
||||
path.relative(siteDir, currentVersion.docsDirPath),
|
||||
posixPath(path.relative(siteDir, currentVersion.docsDirPath)),
|
||||
'foo',
|
||||
'bar.md',
|
||||
),
|
||||
|
@ -440,9 +444,9 @@ describe('versioned website', () => {
|
|||
isDocsHomePage: true,
|
||||
permalink: '/docs/next/',
|
||||
slug: '/',
|
||||
source: path.join(
|
||||
source: path.posix.join(
|
||||
'@site',
|
||||
path.relative(siteDir, currentVersion.docsDirPath),
|
||||
posixPath(path.relative(siteDir, currentVersion.docsDirPath)),
|
||||
'hello.md',
|
||||
),
|
||||
title: 'hello',
|
||||
|
@ -461,9 +465,9 @@ describe('versioned website', () => {
|
|||
isDocsHomePage: true,
|
||||
permalink: '/docs/',
|
||||
slug: '/',
|
||||
source: path.join(
|
||||
source: path.posix.join(
|
||||
'@site',
|
||||
path.relative(siteDir, version101.docsDirPath),
|
||||
posixPath(path.relative(siteDir, version101.docsDirPath)),
|
||||
'hello.md',
|
||||
),
|
||||
title: 'hello',
|
||||
|
@ -482,9 +486,9 @@ describe('versioned website', () => {
|
|||
isDocsHomePage: false,
|
||||
permalink: '/docs/1.0.0/foo/baz',
|
||||
slug: '/foo/baz',
|
||||
source: path.join(
|
||||
source: path.posix.join(
|
||||
'@site',
|
||||
path.relative(siteDir, version100.docsDirPath),
|
||||
posixPath(path.relative(siteDir, version100.docsDirPath)),
|
||||
'foo',
|
||||
'baz.md',
|
||||
),
|
||||
|
@ -629,13 +633,6 @@ describe('versioned website (community)', () => {
|
|||
isDocsHomePage: false,
|
||||
permalink: '/community/next/team',
|
||||
slug: '/team',
|
||||
/*
|
||||
source: path.join(
|
||||
'@site',
|
||||
path.relative(siteDir, currentVersion.docsDirPath),
|
||||
'team.md',
|
||||
),
|
||||
*/
|
||||
source:
|
||||
'@site/i18n/en/docusaurus-plugin-content-docs-community/current/team.md',
|
||||
title: 'Team title translated',
|
||||
|
@ -650,9 +647,9 @@ describe('versioned website (community)', () => {
|
|||
isDocsHomePage: false,
|
||||
permalink: '/community/team',
|
||||
slug: '/team',
|
||||
source: path.join(
|
||||
source: path.posix.join(
|
||||
'@site',
|
||||
path.relative(siteDir, version100.docsDirPath),
|
||||
posixPath(path.relative(siteDir, version100.docsDirPath)),
|
||||
'team.md',
|
||||
),
|
||||
title: 'team',
|
||||
|
|
|
@ -24,30 +24,30 @@ const DefaultI18N: I18n = {
|
|||
};
|
||||
|
||||
describe('version paths', () => {
|
||||
test('getVersionedDocsDirPath', () => {
|
||||
test('getVersionsFilePath', () => {
|
||||
expect(getVersionsFilePath('someSiteDir', DEFAULT_PLUGIN_ID)).toBe(
|
||||
'someSiteDir/versions.json',
|
||||
`someSiteDir${path.sep}versions.json`,
|
||||
);
|
||||
expect(getVersionsFilePath('otherSite/dir', 'pluginId')).toBe(
|
||||
'otherSite/dir/pluginId_versions.json',
|
||||
`otherSite${path.sep}dir${path.sep}pluginId_versions.json`,
|
||||
);
|
||||
});
|
||||
|
||||
test('getVersionedDocsDirPath', () => {
|
||||
expect(getVersionedDocsDirPath('someSiteDir', DEFAULT_PLUGIN_ID)).toBe(
|
||||
'someSiteDir/versioned_docs',
|
||||
`someSiteDir${path.sep}versioned_docs`,
|
||||
);
|
||||
expect(getVersionedDocsDirPath('otherSite/dir', 'pluginId')).toBe(
|
||||
'otherSite/dir/pluginId_versioned_docs',
|
||||
`otherSite${path.sep}dir${path.sep}pluginId_versioned_docs`,
|
||||
);
|
||||
});
|
||||
|
||||
test('getVersionedSidebarsDirPath', () => {
|
||||
expect(getVersionedSidebarsDirPath('someSiteDir', DEFAULT_PLUGIN_ID)).toBe(
|
||||
'someSiteDir/versioned_sidebars',
|
||||
`someSiteDir${path.sep}versioned_sidebars`,
|
||||
);
|
||||
expect(getVersionedSidebarsDirPath('otherSite/dir', 'pluginId')).toBe(
|
||||
'otherSite/dir/pluginId_versioned_sidebars',
|
||||
`otherSite${path.sep}dir${path.sep}pluginId_versioned_sidebars`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue