feat: panneau de facettes repliable + facette Extensions exposee par l'API #157
This commit is contained in:
@@ -143,6 +143,19 @@ test.describe('Full-Text Search', () => {
|
||||
// Not always present — depends on vault content
|
||||
});
|
||||
|
||||
test('should show the extensions facet and collapse the facets panel (#157)', async ({ page }) => {
|
||||
await goHome(page);
|
||||
await searchFor(page, 'test');
|
||||
const extFacet = page.locator('.search-facets__group[data-facet="extensions"]');
|
||||
await expect(extFacet).toBeVisible();
|
||||
await expect(extFacet.locator('.search-facets__item').first()).toBeVisible();
|
||||
// discreet collapse/expand of the whole vaults+tags+extensions section
|
||||
await page.locator('.search-facets__toggle').click();
|
||||
await expect(page.locator('.search-facets__body')).toBeHidden();
|
||||
await page.locator('.search-facets__toggle').click();
|
||||
await expect(page.locator('.search-facets__body')).toBeVisible();
|
||||
});
|
||||
|
||||
test('should navigate results with floating bar arrows', async ({ page }) => {
|
||||
await goHome(page);
|
||||
await searchFor(page, 'test');
|
||||
|
||||
@@ -143,6 +143,35 @@ await test("clicking an extension adds the ext: operator", async () => {
|
||||
);
|
||||
});
|
||||
|
||||
await test("facets panel collapses and restores via the toggle", async () => {
|
||||
localStorage.removeItem("obsigate_facets_collapsed");
|
||||
renderAdvancedSearchResults(PAYLOAD, "python", null);
|
||||
const panel = document.querySelector(".search-facets");
|
||||
const toggle = panel.querySelector(".search-facets__toggle");
|
||||
assert.ok(toggle, "collapse toggle rendered");
|
||||
assert.equal(panel.getAttribute("data-collapsed"), "false", "expanded by default");
|
||||
assert.ok(panel.querySelector(".search-facets__body"), "groups live in the body");
|
||||
|
||||
toggle.click();
|
||||
assert.equal(panel.getAttribute("data-collapsed"), "true", "click collapses");
|
||||
assert.equal(
|
||||
localStorage.getItem("obsigate_facets_collapsed"),
|
||||
"1",
|
||||
"collapsed state persisted",
|
||||
);
|
||||
|
||||
renderAdvancedSearchResults(PAYLOAD, "python", null);
|
||||
const panel2 = document.querySelector(".search-facets");
|
||||
assert.equal(
|
||||
panel2.getAttribute("data-collapsed"),
|
||||
"true",
|
||||
"collapsed state survives a re-render",
|
||||
);
|
||||
panel2.querySelector(".search-facets__toggle").click();
|
||||
assert.equal(panel2.getAttribute("data-collapsed"), "false", "toggle restores");
|
||||
localStorage.removeItem("obsigate_facets_collapsed");
|
||||
});
|
||||
|
||||
// ── Summary ──
|
||||
console.log(`\n${passCount}/${testCount} tests passed`);
|
||||
if (passCount !== testCount) {
|
||||
|
||||
@@ -204,7 +204,7 @@ class TestAdvancedSearchAPI:
|
||||
pytest.skip(f"Advanced search non-JSON response: {resp.text[:200]}")
|
||||
|
||||
def test_basic(self, client):
|
||||
resp = client.get("/api/advanced-search?q=python&vault=all")
|
||||
resp = client.get("/api/search/advanced?q=python&vault=all")
|
||||
data = self._check(resp)
|
||||
assert data["total"] >= 1
|
||||
assert len(data["results"]) > 0
|
||||
@@ -217,16 +217,18 @@ class TestAdvancedSearchAPI:
|
||||
assert "path" in r
|
||||
|
||||
def test_pagination(self, client):
|
||||
resp = client.get("/api/advanced-search?q=python&limit=1&offset=0")
|
||||
resp = client.get("/api/search/advanced?q=python&limit=1&offset=0")
|
||||
data = self._check(resp)
|
||||
assert len(data["results"]) <= 1
|
||||
|
||||
def test_facets(self, client):
|
||||
resp = client.get("/api/advanced-search?q=python&vault=all")
|
||||
data = self._check(resp)
|
||||
resp = client.get("/api/search/advanced?q=python&vault=all")
|
||||
# Hard assertion: the facet contract must hold through the response_model
|
||||
# (regression #157: `extensions` used to be stripped by SearchFacets).
|
||||
assert resp.status_code == 200, resp.text[:200]
|
||||
data = resp.json()
|
||||
assert "facets" in data
|
||||
# #157 — extension facet: keys are query-ready (no leading dot) and,
|
||||
# when there are results, at least one extension is counted.
|
||||
assert "extensions" in data["facets"]
|
||||
exts = data["facets"]["extensions"]
|
||||
assert isinstance(exts, dict)
|
||||
assert all(not e.startswith(".") for e in exts)
|
||||
@@ -235,7 +237,7 @@ class TestAdvancedSearchAPI:
|
||||
assert sum(exts.values()) <= data["total"]
|
||||
|
||||
def test_empty_query(self, client):
|
||||
resp = client.get("/api/advanced-search?q=")
|
||||
resp = client.get("/api/search/advanced?q=")
|
||||
data = self._check(resp)
|
||||
# Empty query should return 0 results
|
||||
assert data["total"] == 0
|
||||
|
||||
Reference in New Issue
Block a user