mirror of
https://github.com/docsifyjs/docsify.git
synced 2026-10-27 02:29:58 +08:00
* develop: (104 commits) chore: bump ssri from 6.0.1 to 6.0.2 (#1563) chore: Update Edit Document using develop branch (#1541) fix: Add escapeHtml for search (#1551) docs: link with plugin Pagination (#1554) fix: Upgrade dompurify from 2.2.6 to 2.2.7 (#1553) fix: upgrade dompurify from 2.2.6 to 2.2.7 (#1552) chore: bump y18n from 4.0.0 to 4.0.1 (#1548) chore: Fix search for missing pathNamespaces (#1547) fix: Upgrade docsify from 4.12.0 to 4.12.1 (#1544) docs:Update deploy, change Zeit to Vercel (#1540) fix: Cannot read property 'classList' of null (#1527) chore: fix microsoft/playwright-github-action error (#1534) Update PULL_REQUEST_TEMPLATE.md chore: Update CHANGELOG and Update test snapshots chore: add changelog 4.12.1 [build] 4.12.1 feat: Support search when there is no title (#1519) test(unit): add test cases on isExternal. (#1515) docs: Update Vercel logo link (#1520) fix: Upgrade docsify from 4.11.6 to 4.12.0 (#1518) ...
160 lines
4.9 KiB
JavaScript
160 lines
4.9 KiB
JavaScript
import docsifyInit from '../helpers/docsify-init';
|
|
|
|
// Suite
|
|
// -----------------------------------------------------------------------------
|
|
describe('Search Plugin Tests', function () {
|
|
// Tests
|
|
// ---------------------------------------------------------------------------
|
|
test('search readme', async () => {
|
|
const docsifyInitConfig = {
|
|
markdown: {
|
|
homepage: `
|
|
# Hello World
|
|
|
|
This is the homepage.
|
|
`,
|
|
sidebar: `
|
|
- [Test Page](test)
|
|
`,
|
|
},
|
|
routes: {
|
|
'/test.md': `
|
|
# Test Page
|
|
|
|
This is a custom route.
|
|
`,
|
|
},
|
|
scriptURLs: ['/lib/plugins/search.min.js'],
|
|
};
|
|
|
|
await docsifyInit(docsifyInitConfig);
|
|
await page.fill('input[type=search]', 'hello');
|
|
await expect(page).toEqualText('.results-panel h2', 'Hello World');
|
|
await page.click('.clear-button');
|
|
await page.fill('input[type=search]', 'test');
|
|
await expect(page).toEqualText('.results-panel h2', 'Test Page');
|
|
});
|
|
|
|
test('search ignore title', async () => {
|
|
const docsifyInitConfig = {
|
|
markdown: {
|
|
homepage: `
|
|
# Hello World
|
|
|
|
This is the homepage.
|
|
`,
|
|
sidebar: `
|
|
- [Home page](/)
|
|
- [GitHub Pages](github)
|
|
`,
|
|
},
|
|
routes: {
|
|
'/github.md': `
|
|
# GitHub Pages
|
|
|
|
This is the GitHub Pages.
|
|
|
|
## GitHub Pages ignore1 <!-- {docsify-ignore} -->
|
|
|
|
There're three places to populate your docs for your Github repository1.
|
|
|
|
## GitHub Pages ignore2 {docsify-ignore}
|
|
|
|
There're three places to populate your docs for your Github repository2.
|
|
`,
|
|
},
|
|
scriptURLs: ['/lib/plugins/search.min.js'],
|
|
};
|
|
await docsifyInit(docsifyInitConfig);
|
|
await page.fill('input[type=search]', 'repository1');
|
|
await expect(page).toEqualText('.results-panel h2', 'GitHub Pages ignore1');
|
|
await page.click('.clear-button');
|
|
await page.fill('input[type=search]', 'repository2');
|
|
await expect(page).toEqualText('.results-panel h2', 'GitHub Pages ignore2');
|
|
});
|
|
|
|
test('search only one homepage', async () => {
|
|
const docsifyInitConfig = {
|
|
markdown: {
|
|
sidebar: `
|
|
- [README](README)
|
|
- [Test Page](test)
|
|
`,
|
|
},
|
|
routes: {
|
|
'/README.md': `
|
|
# Hello World
|
|
|
|
This is the homepage.
|
|
`,
|
|
'/test.md': `
|
|
# Test Page
|
|
|
|
This is a custom route.
|
|
`,
|
|
},
|
|
scriptURLs: ['/lib/plugins/search.js'],
|
|
};
|
|
|
|
await docsifyInit(docsifyInitConfig);
|
|
await page.fill('input[type=search]', 'hello');
|
|
await expect(page).toHaveSelector('.matching-post');
|
|
expect(await page.$$eval('.matching-post', elms => elms.length)).toBe(1);
|
|
await expect(page).toEqualText('.results-panel h2', 'Hello World');
|
|
await page.click('.clear-button');
|
|
await page.fill('input[type=search]', 'test');
|
|
await expect(page).toEqualText('.results-panel h2', 'Test Page');
|
|
});
|
|
|
|
test('search ignore diacritical marks', async () => {
|
|
const docsifyInitConfig = {
|
|
markdown: {
|
|
homepage: `
|
|
# Qué es
|
|
|
|
docsify genera su sitio web de documentación sobre la marcha. A diferencia de GitBook, no genera archivos estáticos html. En cambio, carga y analiza de forma inteligente sus archivos de Markdown y los muestra como sitio web. Todo lo que necesita hacer es crear un index.html para comenzar y desplegarlo en GitHub Pages.
|
|
`,
|
|
},
|
|
scriptURLs: ['/lib/plugins/search.min.js'],
|
|
};
|
|
await docsifyInit(docsifyInitConfig);
|
|
await page.fill('input[type=search]', 'documentacion');
|
|
await expect(page).toEqualText('.results-panel h2', 'Que es');
|
|
await page.click('.clear-button');
|
|
await page.fill('input[type=search]', 'estáticos');
|
|
await expect(page).toEqualText('.results-panel h2', 'Que es');
|
|
});
|
|
|
|
test('search when there is no title', async () => {
|
|
const docsifyInitConfig = {
|
|
markdown: {
|
|
homepage: `
|
|
This is some description. We assume autoHeader added the # Title. A long paragraph.
|
|
`,
|
|
sidebar: `
|
|
- [Changelog](changelog)
|
|
`,
|
|
},
|
|
routes: {
|
|
'/changelog.md': `
|
|
feat: Support search when there is no title
|
|
|
|
## Changelog Title
|
|
|
|
hello, this is a changelog
|
|
`,
|
|
},
|
|
scriptURLs: ['/lib/plugins/search.min.js'],
|
|
};
|
|
await docsifyInit(docsifyInitConfig);
|
|
await page.fill('input[type=search]', 'paragraph');
|
|
await expect(page).toEqualText('.results-panel h2', 'Home Page');
|
|
await page.click('.clear-button');
|
|
await page.fill('input[type=search]', 'Support');
|
|
await expect(page).toEqualText('.results-panel h2', 'changelog');
|
|
await page.click('.clear-button');
|
|
await page.fill('input[type=search]', 'hello');
|
|
await expect(page).toEqualText('.results-panel h2', 'Changelog Title');
|
|
});
|
|
});
|