fix: search on homepage test (#1398)

* fix: ci build

* reset

* test

* update

* fix test

* fix

* Add multi-page search test

* rename

Co-authored-by: John Hildenbiddle <jhildenbiddle@users.noreply.github.com>
This commit is contained in:
沈唁 2020-10-15 17:41:21 +08:00 committed by GitHub
parent c9d4f7abc9
commit ee550d0c51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 16 deletions

38
test/e2e/search.test.js Normal file
View File

@ -0,0 +1,38 @@
const docsifyInit = require('../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: `
- [Home page](/)
- [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');
});
});

View File

@ -1,16 +0,0 @@
const docsifyInit = require('../helpers/docsify-init');
// Suite
// -----------------------------------------------------------------------------
describe('Sidebar Tests', function() {
// Tests
// ---------------------------------------------------------------------------
test('search readme', async () => {
await docsifyInit();
await page.goto(DOCS_URL + '/#/quickstart');
await page.fill('input[type=search]', 'Please consider donating');
expect(
await page.innerText('.results-panel > .matching-post > a > h2')
).toEqual('Donate');
});
});