From 10b3a4ed2dec42053f0068a041a1f2756a8322d2 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Mon, 12 Oct 2020 16:10:00 +0800 Subject: [PATCH 1/4] fix: Can't search homepage content --- src/plugins/search/search.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 18fb88ea4..6bdcb8271 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -226,6 +226,7 @@ export function init(config, vm) { namespaceSuffix = matches[0]; } } + paths.unshift(namespaceSuffix + '/'); } const expireKey = resolveExpireKey(config.namespace) + namespaceSuffix; From f998ff2969106231310d85b03e8177d3088f9265 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Mon, 12 Oct 2020 16:19:50 +0800 Subject: [PATCH 2/4] fix: when pathNamespaces does not exist --- src/plugins/search/search.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 6bdcb8271..5c7f38bca 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -227,6 +227,8 @@ export function init(config, vm) { } } paths.unshift(namespaceSuffix + '/'); + } else { + paths.unshift('/'); } const expireKey = resolveExpireKey(config.namespace) + namespaceSuffix; From 29e3454049e0f52d9a0fc7d4374c72bd3b9eaa59 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Wed, 14 Oct 2020 10:01:05 +0800 Subject: [PATCH 3/4] add test --- test/e2e/sidebar.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/e2e/sidebar.test.js diff --git a/test/e2e/sidebar.test.js b/test/e2e/sidebar.test.js new file mode 100644 index 000000000..f50d167a1 --- /dev/null +++ b/test/e2e/sidebar.test.js @@ -0,0 +1,16 @@ +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]', 'site generator'); + expect( + await page.innerText('.results-panel > .matching-post > a > h2') + ).toEqual('docsify'); + }); +}); From a7a81d70711cc2a2b33e8705ce76b36a61ab99a3 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Wed, 14 Oct 2020 10:43:59 +0800 Subject: [PATCH 4/4] update test to fix windows ci --- test/e2e/sidebar.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/sidebar.test.js b/test/e2e/sidebar.test.js index f50d167a1..3b58bdf5a 100644 --- a/test/e2e/sidebar.test.js +++ b/test/e2e/sidebar.test.js @@ -8,9 +8,9 @@ describe('Sidebar Tests', function() { test('search readme', async () => { await docsifyInit(); await page.goto(DOCS_URL + '/#/quickstart'); - await page.fill('input[type=search]', 'site generator'); + await page.fill('input[type=search]', 'Please consider donating'); expect( await page.innerText('.results-panel > .matching-post > a > h2') - ).toEqual('docsify'); + ).toEqual('Donate'); }); });