This is an automated email from the ASF dual-hosted git repository. imbajin pushed a commit to branch feat/oink-core-platform in repository https://gitbox.apache.org/repos/asf/hugegraph-doc.git
commit df68fb58ec9681590370717098998c32056c7b09 Author: dark <[email protected]> AuthorDate: Fri Sep 4 20:59:06 2026 +0800 test(e2e): stabilize integrated contracts - silence fixture server logs without hiding test failures - persist a non-active top-level sidebar disclosure - resolve expected search titles from the built index - click real palette rows while asserting top-three ranking --- tests/e2e/platform.spec.js | 4 +++- tests/e2e/playwright.config.js | 8 ++++++-- tests/e2e/search-ranking.spec.js | 40 +++++++++++++++++++++++++++------------- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/tests/e2e/platform.spec.js b/tests/e2e/platform.spec.js index 40262dbb5..38299c75f 100644 --- a/tests/e2e/platform.spec.js +++ b/tests/e2e/platform.spec.js @@ -5,7 +5,9 @@ for (const locale of ["en", "cn"]) { test(`latest ${locale} sidebar persists and isolates collapse`, async ({ page }) => { await page.goto(`${prefix}/docs/introduction/`); const toggle = page - .locator("#td-shell-sidebar li [data-td-shell-tree-toggle][aria-expanded=false]") + .locator( + '#td-shell-sidebar li [data-td-shell-tree-toggle][aria-expanded=false][aria-controls*="_nav"]' + ) .first(); await toggle.click(); const target = await toggle.getAttribute("aria-controls"); diff --git a/tests/e2e/playwright.config.js b/tests/e2e/playwright.config.js index 63cd092d0..7eef0aceb 100644 --- a/tests/e2e/playwright.config.js +++ b/tests/e2e/playwright.config.js @@ -26,14 +26,18 @@ module.exports = defineConfig({ command: `python3 -m http.server 4173 --bind 127.0.0.1 --directory ${JSON.stringify(siteRoot)}`, url: "http://127.0.0.1:4173/", reuseExistingServer: false, - timeout: 30_000 + timeout: 30_000, + stdout: "ignore", + stderr: "ignore" }, ...(aiSiteRoot ? [{ command: `python3 -m http.server 4174 --bind 127.0.0.1 --directory ${JSON.stringify(aiSiteRoot)}`, url: "http://127.0.0.1:4174/", reuseExistingServer: false, - timeout: 30_000 + timeout: 30_000, + stdout: "ignore", + stderr: "ignore" }] : []) ] diff --git a/tests/e2e/search-ranking.spec.js b/tests/e2e/search-ranking.spec.js index 52ffa6a5d..75a0d4dd8 100644 --- a/tests/e2e/search-ranking.spec.js +++ b/tests/e2e/search-ranking.spec.js @@ -34,7 +34,8 @@ const FALLBACK_CASES = { }; const metadataFixture = path.resolve(__dirname, "../../scripts/fixtures/community_search_queries.json"); -const cases = fs.existsSync(metadataFixture) +const siteRoot = process.env.SITE_ROOT; +const rawCases = fs.existsSync(metadataFixture) ? Object.groupBy( JSON.parse(fs.readFileSync(metadataFixture, "utf8")).map((entry) => [ entry.query, @@ -43,10 +44,28 @@ const cases = fs.existsSync(metadataFixture) ([query, expectedRef]) => (expectedRef.startsWith("/cn/") ? "cn" : "en") ) : FALLBACK_CASES; +const cases = Object.fromEntries( + Object.entries(rawCases).map(([locale, localeCases]) => { + const indexName = fs + .readdirSync(siteRoot) + .find((name) => name.startsWith(`offline-search-index.${locale}.`) && name.endsWith(".json")); + if (!indexName) throw new Error(`missing ${locale} offline search index`); + const records = JSON.parse(fs.readFileSync(path.join(siteRoot, indexName), "utf8")); + const titles = new Map(records.map((record) => [record.ref, record.title])); + return [ + locale, + localeCases.map(([query, expectedRef]) => { + const expectedTitle = titles.get(expectedRef); + if (!expectedTitle) throw new Error(`missing search record ${expectedRef}`); + return [query, expectedRef, expectedTitle]; + }) + ]; + }) +); for (const [locale, localeCases] of Object.entries(cases)) { test(`summary Lunr ranks fixed ${locale} entry queries`, async ({ page }) => { - for (const [query, expectedRef] of localeCases) { + for (const [query, expectedRef, expectedTitle] of localeCases) { await page.goto(locale === "cn" ? "/cn/docs/" : "/docs/"); await page.locator("[data-td-shell-search-open]").first().click(); const input = page.locator(".td-shell-search__input"); @@ -56,21 +75,16 @@ for (const [locale, localeCases] of Object.entries(cases)) { .first() .locator('[role="option"]'); await expect(pageResults.first(), `no Lunr results for ${query}`).toBeVisible(); - const paths = await pageResults.evaluateAll((rows) => - rows.slice(0, 3).map((row) => { - const link = row.matches("a[href]") ? row : row.querySelector("a[href]"); - return link ? new URL(link.href).pathname : ""; - }) + const titles = await pageResults.evaluateAll((rows) => + rows + .slice(0, 3) + .map((row) => row.querySelector(".td-shell-search__item-title")?.textContent.trim()) ); expect( - paths.includes(expectedRef), + titles.includes(expectedTitle), `${query} must rank ${expectedRef} in the top three` ).toBe(true); - const target = page - .locator("#td-shell-search-results .td-shell-search__group") - .first() - .locator(`a[role="option"][href="${expectedRef}"]`) - .first(); + const target = pageResults.filter({ hasText: expectedTitle }).first(); await target.click(); await expect(page).toHaveURL((url) => url.pathname === expectedRef); }
