diff --git a/test/e2e/search.test.js b/test/e2e/search.test.js new file mode 100644 index 0000000000..42a3cca2f3 --- /dev/null +++ b/test/e2e/search.test.js @@ -0,0 +1,40 @@ +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 5288dfff3d..0000000000 --- a/test/e2e/sidebar.test.js +++ /dev/null @@ -1,39 +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'); - }); - - test('search ignore title', async () => { - const docsifyInitConfig = { - markdown: { - homepage: ` - # Hello World - - This is the homepage. - - ## Test ignore title - - This is the test ignore title. - `, - }, - scriptURLs: ['/lib/plugins/search.min.js'], - styleURLs: ['/lib/themes/vue.css'], - }; - await docsifyInit(docsifyInitConfig); - await page.fill('input[type=search]', 'Test ignore title'); - expect(await page.innerText('.results-panel h2')).toEqual( - 'Test ignore title' - ); - }); -});