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:
Sébastien Lorber 2020-12-28 19:50:12 +01:00 committed by GitHub
parent 863a4d85d3
commit 141d062c3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 189 additions and 131 deletions

View file

@ -65,7 +65,7 @@ describe('loadBlog', () => {
'https://github.com/facebook/docusaurus/edit/master/website-1x/blog/date-matter.md',
permalink: '/blog/date-matter',
readingTime: 0.02,
source: path.join('@site', pluginPath, 'date-matter.md'),
source: path.posix.join('@site', pluginPath, 'date-matter.md'),
title: 'date-matter',
description: `date inside front matter`,
date: new Date('2019-01-01'),
@ -87,10 +87,10 @@ describe('loadBlog', () => {
'https://github.com/facebook/docusaurus/edit/master/website-1x/i18n/en/docusaurus-plugin-content-blog/2018-12-14-Happy-First-Birthday-Slash.md',
permalink: '/blog/2018/12/14/Happy-First-Birthday-Slash',
readingTime: 0.015,
source: path.join(
source: path.posix.join(
'@site',
// pluginPath,
path.join('i18n', 'en', 'docusaurus-plugin-content-blog'),
path.posix.join('i18n', 'en', 'docusaurus-plugin-content-blog'),
'2018-12-14-Happy-First-Birthday-Slash.md',
),
title: 'Happy 1st Birthday Slash! (translated)',
@ -112,7 +112,7 @@ describe('loadBlog', () => {
'https://github.com/facebook/docusaurus/edit/master/website-1x/blog/complex-slug.md',
permalink: '/blog/hey/my super path/héllô',
readingTime: 0.015,
source: path.join('@site', pluginPath, 'complex-slug.md'),
source: path.posix.join('@site', pluginPath, 'complex-slug.md'),
title: 'Complex Slug',
description: `complex url slug`,
prevItem: undefined,
@ -133,7 +133,7 @@ describe('loadBlog', () => {
'https://github.com/facebook/docusaurus/edit/master/website-1x/blog/simple-slug.md',
permalink: '/blog/simple/slug',
readingTime: 0.015,
source: path.join('@site', pluginPath, 'simple-slug.md'),
source: path.posix.join('@site', pluginPath, 'simple-slug.md'),
title: 'Simple Slug',
description: `simple url slug`,
prevItem: undefined,
@ -162,7 +162,7 @@ describe('loadBlog', () => {
'website-blog-without-date',
);
const blogPosts = await getBlogPosts(siteDir);
const noDateSource = path.join('@site', pluginPath, 'no date.md');
const noDateSource = path.posix.join('@site', pluginPath, 'no date.md');
const noDateSourceBirthTime = (
await fs.stat(noDateSource.replace('@site', siteDir))
).birthtime;

View file

@ -21,7 +21,7 @@ const blogPosts: BlogPost[] = [
id: 'Happy 1st Birthday Slash!',
metadata: {
permalink: '/blog/2018/12/14/Happy-First-Birthday-Slash',
source: path.join(
source: path.posix.join(
'@site',
pluginDir,
'2018-12-14-Happy-First-Birthday-Slash.md',

View file

@ -9,6 +9,7 @@ import fs from 'fs-extra';
import globby from 'globby';
import chalk from 'chalk';
import path from 'path';
import {resolve} from 'url';
import readingTime from 'reading-time';
import {Feed} from 'feed';
import {
@ -240,13 +241,18 @@ export function linkify({
while (mdMatch !== null) {
const mdLink = mdMatch[1];
const aliasedPostSource = `@site/${path.relative(
siteDir,
path.resolve(folderPath, mdLink),
)}`;
const aliasedSource = (source: string) =>
aliasedSitePath(source, siteDir);
const blogPost: BlogPost | undefined =
blogPostsBySource[aliasedPostSource];
blogPostsBySource[aliasedSource(resolve(filePath, mdLink))] ||
blogPostsBySource[
aliasedSource(`${contentPaths.contentPathLocalized}/${mdLink}`)
] ||
blogPostsBySource[
aliasedSource(`${contentPaths.contentPath}/${mdLink}`)
];
if (blogPost) {
modifiedLine = modifiedLine.replace(

View file

@ -14,6 +14,7 @@ import {
aliasedSitePath,
getPluginI18nPath,
reportMessage,
posixPath,
} from '@docusaurus/utils';
import {
STATIC_DIR_NAME,
@ -84,7 +85,7 @@ export default function pluginContentBlog(
);
const dataDir = path.join(pluginDataDirRoot, pluginId);
const aliasedSource = (source: string) =>
`~blog/${path.relative(pluginDataDirRoot, source)}`;
`~blog/${posixPath(path.relative(pluginDataDirRoot, source))}`;
let blogPosts: BlogPost[] = [];