From ee550d0c51f222851854c7cd7e9e6f76e26eb6f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Thu, 15 Oct 2020 17:41:21 +0800 Subject: [PATCH] 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 --- test/e2e/search.test.js | 38 ++++++++++++++++++++++++++++++++++++++ test/e2e/sidebar.test.js | 16 ---------------- 2 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 test/e2e/search.test.js delete mode 100644 test/e2e/sidebar.test.js diff --git a/test/e2e/search.test.js b/test/e2e/search.test.js new file mode 100644 index 000000000..3866b4250 --- /dev/null +++ b/test/e2e/search.test.js @@ -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'); + }); +}); diff --git a/test/e2e/sidebar.test.js b/test/e2e/sidebar.test.js deleted file mode 100644 index 3b58bdf5a..000000000 --- a/test/e2e/sidebar.test.js +++ /dev/null @@ -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'); - }); -});