mirror of
https://github.com/docsifyjs/docsify.git
synced 2026-01-25 15:23:21 +00:00
Playwright had some in-range breaking changes (regressions): https://github.com/microsoft/playwright/issues/10819 and https://github.com/microsoft/playwright/issues/11570 Playwright tests need to `await onceRendered()` after each route navigation to wait for render to finish before testing the state of the rendered DOM. Tests were flaky because they were looking for DOM before render finished (sometimes). Additionally, this fixes one test that was failing only locally, but not in CI, due to a RegExp check against page.url() (not sure why it would differ on CI vs local, but now the URL is explicit).
78 lines
2.2 KiB
JavaScript
78 lines
2.2 KiB
JavaScript
const docsifyInit = require('../helpers/docsify-init');
|
|
|
|
// Suite
|
|
// -----------------------------------------------------------------------------
|
|
describe('Sidebar Tests', function() {
|
|
// Tests
|
|
// ---------------------------------------------------------------------------
|
|
test('Active Test', async () => {
|
|
const docsifyInitConfig = {
|
|
markdown: {
|
|
sidebar: `
|
|
- [Test Space](test%20space)
|
|
- [Test _](test_foo)
|
|
- [Test -](test-foo)
|
|
- [Test .](test.foo)
|
|
- [Test >](test>foo)
|
|
- [Test](test)
|
|
`,
|
|
},
|
|
routes: {
|
|
'/test space.md': `
|
|
# Test Space
|
|
`,
|
|
'/test_foo.md': `
|
|
# Test _
|
|
`,
|
|
'/test-foo.md': `
|
|
# Test -
|
|
`,
|
|
'/test.foo.md': `
|
|
# Test .
|
|
`,
|
|
'/test>foo.md': `
|
|
# Test >
|
|
`,
|
|
'/test.md': `
|
|
# Test page
|
|
`,
|
|
},
|
|
};
|
|
|
|
const onceRendered = await docsifyInit(docsifyInitConfig);
|
|
|
|
await page.click('a[href="#/test%20space"]');
|
|
await onceRendered();
|
|
await expect(page).toMatchText(
|
|
'.sidebar-nav li[class=active]',
|
|
'Test Space'
|
|
);
|
|
expect(page.url()).toMatch(/\/test%20space$/);
|
|
|
|
await page.click('a[href="#/test_foo"]');
|
|
await onceRendered();
|
|
await expect(page).toMatchText('.sidebar-nav li[class=active]', 'Test _');
|
|
expect(page.url()).toMatch(/\/test_foo$/);
|
|
|
|
await page.click('a[href="#/test-foo"]');
|
|
await onceRendered();
|
|
await expect(page).toMatchText('.sidebar-nav li[class=active]', 'Test -');
|
|
expect(page.url()).toMatch(/\/test-foo$/);
|
|
|
|
await page.click('a[href="#/test.foo"]');
|
|
await onceRendered();
|
|
await expect(page).toMatchText('.sidebar-nav li[class=active]', 'Test .');
|
|
expect(page.url()).toMatch(/\/test.foo$/);
|
|
|
|
await page.click('a[href="#/test>foo"]');
|
|
await onceRendered();
|
|
await expect(page).toMatchText('.sidebar-nav li[class=active]', 'Test >');
|
|
expect(page.url()).toMatch(/\/test%3Efoo$/);
|
|
|
|
await page.click('a[href="#/test"]');
|
|
await onceRendered();
|
|
await expect(page).toMatchText('.sidebar-nav li[class=active]', 'Test');
|
|
expect(page.url()).toMatch(/\/test$/);
|
|
});
|
|
});
|