From 25bc9b7eb7e878a6a50ed5f91d33d6a75f9811b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Wed, 14 Oct 2020 12:39:56 +0800 Subject: [PATCH] fix: Can't search homepage content (#1391) * fix: Can't search homepage content * fix: when pathNamespaces does not exist * add test * update test to fix windows ci --- src/plugins/search/search.js | 3 +++ test/e2e/sidebar.test.js | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 test/e2e/sidebar.test.js diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 18fb88ea4..5c7f38bca 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -226,6 +226,9 @@ export function init(config, vm) { namespaceSuffix = matches[0]; } } + paths.unshift(namespaceSuffix + '/'); + } else { + paths.unshift('/'); } const expireKey = resolveExpireKey(config.namespace) + namespaceSuffix; diff --git a/test/e2e/sidebar.test.js b/test/e2e/sidebar.test.js new file mode 100644 index 000000000..3b58bdf5a --- /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]', 'Please consider donating'); + expect( + await page.innerText('.results-panel > .matching-post > a > h2') + ).toEqual('Donate'); + }); +});