mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
- Refactor methods names and functionality - Replace scroll listeners with observers - Replace Tweezer-based scrolling with native scroll methods - Remove tweezer.js dependency - Remove redundant method calls - Rename $resetEvents to onNavigate - Rename __scrollActiveSidebar to onRender - Remove __getAndActive - Remove __sticky - Add IntersectionObserver mock to Jest environment Also included: - Add e2e test “ui” and “chromium” scripts - Rename "jest" script to "test:jest" - Remove unused SSR code --------- Co-authored-by: Koy Zhuang <koy@ko8e24.top>
72 lines
2.0 KiB
JavaScript
72 lines
2.0 KiB
JavaScript
import docsifyInit from '../helpers/docsify-init.js';
|
|
import { test, expect } from './fixtures/docsify-init-fixture.js';
|
|
|
|
// Suite
|
|
// -----------------------------------------------------------------------------
|
|
test.describe('Sidebar Tests', () => {
|
|
// Tests
|
|
// ---------------------------------------------------------------------------
|
|
test('Active Test', async ({ page }) => {
|
|
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 activeLinkElm = page.locator('.sidebar-nav li[class=active]');
|
|
|
|
await docsifyInit(docsifyInitConfig);
|
|
|
|
await page.click('a[href="#/test"]');
|
|
await expect(activeLinkElm).toHaveText('Test');
|
|
expect(page.url()).toMatch(/\/test$/);
|
|
|
|
await page.click('a[href="#/test%20space"]');
|
|
await expect(activeLinkElm).toHaveText('Test Space');
|
|
expect(page.url()).toMatch(/\/test%20space$/);
|
|
|
|
await page.click('a[href="#/test_foo"]');
|
|
await expect(activeLinkElm).toHaveText('Test _');
|
|
expect(page.url()).toMatch(/\/test_foo$/);
|
|
|
|
await page.click('a[href="#/test-foo"]');
|
|
await expect(activeLinkElm).toHaveText('Test -');
|
|
expect(page.url()).toMatch(/\/test-foo$/);
|
|
|
|
await page.click('a[href="#/test.foo"]');
|
|
await expect(activeLinkElm).toHaveText('Test .');
|
|
expect(page.url()).toMatch(/\/test.foo$/);
|
|
|
|
await page.click('a[href="#/test>foo"]');
|
|
await expect(activeLinkElm).toHaveText('Test >');
|
|
expect(page.url()).toMatch(/\/test%3Efoo$/);
|
|
});
|
|
});
|