mirror of
https://github.com/docsifyjs/docsify.git
synced 2026-10-17 04:31:18 +08:00
fix: update sidebar anchor activation logic (#2779)
This commit is contained in:
@@ -140,6 +140,44 @@ test.describe('Search Plugin Tests', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('updates the active sidebar anchor after clicking a heading result', async ({
|
||||
page,
|
||||
}) => {
|
||||
const docsifyInitConfig = {
|
||||
config: {
|
||||
subMaxLevel: 2,
|
||||
search: {
|
||||
paths: ['/'],
|
||||
},
|
||||
},
|
||||
markdown: {
|
||||
homepage: `
|
||||
# Home
|
||||
|
||||
## Installation
|
||||
|
||||
Searchable installation content.
|
||||
`,
|
||||
sidebar: '- [Home](/)',
|
||||
},
|
||||
scriptURLs: ['/dist/plugins/search.js'],
|
||||
};
|
||||
|
||||
const searchFieldElm = page.locator('input[type=search]');
|
||||
const resultsHeadingElm = page.locator('.results-panel .title');
|
||||
const installationSidebarItem = page
|
||||
.locator('.sidebar-nav a[href="#/?id=installation"]')
|
||||
.locator('..');
|
||||
|
||||
await docsifyInit(docsifyInitConfig);
|
||||
|
||||
await searchFieldElm.fill('installation');
|
||||
await expect(resultsHeadingElm).toHaveText('Installation');
|
||||
await page.click('.matching-post a');
|
||||
|
||||
await expect(installationSidebarItem).toHaveClass(/active/);
|
||||
});
|
||||
|
||||
test('search ignore title', async ({ page }) => {
|
||||
const docsifyInitConfig = {
|
||||
markdown: {
|
||||
|
||||
Reference in New Issue
Block a user