From 65fe9365aaf0cd3c13c832c779d5e709c68ce09b Mon Sep 17 00:00:00 2001 From: Ophir Lojkine Date: Mon, 30 Nov 2026 10:40:24 +0000 Subject: [PATCH 1/3] Test observable browser behavior and audit SQL fixtures with axe --- .github/workflows/ci.yml | 2 +- AGENTS.md | 6 +- CONTRIBUTING.md | 2 + tests/end-to-end/accessibility.ts | 7 + tests/end-to-end/component-assertions.ts | 188 +++++--------- tests/end-to-end/fixture.ts | 36 +-- tests/end-to-end/fixtures.axe.ts | 45 ++++ tests/end-to-end/fixtures/big-number/test.ts | 26 +- tests/end-to-end/fixtures/chart/test.ts | 229 ++++++------------ tests/end-to-end/fixtures/facet/test.ts | 11 +- .../fixtures/fragment-loaded/test.ts | 38 ++- tests/end-to-end/fixtures/map/test.ts | 111 +++------ tests/end-to-end/fixtures/pagination/test.ts | 22 +- .../fixtures/select-create-text/index.sql | 13 +- .../fixtures/select-create-text/test.ts | 47 ++-- .../fixtures/shell-menu-link/test.ts | 8 +- tests/end-to-end/fixtures/status-bar/test.ts | 3 - tests/end-to-end/fixtures/tracking/test.ts | 37 ++- tests/end-to-end/landing-demos.spec.ts | 36 +-- tests/end-to-end/landing-mobile.spec.ts | 31 ++- tests/end-to-end/landing-touch.spec.ts | 6 +- tests/end-to-end/landing.spec.ts | 26 +- .../official-site-accessibility.spec.ts | 3 +- tests/end-to-end/official-site.spec.ts | 53 ++-- tests/end-to-end/playwright.config.ts | 9 + 25 files changed, 401 insertions(+), 594 deletions(-) create mode 100644 tests/end-to-end/accessibility.ts create mode 100644 tests/end-to-end/fixtures.axe.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e3d2bbb0..4e8a81395 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -259,7 +259,7 @@ jobs: - name: Run Playwright tests run: | chmod +x "${{ runner.temp }}/sqlpage-bin/sqlpage" - SQLPAGE_BINARY="${{ runner.temp }}/sqlpage-bin/sqlpage" npx playwright test + AXE_FIXTURES=1 SQLPAGE_BINARY="${{ runner.temp }}/sqlpage-bin/sqlpage" npx playwright test - uses: actions/upload-artifact@v7 if: ${{ !cancelled() }} with: diff --git a/AGENTS.md b/AGENTS.md index 17706edd9..1331baa25 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -32,9 +32,9 @@ reference material in the official documentation site. Do not duplicate it here. ## Changes and validation -Keep changes scoped to the task, including formatting. Reuse existing tests and -parameterize repeated setup without removing assertions or scenarios. Run the -relevant tests and the formatting/lint checks in CONTRIBUTING.md before stopping. +Keep edits and formatting scoped. Reuse test setup and preserve distinct scenarios. +Test observable behavior through public interfaces. Avoid internal markup and state. +Run the relevant tests and formatting/lint checks in CONTRIBUTING.md. Report unavailable checks and failures accurately; a test summary followed by a hung process is a failure. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ee28efe42..8c5861f8e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,6 +74,8 @@ template properties. Run `npx playwright test --grep @accessibility` from `tests/end-to-end` to audit the official site's component documentation and its live examples in SQLPage's stock light and dark themes with axe-core. The normal Playwright suite also runs it. +CI also audits each browser fixture's initial page once. Run that project locally +with `AXE_FIXTURES=1 npx playwright test --project=fixture-accessibility`. To show that an issue exists before you fix it, put the reproduction in a fixture and run it against releases with one command, such as `nix run .#reproduce -- repro_721 postgres v0.35.0 v0.36.1 tree`. The second argument is `sqlite` or `postgres`, and `tree` is your working tree. It prints Playwright's output for each version, then a table you can paste into the issue or pull request. Releases run from their Docker images, from v0.29.0 onwards, and Postgres from `docker compose`. Without Nix, run `npm run reproduce --` in `tests/end-to-end` instead. diff --git a/tests/end-to-end/accessibility.ts b/tests/end-to-end/accessibility.ts new file mode 100644 index 000000000..080175209 --- /dev/null +++ b/tests/end-to-end/accessibility.ts @@ -0,0 +1,7 @@ +export const wcagTags = [ + "wcag2a", + "wcag2aa", + "wcag21a", + "wcag21aa", + "wcag22aa", +]; diff --git a/tests/end-to-end/component-assertions.ts b/tests/end-to-end/component-assertions.ts index 0fbe327e5..b7b92d66a 100644 --- a/tests/end-to-end/component-assertions.ts +++ b/tests/end-to-end/component-assertions.ts @@ -1,16 +1,7 @@ -import { expect, type Locator, type Page } from "@playwright/test"; +import { expect, type Page } from "@playwright/test"; -// Shared assertions keep documentation page smokes and component fragments aligned. export async function checkToastNotifications(page: Page) { const automatic = page.locator("#toast-auto"); - await expect(automatic).toBeVisible(); - await expect(automatic).toHaveAttribute("data-bs-delay", "5000"); - await expect(automatic).toHaveAttribute("data-bs-autohide", "true"); - await expect( - automatic.getByRole("button", { name: "Close notification" }), - ).toBeVisible(); - await expect(page.locator(".toast.show")).toHaveCount(1); - const automaticHandle = await automatic.elementHandle(); await automatic.getByRole("button", { name: "Close notification" }).click(); await expect(automatic).toBeHidden(); await expect(page.locator("main")).toBeFocused(); @@ -18,95 +9,42 @@ export async function checkToastNotifications(page: Page) { const stackOne = page.locator("#toast-stack-one"); const stackTwo = page.locator("#toast-stack-two"); await expect(stackOne).toBeHidden(); - await page.evaluate(() => { - document.addEventListener("shown.bs.toast", (event) => { - const toast = event.target; - if (!(toast instanceof HTMLElement)) throw new Error("Missing toast"); - toast.dataset.shownCount = String( - Number(toast.dataset.shownCount ?? 0) + 1, - ); - }); - }); await page.getByRole("button", { name: "Show queued notifications" }).click(); await expect(stackOne).toBeVisible(); await expect(stackTwo).toBeVisible(); - await expect(stackOne).toHaveAttribute("data-shown-count", "1"); - await expect(stackTwo).toHaveAttribute("data-shown-count", "1"); - await expect(page.locator("#toast-short")).toHaveAttribute( - "data-shown-count", - "1", - ); - await page.evaluate(() => - document.dispatchEvent(new CustomEvent("fragment-loaded")), - ); - await page.waitForTimeout(250); - await expect(page.locator("#toast-short")).toHaveAttribute( - "data-shown-count", - "1", - ); expect(decodeURIComponent(new URL(page.url()).hash)).toBe( "#queued notifications", ); - const stackContainer = stackOne.locator("xpath=.."); - await expect(stackContainer).toHaveAttribute( - "data-sqlpage-toast-position", - "top-end", - ); - await expect(stackContainer).toHaveClass(/\bmh-100\b/); - await expect(stackContainer).toHaveClass(/\boverflow-auto\b/); - expect( - await stackContainer.evaluate( - (container) => container.parentElement === document.body, - ), - ).toBe(true); - expect( - await stackTwo - .locator("xpath=..") - .getAttribute("data-sqlpage-toast-position"), - ).toBe("top-end"); - const firstBox = await stackOne.boundingBox(); - const secondBox = await stackTwo.boundingBox(); - expect(firstBox).not.toBeNull(); - expect(secondBox).not.toBeNull(); - expect(secondBox?.y).toBeGreaterThanOrEqual( - (firstBox?.y ?? 0) + (firstBox?.height ?? 0), + const [firstBox, secondBox] = await Promise.all([ + stackOne.boundingBox(), + stackTwo.boundingBox(), + ]); + if (!firstBox || !secondBox) throw new Error("Missing queued notifications"); + expect(secondBox.y).toBeGreaterThanOrEqual(firstBox.y + firstBox.height); + expect(secondBox.x + secondBox.width).toBeCloseTo( + firstBox.x + firstBox.width, ); const temporary = page.locator("#toast-short"); - await expect(temporary).toHaveAttribute("data-bs-delay", "2000"); await expect(temporary).toBeVisible(); await expect(temporary).toBeHidden({ timeout: 5000 }); await expect(stackOne).toBeVisible(); - await expect(automatic).toBeHidden({ timeout: 7000 }); - expect( - await automaticHandle?.evaluate((element) => element.isConnected), - ).toBe(false); + await page.evaluate(() => + document.dispatchEvent(new CustomEvent("fragment-loaded")), + ); + await expect(temporary).toBeHidden(); + await expect(automatic).toBeHidden(); const dismissible = page.locator("#toast-dismissible"); - await expect(dismissible).toHaveAttribute("data-bs-delay", "0"); - await expect(dismissible).toHaveAttribute("data-bs-autohide", "false"); await page.getByRole("button", { name: "Show dismissible error" }).click(); const closeButton = dismissible.getByRole("button", { name: "Close notification", }); await expect(closeButton).toBeVisible(); - const closeStyle = await closeButton.evaluate((button) => { - const style = getComputedStyle(button); - const toast = button.closest(".toast"); - if (!toast) throw new Error("Missing toast"); - const toastStyle = getComputedStyle(toast); - return { - backgroundColor: style.backgroundColor, - color: style.color, - filter: style.filter, - maskImage: style.maskImage, - toastColor: toastStyle.color, - }; - }); - expect(closeStyle.filter).toBe("none"); - expect(closeStyle.maskImage).not.toBe("none"); - expect(closeStyle.color).toBe(closeStyle.toastColor); - expect(closeStyle.backgroundColor).toBe(closeStyle.toastColor); + await expect(closeButton).toHaveCSS( + "background-color", + await dismissible.evaluate((toast) => getComputedStyle(toast).color), + ); await page.evaluate(() => { window.history.replaceState({ toastTest: true }, "", window.location.href); }); @@ -146,41 +84,14 @@ export async function checkToastNotifications(page: Page) { await expect(page.locator("#toast-plain")).toContainText( "Plain text stays escaped", ); - const whiteToast = page.locator("#toast-plain"); - const whiteToastStyle = await whiteToast - .locator(".btn-close") - .evaluate((close) => { - const toast = close.closest(".toast"); - if (!toast) throw new Error("Missing toast"); - const style = getComputedStyle(toast); - const closeStyle = getComputedStyle(close); - const rgba = (color: string) => { - const canvas = document.createElement("canvas"); - const context = canvas.getContext("2d"); - if (!context) throw new Error("Canvas 2D context is unavailable"); - context.fillStyle = color; - context.fillRect(0, 0, 1, 1); - return Array.from(context.getImageData(0, 0, 1, 1).data); - }; - return { - backgroundColor: rgba(style.backgroundColor), - closeColor: rgba(closeStyle.backgroundColor), - color: rgba(style.color), - themeDark: rgba(style.getPropertyValue("--tblr-dark")), - }; - }); - expect(whiteToastStyle.backgroundColor).toEqual([255, 255, 255, 255]); - expect(whiteToastStyle.color).toEqual(whiteToastStyle.themeDark); - expect(whiteToastStyle.closeColor).toEqual(whiteToastStyle.color); - - const bottomContainer = page.locator( - '[data-sqlpage-toast-position="bottom-center"]', - ); await page.getByRole("button", { name: "Show bottom notification" }).click(); - await expect(page.locator("#toast-bottom-center")).toBeVisible(); - await expect(bottomContainer).toHaveClass(/\bbottom-0\b/); - await expect(bottomContainer).toHaveClass(/\bstart-50\b/); - await expect(bottomContainer).toHaveClass(/\btranslate-middle-x\b/); + const bottom = page.locator("#toast-bottom-center"); + await expect(bottom).toBeVisible(); + const box = await bottom.boundingBox(); + const viewport = page.viewportSize(); + if (!box || !viewport) throw new Error("Missing bottom notification"); + expect(box.x + box.width / 2).toBeCloseTo(viewport.width / 2); + expect(box.y).toBeGreaterThan(viewport.height / 2); } export async function checkTableFiltering(page: Page, fragment = false) { @@ -192,49 +103,58 @@ export async function checkTableFiltering(page: Page, fragment = false) { await tableSection .locator(".card-body") .dispatchEvent("fragment-loaded", { bubbles: true }); - await expect(page.locator('[data-pre-init="table"]')).not.toHaveCount(0); + const otherTable = page.getByRole("table").filter({ + has: page.getByRole("button", { name: "id", exact: true }), + }); + await otherTable.getByRole("button", { name: "id", exact: true }).click(); + await expect(otherTable.getByRole("cell").first()).toHaveText("31456"); } const searchInput = tableSection.getByPlaceholder("Search…"); await searchInput.fill("chart"); const chartCell = tableSection.getByRole("cell", { name: "Chart" }); await expect(chartCell).toBeVisible(); - await expect(chartCell).toHaveClass(/\b_col_name\b/); await expect(chartCell).toHaveCSS("vertical-align", "middle"); await expect( tableSection.getByRole("cell", { name: "Table" }), ).not.toBeVisible(); } -const numbersInColumn = async (table: Locator, cells: string) => { - const texts = await table.locator(cells).allInnerTexts(); - expect(texts.length).toBeGreaterThan(1); - return texts.map((text) => Number.parseInt(text.replace(/[^0-9]/g, ""), 10)); -}; - -const ascending = (values: number[]) => [...values].sort((a, b) => a - b); - export async function checkTableSort( page: Page, - column: "id" | "Amount in stock", + column: string, reverse = false, ) { - const table = page.locator(".table-responsive", { + const table = page.getByRole("table").filter({ has: page.getByRole("cell", { name: "31456" }), }); - await table.getByRole("button", { name: column }).click(); - if (reverse) await table.getByRole("button", { name: column }).click(); - const values = await numbersInColumn( - table, - column === "id" ? "td._col_id" : "td._col_Amount_in_stock", + const sort = table.getByRole("button", { name: column, exact: true }); + const columns = await table.getByRole("columnheader").allTextContents(); + const index = columns.findIndex((name) => name.trim() === column); + expect(index).toBeGreaterThanOrEqual(0); + await sort.click(); + if (reverse) await sort.click(); + const rows = await table + .getByRole("row") + .filter({ has: page.getByRole("cell") }) + .all(); + const values = await Promise.all( + rows.map(async (row) => + Number.parseInt( + ( + (await row.getByRole("cell").nth(index).textContent()) ?? "" + ).replaceAll(",", ""), + 10, + ), + ), ); + expect(values.length).toBeGreaterThan(1); + expect(values.every(Number.isFinite)).toBe(true); expect(values).toEqual( - reverse ? ascending(values).reverse() : ascending(values), + [...values].sort(reverse ? (a, b) => b - a : (a, b) => a - b), ); } export async function checkModal(page: Page) { - await expect(page.locator("body > #my_modal")).toBeAttached(); - await expect(page.locator("body > #my_embed_form_modal")).toBeAttached(); const openButton = page.getByRole("button", { name: "Open a simple modal" }); await openButton.click(); diff --git a/tests/end-to-end/fixture.ts b/tests/end-to-end/fixture.ts index 9059205d5..f7cb4299e 100644 --- a/tests/end-to-end/fixture.ts +++ b/tests/end-to-end/fixture.ts @@ -1,29 +1,31 @@ import path from "node:path"; import { test as base, expect, type Page } from "@playwright/test"; -const fixturesDirectory = path.resolve(import.meta.dirname, "fixtures"); +export const fixturesDirectory = path.resolve(import.meta.dirname, "fixtures"); + +export async function openFixture(page: Page, directory: string) { + const url = `/${directory.split(path.sep).join("/")}/`; + const response = await page.goto(url); + expect(response?.ok(), `loading ${url}`).toBe(true); + await expect( + page.getByRole("heading", { name: "An error occurred" }), + "SQL fixture rendered without errors", + ).toHaveCount(0); + await expect( + page.locator("[data-pre-init]"), + "component initialization", + ).toHaveCount(0); +} export const test = base.extend({ page: async ({ page }, use, testInfo) => { - const fixture = path - .relative(fixturesDirectory, path.dirname(testInfo.file)) - .split(path.sep) - .join("/"); const errors: string[] = []; page.on("pageerror", (error) => errors.push(error.message)); - const response = await page.goto(`/${fixture}/`); - expect(response).not.toBeNull(); - expect(response?.ok(), `loading ${response?.url()}`).toBe(true); - await expect( - page.getByRole("heading", { name: "An error occurred" }), - "SQL fixture rendered without errors", - ).toHaveCount(0); - await expect( - page.locator("[data-pre-init]"), - "component initialization", - ).toHaveCount(0); - + await openFixture( + page, + path.relative(fixturesDirectory, path.dirname(testInfo.file)), + ); await use(page); expect(errors, "uncaught browser errors").toEqual([]); diff --git a/tests/end-to-end/fixtures.axe.ts b/tests/end-to-end/fixtures.axe.ts new file mode 100644 index 000000000..2e3d6c474 --- /dev/null +++ b/tests/end-to-end/fixtures.axe.ts @@ -0,0 +1,45 @@ +import { globSync } from "node:fs"; +import path from "node:path"; +import { AxeBuilder } from "@axe-core/playwright"; +import { expect, test } from "@playwright/test"; +import { wcagTags } from "./accessibility.ts"; +import { fixturesDirectory, openFixture } from "./fixture.ts"; + +test.use({ reducedMotion: "reduce" }); + +// Existing stock-theme contrast and empty shell brand links. Keep the rules +// enabled so new violations in other fixtures still fail. +const knownViolations: Record> = { + alert: { "color-contrast": 1 }, + "big-number": { "color-contrast": 2 }, + "shell-menu-link": { "link-name": 1 }, + "shell-search": { "color-contrast": 1, "link-name": 1 }, + "status-bar": { "color-contrast": 1 }, + "tab/colored": { "color-contrast": 2 }, +}; + +for (const file of globSync("**/test.ts", { cwd: fixturesDirectory }).sort()) { + const directory = path.dirname(file).split(path.sep).join("/"); + + test(`${directory} passes axe`, async ({ page }) => { + await openFixture(page, directory); + const { violations } = await new AxeBuilder({ page }) + .withTags(wcagTags) + // Most component fixtures omit the shell. The official site audits language. + .disableRules("html-has-lang") + .analyze(); + + expect( + violations + .filter( + ({ id, nodes }) => + nodes.length > (knownViolations[directory]?.[id] ?? 0), + ) + .map(({ id, helpUrl, nodes }) => ({ + id, + helpUrl, + targets: nodes.map(({ target }) => target), + })), + ).toEqual([]); + }); +} diff --git a/tests/end-to-end/fixtures/big-number/test.ts b/tests/end-to-end/fixtures/big-number/test.ts index 9a6a56e2e..1e8245d45 100644 --- a/tests/end-to-end/fixtures/big-number/test.ts +++ b/tests/end-to-end/fixtures/big-number/test.ts @@ -5,19 +5,15 @@ for (const theme of ["light", "dark"]) { page, }) => { await page.goto(`/big-number/?theme=${theme}`); - await expect(page.locator("body")).toHaveAttribute("data-bs-theme", theme); await expect(page.locator("body")).toHaveCSS("color-scheme", theme); const defaultColor = await page - .locator("#default-color .h1") + .getByText("9,012", { exact: true }) .evaluate((value) => getComputedStyle(value).color); - const rem = await page - .locator("html") - .evaluate((html) => Number.parseFloat(getComputedStyle(html).fontSize)); - for (const { id, linked } of [ - { id: "plain-color", linked: false }, - { id: "linked-color", linked: true }, + for (const { id, value } of [ + { id: "plain-color", value: page.getByText("1,234", { exact: true }) }, + { id: "linked-color", value: page.getByRole("link", { name: "5,678" }) }, ]) { const item = page.locator(`#${id}`); const cardColor = await item @@ -26,19 +22,7 @@ for (const theme of ["light", "dark"]) { // Matching two default-colored elements must not count as a color fix. expect(cardColor).not.toBe(defaultColor); - await expect(item.locator(".h1")).toHaveCSS("color", cardColor); - await expect(item.locator(".h1 a")).toHaveCount(linked ? 1 : 0); - if (linked) { - await expect(item.locator(".h1 a")).toHaveCSS("color", cardColor); - } - await expect(item.locator(".card-body")).toHaveCSS( - "padding-top", - `${rem}px`, - ); - await expect(item.locator(".card-body")).toHaveCSS( - "padding-bottom", - `${rem}px`, - ); + await expect(value).toHaveCSS("color", cardColor); } }); } diff --git a/tests/end-to-end/fixtures/chart/test.ts b/tests/end-to-end/fixtures/chart/test.ts index 2d5f557ab..6f9c2a983 100644 --- a/tests/end-to-end/fixtures/chart/test.ts +++ b/tests/end-to-end/fixtures/chart/test.ts @@ -2,6 +2,8 @@ import assert from "node:assert/strict"; import { text } from "node:stream/consumers"; import { type ConsoleMessage, expect, type Page, test } from "../../fixture.ts"; +test.use({ timezoneId: "UTC" }); + const MARKS = ".apexcharts-bar-area, .apexcharts-rangebar-area, .apexcharts-treemap-rect, .apexcharts-pie-area, .apexcharts-heatmap-rect, .apexcharts-series .apexcharts-marker"; @@ -24,24 +26,16 @@ async function renderChart(page: Page, fixture: string) { ({ failures, marks }) => { const container = document.getElementById("test-chart"); if (!container) throw new Error("Chart fixture did not render"); - const rendered = window.charts?.[0]; - const series = (rendered?.w.config.series ?? []) - .filter((s) => typeof s !== "number") - .map((s) => ({ - name: s.name, - points: s.data.map((p) => [ - p.x instanceof Date ? p.x.toISOString() : p.x, - p.y, - ]), - })); - const drawnPerSeries = series.map(({ name }) => { + const drawnPerSeries = [ + ...container.querySelectorAll(".apexcharts-series[seriesName]"), + ].map((series) => { const markers = [ - ...container.querySelectorAll( - `.apexcharts-series[seriesName='${name}'] .apexcharts-series-markers > .apexcharts-marker`, + ...series.querySelectorAll( + ".apexcharts-series-markers > .apexcharts-marker", ), ].map((m) => m.getBBox()); return { - name, + name: series.getAttribute("seriesName"), lefts: markers.map((b) => Math.round(b.x)), heights: markers.map((b) => Math.round(b.y)), }; @@ -96,22 +90,16 @@ async function renderChart(page: Page, fixture: string) { return { failures, - type: rendered?.w.config.chart.type ?? null, - stacked: rendered?.w.config.chart.stacked ?? null, - xaxis: { - type: rendered?.w.config.xaxis.type ?? null, - tickAmount: rendered?.w.config.xaxis.tickAmount ?? null, - }, - generatedLabels: rendered?.w.globals.labels ?? [], - threeDimensional: rendered?.w.globals.isDataXYZ ?? null, axisLabels, + rowLabels: [ + ...container.querySelectorAll(".apexcharts-yaxis-label tspan"), + ].map((label) => label.textContent), dataLabels: [ ...container.querySelectorAll( ".apexcharts-datalabel, .apexcharts-pie-label", ), ].map((label) => label.textContent), barGroups, - series, drawnPerSeries, shapes, referenceLines, @@ -217,8 +205,6 @@ test("positions complete numeric bar series on an explicit numeric axis (#733)", const xs = Array.from({ length: 12 }, (_, index) => index + 1); expect(chart.failures).toEqual([]); - expect(chart.xaxis).toEqual({ type: "numeric", tickAmount: null }); - expect(chart.generatedLabels).toEqual(xs); expect(chart.axisLabels.map(({ text }) => Number(text))).toEqual(xs); expect(chart.dataLabels.map(Number)).toEqual([...xs, ...xs]); expect(chart.barGroups).toHaveLength(xs.length); @@ -235,14 +221,11 @@ test("keeps irregular numeric x values proportionately spaced", async ({ const chart = await renderChart(page, "numeric-axis-irregular"); expect(chart.failures).toEqual([]); - expect(chart.xaxis.type).toBe("numeric"); - expect(chart.generatedLabels).toEqual([0.25, 1.63, 3]); expect(chart.axisLabels.map(({ text }) => text)).toEqual([ "0.3", "1.6", "3.0", ]); - expect(chart.axisLabels.map(({ text }) => text)).not.toContain("2"); const [first, second, third] = chart.barGroups; assert.ok(first !== undefined && second !== undefined && third !== undefined); expect(third - second).toBeGreaterThan(5 * (second - first)); @@ -252,20 +235,26 @@ test("keeps an explicit x interval count", async ({ page }) => { const chart = await renderChart(page, "numeric-axis-xticks"); expect(chart.failures).toEqual([]); - expect(chart.xaxis).toEqual({ type: "numeric", tickAmount: 2 }); + expect(chart.axisLabels.map(({ text }) => text)).toEqual(["1", "7", "12"]); }); test("keeps text x values as categories", async ({ page }) => { const chart = await renderChart(page, "index"); - expect(chart.xaxis.type).toBe("category"); - expect(chart.generatedLabels).toEqual(["Mon", "Tue", "Wed"]); + expect(chart.axisLabels.map(({ text }) => text)).toEqual([ + "Mon", + "Tue", + "Wed", + ]); }); test("keeps time series on a datetime axis", async ({ page }) => { const chart = await renderChart(page, "unstacked-time-series"); - expect(chart.xaxis.type).toBe("datetime"); + expect(chart.axisLabels.map(({ text }) => text)).toEqual( + expect.arrayContaining(["00:01:00", "00:02:00"]), + ); + expect(chart.drawnPerSeries.map(({ lefts }) => lefts.length)).toEqual([4, 3]); }); test("keeps numeric horizontal bars on their category-oriented axis", async ({ @@ -273,7 +262,7 @@ test("keeps numeric horizontal bars on their category-oriented axis", async ({ }) => { const chart = await renderChart(page, "numeric-horizontal-bar"); - expect(chart.xaxis.type).toBeNull(); + expect(chart.rowLabels).toEqual(["1", "4", "12"]); expect(chart.shapes).toHaveLength(3); }); @@ -282,8 +271,9 @@ test("keeps a rangeBar timeline on its datetime value axis", async ({ }) => { const chart = await renderChart(page, "range-bar"); - expect(chart.type).toBe("rangeBar"); - expect(chart.xaxis.type).toBe("datetime"); + expect(chart.axisLabels.map(({ text }) => text)).toEqual( + expect.arrayContaining(["01 Mar", "09 Mar"]), + ); expect(chart.shapes).toHaveLength(2); }); @@ -292,31 +282,16 @@ test("draws a column chart as a vertical bar chart", async ({ page }) => { expect(chart.failures).toEqual([]); expect(chart.shapes).toHaveLength(3); - expect(chart.type).toBe("bar"); expect(new Set(chart.shapes.map((s) => s.x)).size).toBe(3); expect(new Set(chart.shapes.map((s) => s.height)).size).toBe(3); }); -test("gives a stacked series a zero at every x it did not measure", async ({ - page, -}) => { - const chart = await renderChart(page, "stacked-time-series"); - - expect(chart.failures).toEqual([]); - expect(chart.series.map((s) => s.name)).toEqual(["CPU", "GPU"]); - expect(chart.series[1]?.points).toEqual([ - ["2024-01-01T00:00:00.000Z", 0], - ["2024-01-01T00:01:00.000Z", 50], - ["2024-01-01T00:02:00.000Z", 50], - ["2024-01-01T00:03:00.000Z", 50], - ["2024-01-01T00:04:00.000Z", 0], - ]); -}); - test("stacks a series above the one it shares an x with", async ({ page }) => { const chart = await renderChart(page, "stacked-time-series"); - const [cpu, gpu] = chart.drawnPerSeries; + expect(chart.failures).toEqual([]); + const cpu = chart.drawnPerSeries.find(({ name }) => name === "CPU"); + const gpu = chart.drawnPerSeries.find(({ name }) => name === "GPU"); assert.ok(cpu && gpu, "Both series were drawn"); expect(cpu.lefts).toHaveLength(5); @@ -337,11 +312,11 @@ test("keeps a lone series in the order the query returned it (#930)", async ({ const chart = await renderChart(page, "out-of-order"); expect(chart.failures).toEqual([]); - expect(chart.series[0]?.points).toEqual([ - ["Q3", 3], - ["Q1", 1], - ["Q2", 2], - ]); + expect(chart.axisLabels.map(({ text }) => text)).toEqual(["Q3", "Q1", "Q2"]); + const [first, second, third] = chart.shapes; + assert.ok(first && second && third); + expect(first.height).toBeGreaterThan(third.height); + expect(third.height).toBeGreaterThan(second.height); }); test("orders by name the categories two bar series do not share (#951)", async ({ @@ -350,28 +325,14 @@ test("orders by name the categories two bar series do not share (#951)", async ( const chart = await renderChart(page, "disjoint-categories"); expect(chart.failures).toEqual([]); - expect(chart.series[0]?.points).toEqual([ - ["X1", 0], - ["X2", 10], - ["X3", 30], - ]); - expect(chart.series[1]?.points).toEqual([ - ["X1", 25], - ["X2", 20], - ["X3", 0], - ]); -}); - -test("leaves the points of a chart that does not stack alone", async ({ - page, -}) => { - const chart = await renderChart(page, "unstacked-time-series"); - - expect(chart.failures).toEqual([]); - expect(chart.series[1]?.points).toEqual([ - ["2024-01-01T00:01:00.000Z", 50], - ["2024-01-01T00:02:00.000Z", 50], - ["2024-01-01T00:03:00.000Z", 50], + expect(chart.axisLabels.map(({ text }) => text)).toEqual(["X1", "X2", "X3"]); + expect(chart.shapes.map(({ height }) => height > 0)).toEqual([ + false, + true, + true, + true, + true, + false, ]); }); @@ -379,24 +340,11 @@ test("stacks a bar series on the categories it skipped", async ({ page }) => { const chart = await renderChart(page, "stacked-categories"); expect(chart.failures).toEqual([]); - expect(chart.series[1]?.points).toEqual([ - ["Q1", 0], - ["Q2", 20], - ["Q3", 30], - ]); -}); - -test("lines an unstacked series up with the categories it skipped", async ({ - page, -}) => { - const chart = await renderChart(page, "line-categories"); - - expect(chart.failures).toEqual([]); - expect(chart.series[1]?.points).toEqual([ - ["Q1", null], - ["Q2", 20], - ["Q3", 30], - ]); + const [a1, a2, a3, b1, b2, b3] = chart.shapes; + assert.ok(a1 && a2 && a3 && b1 && b2 && b3); + expect(b1.height).toBe(0); + expect(b2.y + b2.height).toBeCloseTo(a2.y); + expect(b3.y + b3.height).toBeCloseTo(a3.y); }); test("draws nothing where an unstacked series has no value", async ({ @@ -415,11 +363,6 @@ test("keeps a measured zero apart from a missing value", async ({ page }) => { const [a, b] = chart.drawnPerSeries; assert.ok(a && b, "Both series were drawn"); - expect(chart.series[1]?.points).toEqual([ - ["Q1", null], - ["Q2", 0], - ["Q3", 30], - ]); expect(b.lefts).toEqual(a.lefts.slice(1)); }); @@ -430,39 +373,33 @@ for (const type of ["area", "scatter", "heatmap"]) { const chart = await renderChart(page, `${type}-categories`); expect(chart.failures).toEqual([]); - expect(chart.series[1]?.points.map((p) => p[0])).toEqual([ + expect(chart.axisLabels.map(({ text }) => text)).toEqual([ "Q1", "Q2", "Q3", ]); + if (type === "heatmap") { + expect(chart.shapes.map(({ x }) => x).slice(0, 3)).toEqual( + chart.shapes.map(({ x }) => x).slice(3), + ); + } else { + const [a, b] = chart.drawnPerSeries; + assert.ok(a && b); + expect(b.lefts).toEqual(a.lefts.slice(1)); + } }); } -test("counts a third dimension only where the rows carried one", async ({ - page, -}) => { - const flat = await renderChart(page, "index"); - const bubbles = await renderChart(page, "bubble-categories"); - - expect(flat.threeDimensional).toBe(false); - expect(bubbles.threeDimensional).toBe(true); -}); - test("keeps the bubble size of the points it lined up", async ({ page }) => { const chart = await renderChart(page, "bubble-categories"); expect(chart.failures).toEqual([]); - expect(chart.series[1]?.points).toEqual([ - ["Q1", null], - ["Q2", 5], - ]); -}); - -test("leaves a rangeBar chart on a category axis alone", async ({ page }) => { - const chart = await renderChart(page, "range-bar"); - - expect(chart.failures).toEqual([]); - expect(chart.shapes).toHaveLength(2); + const visible = chart.shapes.filter(({ width }) => width >= 1); + const [first, second, larger] = visible; + assert.ok(first && second && larger); + expect(visible).toHaveLength(3); + expect(larger.x + larger.width / 2).toBeCloseTo(second.x + second.width / 2); + expect(larger.width).toBeGreaterThan(second.width); }); test("keeps treemap labels legible on a phone and in an SVG download", async ({ @@ -517,7 +454,6 @@ test("draws a rangeBar chart that asks to be stacked", async ({ page }) => { expect(chart.failures).toEqual([]); expect(chart.shapes).toHaveLength(2); - expect(chart.stacked).toBe(false); }); test("gives the tooltip title the color of the tooltip around it", async ({ @@ -717,7 +653,10 @@ test("renders series named after built-in JavaScript properties", async ({ const chart = await renderChart(page, "builtin-series-names"); expect(chart.failures).toEqual([]); - expect(chart.series.map((s) => s.name)).toEqual(["toString", "constructor"]); + await expect(page.locator(".apexcharts-legend-text")).toHaveText([ + "toString", + "constructor", + ]); expect(chart.shapes).toHaveLength(2); }); @@ -727,7 +666,11 @@ test("keeps numeric series names in the order their rows came back in", async ({ const chart = await renderChart(page, "numeric-series-names"); expect(chart.failures).toEqual([]); - expect(chart.series.map((s) => s.name)).toEqual([2024, 2023, "total"]); + await expect(page.locator(".apexcharts-legend-text")).toHaveText([ + "2024", + "2023", + "total", + ]); }); test("keeps coloring reference lines from their own row", async ({ page }) => { @@ -741,26 +684,12 @@ test("labels each axis of a bubble tooltip with its own title", async ({ page, }) => { await renderChart(page, "titled-bubble"); - - const rows = await page.evaluate(() => { - const chart = window.charts?.[0]; - if (!chart) throw new Error("Chart fixture did not render"); - const custom = chart.w.config.tooltip.custom; - if (!custom) throw new Error("A bubble chart needs the custom tooltip"); - const holder = document.createElement("div"); - holder.innerHTML = custom({ seriesIndex: 0, dataPointIndex: 1 }); - const values = holder.querySelectorAll(".apexcharts-tooltip-text-y-value"); - return [...holder.querySelectorAll(".apexcharts-tooltip-text-y-label")].map( - (label, i): [string, string] => [ - label.textContent?.trim() ?? "", - values[i]?.textContent?.trim() ?? "", - ], - ); - }); - - expect(rows).toEqual([ - ["Weekday:", "Tue"], - ["Hours:", "4"], - ["Weight:", "30"], - ]); + await page + .locator(".apexcharts-series .apexcharts-marker:visible") + .nth(1) + .hover(); + const tooltip = page.locator(".apexcharts-tooltip").filter({ visible: true }); + await expect(tooltip).toHaveText( + /Weekday:\s*Tue\s*Hours:\s*4\s*Weight:\s*30/, + ); }); diff --git a/tests/end-to-end/fixtures/facet/test.ts b/tests/end-to-end/fixtures/facet/test.ts index ca26a1a0e..db0cfea30 100644 --- a/tests/end-to-end/fixtures/facet/test.ts +++ b/tests/end-to-end/fixtures/facet/test.ts @@ -1,6 +1,6 @@ import { expect, test } from "../../fixture.ts"; -test("fragment dropdown keeps one Bootstrap instance after repeated events", async ({ +test("fragment dropdown opens and closes once per click after repeated events", async ({ page, }) => { await page @@ -9,11 +9,10 @@ test("fragment dropdown keeps one Bootstrap instance after repeated events", asy await page.evaluate(() => document.dispatchEvent(new CustomEvent("fragment-loaded")), ); - const toggle = page - .locator('[data-bs-toggle="dropdown"]') - .filter({ hasText: "Constitution" }); + const toggle = page.getByRole("button", { name: "Constitution" }); + const choice = page.getByRole("link", { name: "One", exact: true }); await toggle.click(); - await expect(page.locator(".dropdown-menu.show")).toBeVisible(); + await expect(choice).toBeVisible(); await toggle.click(); - await expect(page.locator(".dropdown-menu.show")).toHaveCount(0); + await expect(choice).toBeHidden(); }); diff --git a/tests/end-to-end/fixtures/fragment-loaded/test.ts b/tests/end-to-end/fixtures/fragment-loaded/test.ts index 7710b6f84..dd7cb9ff0 100644 --- a/tests/end-to-end/fixtures/fragment-loaded/test.ts +++ b/tests/end-to-end/fixtures/fragment-loaded/test.ts @@ -77,7 +77,9 @@ for (const root of ["#root-form", '#root-form input[type="file"]']) { await trackHandlers(page, "#root-form"); const form = page.locator("#root-form"); const isForm = root === "#root-form"; - await expect(form.locator(".ts-wrapper")).toHaveCount(isForm ? 1 : 0); + await expect( + form.locator("input").and(form.getByRole("combobox")), + ).toHaveCount(isForm ? 1 : 0); await form.getByLabel("Modern text field").fill("changed"); await form.getByLabel("Modern text field").blur(); await expect(form).toHaveAttribute("data-submissions", isForm ? "1" : "0"); @@ -94,7 +96,6 @@ for (const root of ["#root-form", '#root-form input[type="file"]']) { mimeType: "text/plain", buffer: Buffer.alloc(maxSize + 1), }); - await expect(upload).toHaveClass(/is-invalid/); await expect(upload).toHaveJSProperty( "validationMessage", `File size must be less than ${maxSize / 1000} kB.`, @@ -110,10 +111,12 @@ test("chart and select roots leave unrelated fragments pending", async ({ await expect( page.locator("main > #test-chart .apexcharts-canvas"), ).toBeAttached(); - const select = page.locator("#root-form select"); - await expect(select).toHaveAttribute("data-pre-init", "select-dropdown"); + const form = page.locator("#root-form"); + const search = form.locator("input").and(form.getByRole("combobox")); + await expect(search).toHaveCount(0); + const select = form.getByRole("combobox"); await select.dispatchEvent("fragment-loaded", { bubbles: true }); - await expect(page.locator("#root-form .ts-wrapper")).toBeAttached(); + await expect(search).toBeVisible(); }); test("map roots initialize before and after their shared dependency loads", async ({ @@ -136,12 +139,12 @@ test("map roots initialize before and after their shared dependency loads", asyn releaseLeaflet(); } await expect(page.locator(".leaflet-map-pane")).toHaveCount(2); - await expect(pending).toHaveAttribute("data-pre-init", "map"); + await expect(pending.getByRole("button", { name: "Zoom in" })).toHaveCount(0); await loadFragment(page, "/map/", root); await expect(page.locator(".leaflet-map-pane")).toHaveCount(3); await page.locator(root).dispatchEvent("fragment-loaded", { bubbles: true }); await expect(page.locator(".leaflet-map-pane")).toHaveCount(3); - await expect(pending).toHaveAttribute("data-pre-init", "map"); + await expect(pending.getByRole("button", { name: "Zoom in" })).toHaveCount(0); await pending.dispatchEvent("fragment-loaded", { bubbles: true }); await expect(page.locator(".leaflet-map-pane")).toHaveCount(4); }); @@ -154,7 +157,7 @@ for (const bundle of ["apexcharts", "tomselect"]) { const select = bundle === "tomselect"; const url = select ? "/form/?fragment=1" : "/chart/"; const component = select ? "form" : "[data-sqlpage-js]"; - const ready = select ? ".ts-wrapper" : ".apexcharts-canvas"; + const ready = select ? 'input[role="combobox"]' : ".apexcharts-canvas"; await loadFragment(page, url, null); const pending = page.locator(`main > ${component}`).first(); let releaseBundle = () => {}; @@ -172,10 +175,7 @@ for (const bundle of ["apexcharts", "tomselect"]) { releaseBundle(); } await expect(page.locator(ready)).toHaveCount(2); - await expect(select ? pending.locator("select") : pending).toHaveAttribute( - "data-pre-init", - select ? "select-dropdown" : "chart", - ); + await expect(pending.locator(ready)).toHaveCount(0); await pending.dispatchEvent("fragment-loaded", { bubbles: true }); await expect(page.locator(ready)).toHaveCount(3); }); @@ -200,25 +200,23 @@ for (const lazy of [false, true]) { await page .locator("main") .dispatchEvent("fragment-loaded", { bubbles: true }); - await expect(page.locator("body > #nested-modal")).toBeAttached(); - await expect(page.locator("#nested-modal .ts-wrapper")).toBeAttached(); - await expect( - page.locator("#nested-modal .apexcharts-canvas"), - ).toBeAttached(); await expect(page.locator("#nested-toast")).toBeVisible(); await page.evaluate(() => { window.location.hash = "nested-modal"; }); - await expect(page.getByRole("dialog")).toBeVisible(); + const dialog = page.getByRole("dialog"); + await expect(dialog.locator('input[role="combobox"]')).toBeVisible(); + await expect(dialog.locator(".apexcharts-canvas")).toBeVisible(); await page.locator("#added").hover(); await expect(page.locator(".tooltip")).toHaveText("injected hint"); await page .getByRole("button", { name: "Constitution", exact: true }) .click(); - await expect(page.locator(".dropdown-menu.show")).toBeVisible(); + const choice = dialog.getByRole("link", { name: "One", exact: true }); + await expect(choice).toBeVisible(); await page .getByRole("button", { name: "Constitution", exact: true }) .click(); - await expect(page.locator(".dropdown-menu.show")).toHaveCount(0); + await expect(choice).toBeHidden(); }); } diff --git a/tests/end-to-end/fixtures/map/test.ts b/tests/end-to-end/fixtures/map/test.ts index debec5499..5265f7da8 100644 --- a/tests/end-to-end/fixtures/map/test.ts +++ b/tests/end-to-end/fixtures/map/test.ts @@ -1,80 +1,33 @@ -import { type ConsoleMessage, expect, type Page, test } from "../../fixture.ts"; - -const PARIS_WITHOUT_ITS_LONGITUDE = "48.85,"; -const NOT_COORDINATES = "somewhere nice"; - -async function renderMap(page: Page, fixture: string, markerCount = 0) { - const errors: string[] = []; - const logged: string[] = []; - const recordPageError = (error: Error) => errors.push(error.message); - const recordConsoleError = (message: ConsoleMessage) => { - if (message.type() === "error") logged.push(message.text()); - }; - page.on("pageerror", recordPageError); - page.on("console", recordConsoleError); - const response = await page.goto(`/map/${fixture}.sql`); - expect(response?.ok(), `loading ${response?.url()}`).toBe(true); - await expect(page.locator("[data-pre-init='map']")).toHaveCount(0); - await expect(page.locator(".leaflet-map-pane")).toBeAttached(); - await expect(page.locator(".leaflet-marker-icon")).toHaveCount(markerCount); - page.off("pageerror", recordPageError); - page.off("console", recordConsoleError); - - return page.locator(".leaflet").evaluate( - (container, messages) => ({ - ...messages, - markers: container.querySelectorAll(".leaflet-marker-icon").length, - initialized: !!container.querySelector(".leaflet-map-pane"), - }), - { errors, logged }, - ); +import { expect, test } from "../../fixture.ts"; + +for (const [fixture, invalidCoordinates, hasMarker] of [ + ["valid-center", null, false], + ["missing-center-longitude", "48.85,", false], + ["invalid-center", "somewhere nice", false], + ["valid-marker", null, true], + ["invalid-and-valid-markers", "48.85,", true], +] as const) { + test(`renders the map and reports invalid coordinates (${fixture})`, async ({ + page, + }) => { + const errors: string[] = []; + page.on("console", (message) => { + if (message.type() === "error") errors.push(message.text()); + }); + const response = await page.goto(`/map/${fixture}.sql`); + expect(response?.ok()).toBe(true); + await expect(page.getByRole("button", { name: "Zoom in" })).toBeVisible(); + await expect(page.getByRole("link", { name: "Leaflet" })).toHaveCSS( + "text-decoration-line", + "underline", + ); + await expect(page.getByTitle("Paris")).toHaveCount(hasMarker ? 1 : 0); + await expect(page.getByTitle("Half of Paris")).toHaveCount(0); + + await expect + .poll(() => errors) + .toEqual( + invalidCoordinates ? [expect.stringContaining(invalidCoordinates)] : [], + ); + }); } - -test("centers the map on a pair of coordinates", async ({ page }) => { - const map = await renderMap(page, "valid-center"); - - expect(map.errors).toEqual([]); - expect(map.logged).toEqual([]); - expect(map.initialized).toBe(true); - await expect( - page.locator(".leaflet-control-attribution a").first(), - ).toHaveCSS("text-decoration-line", "underline"); -}); - -test("reports a center whose longitude is missing", async ({ page }) => { - const map = await renderMap(page, "missing-center-longitude"); - - expect(map.errors).toEqual([]); - expect(map.logged).toEqual([ - expect.stringContaining(PARIS_WITHOUT_ITS_LONGITUDE), - ]); - expect(map.initialized).toBe(true); -}); - -test("reports a center that is not a pair of numbers", async ({ page }) => { - const map = await renderMap(page, "invalid-center"); - - expect(map.errors).toEqual([]); - expect(map.logged).toEqual([expect.stringContaining(NOT_COORDINATES)]); - expect(map.initialized).toBe(true); -}); - -test("draws a marker at a pair of coordinates", async ({ page }) => { - const map = await renderMap(page, "valid-marker", 1); - - expect(map.errors).toEqual([]); - expect(map.logged).toEqual([]); - expect(map.markers).toBe(1); -}); - -test("reports a marker whose longitude is missing, keeping the others", async ({ - page, -}) => { - const map = await renderMap(page, "invalid-and-valid-markers", 1); - - expect(map.errors).toEqual([]); - expect(map.logged).toEqual([ - expect.stringContaining(PARIS_WITHOUT_ITS_LONGITUDE), - ]); - expect(map.markers).toBe(1); -}); diff --git a/tests/end-to-end/fixtures/pagination/test.ts b/tests/end-to-end/fixtures/pagination/test.ts index 9804aaf39..74d331209 100644 --- a/tests/end-to-end/fixtures/pagination/test.ts +++ b/tests/end-to-end/fixtures/pagination/test.ts @@ -4,13 +4,19 @@ test("pagination names its controls and only disables the requested links", asyn page, }) => { for (const name of ["First page", "Next page", "Last page"]) { - const link = page.getByRole("link", { name }); - await expect(link).toBeVisible(); - await expect(link).not.toHaveAttribute("aria-disabled"); - await link.focus(); - await expect(link).toBeFocused(); + await expect(page.getByRole("link", { name })).toBeEnabled(); } - const previous = page.getByRole("link", { name: "Previous page" }); - await expect(previous).toHaveAttribute("aria-disabled", "true"); - await expect(previous).toHaveAttribute("tabindex", "-1"); + const first = page.getByRole("link", { name: "First page" }); + await expect( + page.getByRole("link", { name: "Previous page" }), + ).toBeDisabled(); + await first.focus(); + await page.keyboard.press("Tab"); + await expect( + page.getByRole("link", { name: "1", exact: true }), + ).toBeFocused(); + await page.keyboard.press("Tab"); + await expect(page.getByRole("link", { name: "Next page" })).toBeFocused(); + await page.keyboard.press("Enter"); + await expect(page).toHaveURL(/#next$/); }); diff --git a/tests/end-to-end/fixtures/select-create-text/index.sql b/tests/end-to-end/fixtures/select-create-text/index.sql index e807b68d7..aeeed3966 100644 --- a/tests/end-to-end/fixtures/select-create-text/index.sql +++ b/tests/end-to-end/fixtures/select-create-text/index.sql @@ -1,6 +1,11 @@ -SELECT 'form' AS component; -SELECT 'translated' AS name, 'select' AS type, 1 AS searchable, 1 AS create_new, - 'Neu anlegen:' AS create_new_text, 'Keine Treffer' AS no_results_text, +SELECT 'text' AS component, 'Created: ' || :translated AS contents +WHERE sqlpage.request_method() = 'POST'; +SELECT 'form' AS component, 'Save' AS validate; +SELECT 'translated' AS name, 'Translated' AS label, 'select' AS type, 1 AS searchable, 1 AS create_new, + 'Neu anlegen:' AS create_new_text, '[{"label": "Red", "value": "red"}, {"label": "Blue", "value": "blue"}]' AS options; -SELECT 'default' AS name, 'select' AS type, 1 AS searchable, 1 AS create_new, +SELECT 'default' AS name, 'Default' AS label, 'select' AS type, 1 AS searchable, 1 AS create_new, + '[{"label": "Red", "value": "red"}, {"label": "Blue", "value": "blue"}]' AS options; +SELECT 'choices' AS name, 'Choices' AS label, 'select' AS type, 1 AS searchable, + 'Keine Treffer' AS no_results_text, '[{"label": "Red", "value": "red"}, {"label": "Blue", "value": "blue"}]' AS options; diff --git a/tests/end-to-end/fixtures/select-create-text/test.ts b/tests/end-to-end/fixtures/select-create-text/test.ts index b8566b16a..91fc2da44 100644 --- a/tests/end-to-end/fixtures/select-create-text/test.ts +++ b/tests/end-to-end/fixtures/select-create-text/test.ts @@ -1,32 +1,27 @@ -import { expect, type Page, test } from "../../fixture.ts"; +import { expect, test } from "../../fixture.ts"; -async function search(page: Page, name: string, text: string) { - const field = page - .locator("label") - .filter({ has: page.locator(`select[name="${name}"]`) }); - const input = field.locator('input[role="combobox"]'); - await field.locator(".ts-control").click(); - await input.fill(text); - return { input, dropdown: field.getByRole("listbox") }; -} - -test("translated texts, and the create row is the active option", async ({ +test("a keyboard user can create and submit a value from the translated option", async ({ page, }) => { - const { input, dropdown } = await search(page, "translated", "Gruen"); - const create = dropdown.getByRole("option", { name: "Neu anlegen: Gruen…" }); - await expect(create).toBeVisible(); - await expect(input).toHaveAttribute( - "aria-activedescendant", - (await create.getAttribute("id")) ?? "", - ); - await expect(dropdown.getByText("Keine Treffer")).toBeVisible(); -}); - -test("without the properties, the texts stay the same", async ({ page }) => { - const { dropdown } = await search(page, "default", "Gruen"); + await page.keyboard.press("Tab"); + await page.keyboard.type("Gruen"); await expect( - dropdown.getByRole("option", { name: "Add Gruen…" }), + page.getByRole("option", { name: "Neu anlegen: Gruen…" }), ).toBeVisible(); - await expect(dropdown.getByText("No results found")).toBeVisible(); + await page.keyboard.press("Enter"); + await page.getByRole("button", { name: "Save" }).press("Enter"); + await expect(page.getByText("Created: Gruen", { exact: true })).toBeVisible(); +}); + +test("searchable selects keep their default copy and can translate empty results", async ({ + page, +}) => { + await page.keyboard.press("Tab"); + await page.keyboard.press("Tab"); + await page.keyboard.type("Gruen"); + await expect(page.getByRole("option", { name: "Add Gruen…" })).toBeVisible(); + await expect(page.getByText("No results found")).toBeVisible(); + await page.keyboard.press("Tab"); + await page.keyboard.type("Gruen"); + await expect(page.getByText("Keine Treffer")).toBeVisible(); }); diff --git a/tests/end-to-end/fixtures/shell-menu-link/test.ts b/tests/end-to-end/fixtures/shell-menu-link/test.ts index afac01bc7..316901b9f 100644 --- a/tests/end-to-end/fixtures/shell-menu-link/test.ts +++ b/tests/end-to-end/fixtures/shell-menu-link/test.ts @@ -11,10 +11,10 @@ test("a JSON menu item with a link is announced as a link", async ({ }); test("a JSON menu item with a submenu stays a button", async ({ page }) => { - await expect(page.getByRole("button", { name: "More" })).toHaveAttribute( - "data-bs-toggle", - "dropdown", - ); + const settings = page.getByRole("link", { name: "Settings" }); + await expect(settings).toBeHidden(); + await page.getByRole("button", { name: "More" }).click(); + await expect(settings).toBeVisible(); }); test("a plain string menu item is still a link", async ({ page }) => { diff --git a/tests/end-to-end/fixtures/status-bar/test.ts b/tests/end-to-end/fixtures/status-bar/test.ts index ff9bcd283..26342957f 100644 --- a/tests/end-to-end/fixtures/status-bar/test.ts +++ b/tests/end-to-end/fixtures/status-bar/test.ts @@ -4,15 +4,12 @@ test("rows render in order with icons, tooltips and links", async ({ page, }) => { const bar = page.getByRole("status", { name: "Repository status" }); - await expect(bar).toHaveAttribute("id", "repository"); - await expect(bar).toContainClass("project-status"); await expect(bar).toHaveText( /Build passed\s*Branch: feature\/improve-search-index\s*12 pending changes\s*View history/, ); const build = bar.getByRole("link", { name: "Build passed", exact: true }); const history = bar.getByRole("link", { name: "View history" }); - await expect(bar.locator(".build-result")).toContainClass("text-green"); await expect(build.locator("svg")).toBeVisible(); const barRight = await bar.evaluate((el) => el.getBoundingClientRect().right); const textRight = await history.evaluate((el) => { diff --git a/tests/end-to-end/fixtures/tracking/test.ts b/tests/end-to-end/fixtures/tracking/test.ts index fab6dddc4..47ac254cb 100644 --- a/tests/end-to-end/fixtures/tracking/test.ts +++ b/tests/end-to-end/fixtures/tracking/test.ts @@ -1,31 +1,22 @@ import { expect, test } from "../../fixture.ts"; -test("tracking block with a link opens it", async ({ page }) => { - await page.locator(".tracking-block").first().click(); +test("linked tracking blocks expose their title and open their details", async ({ + page, +}) => { + const monday = page.getByRole("link", { name: "Monday: up" }); + await monday.hover(); + await expect(page.getByRole("tooltip")).toHaveText("Monday: up"); + await monday.click(); await expect(page).toHaveURL(/\/tracking\/day\.sql\?day=Monday$/); await expect(page.getByText("Details for Monday")).toBeVisible(); }); -test("tracking block without a link is not a link", async ({ page }) => { - await expect(page.locator(".tracking-block").nth(1)).not.toHaveAttribute( - "href", - ); -}); - test("tracking block with a link looks like one without", async ({ page }) => { - const blocks = page.locator(".tracking-block"); - const linked = await blocks.nth(0).boundingBox(); - const plain = await blocks.nth(1).boundingBox(); - expect(linked?.width).toBe(plain?.width); - expect(linked?.height).toBe(plain?.height); -}); - -test("tracking block with a link keeps its tooltip", async ({ page }) => { - await page.locator(".tracking-block").first().hover(); - await expect(page.getByRole("tooltip")).toHaveText("Monday: up"); -}); - -test("tracking blocks expose their titles", async ({ page }) => { - await expect(page.getByRole("link", { name: "Monday: up" })).toBeVisible(); - await expect(page.getByRole("img", { name: "Tuesday: down" })).toBeVisible(); + const linked = await page + .getByRole("link", { name: "Monday: up" }) + .boundingBox(); + const plain = await page + .getByRole("img", { name: "Tuesday: down" }) + .boundingBox(); + expect(plain).toMatchObject({ width: linked?.width, height: linked?.height }); }); diff --git a/tests/end-to-end/landing-demos.spec.ts b/tests/end-to-end/landing-demos.spec.ts index a9ba0fa14..c59aff096 100644 --- a/tests/end-to-end/landing-demos.spec.ts +++ b/tests/end-to-end/landing-demos.spec.ts @@ -27,6 +27,7 @@ for (const settings of [ ); await expect(demo.getByRole("cell", { name: "Acme Corp" })).toBeVisible(); const tableSource = await source.textContent(); + if (!tableSource) throw new Error("The table example did not show its SQL"); // Hold the source request: the current working example must stay visible. let release = () => {}; @@ -40,10 +41,12 @@ for (const settings of [ await route.continue(); }, ); - await page.getByRole("tab", { name: "form Fields from rows" }).click(); - await expect(panel).toHaveAttribute("aria-busy", "true"); + await Promise.all([ + page.waitForRequest("**/landing-demos/source.sql?component=form"), + page.getByRole("tab", { name: "form Fields from rows" }).click(), + ]); await expect(demo.getByRole("cell", { name: "Acme Corp" })).toBeVisible(); - await expect(source).toHaveText(tableSource!); + await expect(source).toHaveText(tableSource); await expect( page.getByRole("tab", { name: "table.sql", exact: true }), ).toBeVisible(); @@ -63,9 +66,10 @@ for (const settings of [ frames.push({ height: element.getBoundingClientRect().height, scroll: scrollY, - loading: element - .querySelector("#demo-source")! - .textContent!.includes("Loading source"), + loading: + element + .querySelector("#demo-source") + ?.textContent?.includes("Loading source") ?? false, }); if (performance.now() - start < 1000) requestAnimationFrame(sample); @@ -78,7 +82,6 @@ for (const settings of [ release(); await expect(demo.getByLabel("Your name")).toBeVisible(); await expect(source).toContainText("/landing-demos/save.sql"); - await expect(panel).not.toHaveAttribute("aria-busy", "true"); const frames = await samples; expect(frames.some((frame) => frame.loading)).toBe(false); const heights = frames.map((frame) => frame.height); @@ -115,10 +118,10 @@ for (const settings of [ await route.continue(); }, ); - await page - .getByRole("tab", { name: "chart A timeline from 3 rows", exact: true }) - .click(); - await expect(panel).toHaveAttribute("aria-busy", "true"); + await Promise.all([ + page.waitForRequest("**/landing-demos/source.sql?component=chart"), + page.getByRole("tab", { name: "chart A timeline from 3 rows" }).click(), + ]); const numbers = page.getByRole("tab", { name: "big_number KPIs at a glance", exact: true, @@ -146,7 +149,6 @@ for (const settings of [ await expect(demo.getByText("98%", { exact: true })).toBeVisible(); releaseChart(); await expect(source).toContainText("'big_number' as component"); - await expect(panel).toHaveAttribute("data-demo", "big_number"); await expect(page.locator("#demo-panel iframe")).toHaveCount(1); await numbers.press("Home"); await expect(page.locator("#tab-chart")).toBeFocused(); @@ -175,10 +177,12 @@ test("a failed landing example keeps the current preview and SQL", async ({ ); await expect(demo.getByRole("cell", { name: "Acme Corp" })).toBeVisible(); await expect(page.locator("#demo-source")).toContainText("from customers"); - await expect(page.locator("#tab-table")).toHaveAttribute( - "aria-selected", - "true", - ); + await expect( + page.getByRole("tab", { + name: "table Sortable and searchable", + selected: true, + }), + ).toBeVisible(); await expect(page.locator("#demo-panel iframe")).toHaveCount(1); }); diff --git a/tests/end-to-end/landing-mobile.spec.ts b/tests/end-to-end/landing-mobile.spec.ts index d56af7e57..d690e7927 100644 --- a/tests/end-to-end/landing-mobile.spec.ts +++ b/tests/end-to-end/landing-mobile.spec.ts @@ -103,17 +103,12 @@ test("phone layouts have balanced gutters, readable cards, and usable controls", (await bounds(diagram)).width, 0, ); - await expect(result.locator("br")).toHaveCSS("display", "none"); } if (name === "Ship it anywhere") { const diagram = page.locator(".ship-diagram"); const source = await bounds(diagram.locator(":scope > .feature-node")); const options = await bounds(diagram.locator(".ship-options")); expect(options.y).toBeGreaterThan(source.y + source.height); - await expect(diagram.locator(":scope > b")).toHaveCSS( - "rotate", - "90deg", - ); } const whitespace = await panels.evaluate((element) => { const panel = element.querySelector(".frontend-panel:not([hidden])")!; @@ -207,17 +202,21 @@ test("small phones can use navigation and every live component preview", async ( const preview = page.frameLocator( 'iframe[title="Live SQLPage component demo"]', ); - for (const component of ["chart", "big_number", "catalog", "form", "table"]) { - await page.locator(`#tab-${component}`).click(); - await expect(page.locator("#demo-panel")).toHaveAttribute( - "data-demo", - component, - ); - await expect(page.locator("#demo-panel")).not.toHaveAttribute( - "aria-busy", - "true", - ); - await expect(preview.locator("#sqlpage_main_wrapper")).toBeVisible(); + for (const [name, content] of [ + [/A timeline from 3 rows/, preview.locator(".apexcharts-canvas")], + [/KPIs at a glance/, preview.getByText("98%", { exact: true })], + [ + /Explore the whole toolkit/, + preview.getByRole("link", { name: "form", exact: true }), + ], + [/Fields from rows/, preview.getByLabel("Your name")], + [ + /Sortable and searchable/, + preview.getByRole("cell", { name: "Acme Corp" }), + ], + ] as const) { + await page.getByRole("tab", { name }).click(); + await expect(content).toBeVisible(); await expect .poll(() => preview diff --git a/tests/end-to-end/landing-touch.spec.ts b/tests/end-to-end/landing-touch.spec.ts index a9980c935..9023ecff0 100644 --- a/tests/end-to-end/landing-touch.spec.ts +++ b/tests/end-to-end/landing-touch.spec.ts @@ -31,8 +31,6 @@ test.describe("landing sculpture touch gestures", () => { const sculpture = page.getByRole("application", { name: "Interactive 3D database sculpture", }); - await expect(sculpture).toHaveAttribute("tabindex", "0"); - await expect(sculpture).toHaveCSS("touch-action", "pan-y pinch-zoom"); // The live scene and low-power views both describe native vertical scrolling. await expect(sculpture).toHaveAccessibleDescription( /swipe (up or down|vertically)/i, @@ -90,7 +88,6 @@ test.describe("landing sculpture touch gestures", () => { // A cancelled scroll must release the trackball and allow the next drag. await page.evaluate(() => window.scrollTo(0, 0)); - await expect(sculpture).toHaveAttribute("tabindex", "0"); await expect .poll(async () => (await visibleBounds(sculpture)).y) .toBeGreaterThan(90); @@ -158,7 +155,6 @@ test.describe("landing sculpture touch gestures", () => { throw new Error("The opening scene must be present"); window.scrollTo(0, (hero.offsetHeight - viewport.offsetHeight) * 0.76); }); - await expect(sculpture).toHaveAttribute("tabindex", "0"); await expect .poll(async () => (await visibleBounds(sculpture)).width) .toBeGreaterThan(initialWidth * 1.2); @@ -200,7 +196,7 @@ test("landing sculpture keeps mouse and keyboard rotation", async ({ const sculpture = page.getByRole("application", { name: "Interactive 3D database sculpture", }); - await expect(sculpture).toHaveAttribute("tabindex", "0", { timeout: 30_000 }); + await expect(sculpture).toBeVisible({ timeout: 30_000 }); const canvas = page.locator("canvas"); const initial = await canvas.screenshot(); const rect = await visibleBounds(sculpture); diff --git a/tests/end-to-end/landing.spec.ts b/tests/end-to-end/landing.spec.ts index 66e0a6374..40003275d 100644 --- a/tests/end-to-end/landing.spec.ts +++ b/tests/end-to-end/landing.spec.ts @@ -467,8 +467,8 @@ test("landing page: live components, deployment and mobile navigation", async ({ .getByRole("tab", { name: "save.sql", exact: true }) .press("ArrowLeft"); await expect( - page.getByRole("tab", { name: "form.sql", exact: true }), - ).toHaveAttribute("aria-selected", "true"); + page.getByRole("tab", { name: "form.sql", exact: true, selected: true }), + ).toBeVisible(); await expect(page.locator("#demo-source")).toContainText( "/landing-demos/save.sql", ); @@ -505,26 +505,16 @@ test("landing page: live components, deployment and mobile navigation", async ({ await page .getByRole("button", { name: "A SQLPage app", exact: true }) .click(); - await expect(page.locator(".stack-comparison")).toHaveAttribute( - "data-stack", - "sqlpage", - ); - const comparison = page.locator(".stack-comparison"); - await expect( - comparison.locator('[data-stack-copy="sqlpage"]').last(), - ).toHaveAttribute("aria-hidden", "false"); + const oidc = page.getByText("built-in OIDC + state in db", { exact: true }); + await expect(oidc).toHaveCSS("opacity", "1"); await page .getByRole("button", { name: "A typical webapp", exact: true }) .click(); - await expect(comparison).toHaveAttribute("data-stack", "typical"); - await expect( - comparison.locator('[data-stack-copy="sqlpage"]').last(), - ).toHaveAttribute("aria-hidden", "true"); + await expect(oidc).toHaveCSS("opacity", "0"); const features = page.getByRole("tablist", { name: "Frontend features" }); - await expect(features.getByRole("tab", { name: "Instant" })).toHaveAttribute( - "aria-selected", - "true", - ); + await expect( + features.getByRole("tab", { name: "Instant", selected: true }), + ).toBeVisible(); await expect(page.locator("#instant-panel")).toBeVisible(); for (const [name, id] of [ ["Make it yours", "customize"], diff --git a/tests/end-to-end/official-site-accessibility.spec.ts b/tests/end-to-end/official-site-accessibility.spec.ts index 15c4b4d29..d013c4397 100644 --- a/tests/end-to-end/official-site-accessibility.spec.ts +++ b/tests/end-to-end/official-site-accessibility.spec.ts @@ -1,7 +1,6 @@ import { AxeBuilder } from "@axe-core/playwright"; import { expect, test } from "@playwright/test"; - -const wcagTags = ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"]; +import { wcagTags } from "./accessibility.ts"; const themes = ["documentation", "light", "dark"] as const; type Theme = (typeof themes)[number]; diff --git a/tests/end-to-end/official-site.spec.ts b/tests/end-to-end/official-site.spec.ts index bcf0d93ef..c77e54c2c 100644 --- a/tests/end-to-end/official-site.spec.ts +++ b/tests/end-to-end/official-site.spec.ts @@ -1,10 +1,5 @@ import { expect, type Locator, type Page, test } from "@playwright/test"; -import { - checkModal, - checkTableFiltering, - checkTableSort, - checkToastNotifications, -} from "./component-assertions.ts"; +import { checkModal, checkTableFiltering } from "./component-assertions.ts"; test("Open documentation", async ({ page }) => { await page.goto("/"); @@ -506,7 +501,6 @@ test("chart documentation renders its examples without browser errors", async ({ await expect(page.getByText("Loading...")).toHaveCount(0, { timeout: 15_000, }); - await expect(page.locator('[data-pre-init="chart"]')).toHaveCount(0); const examples = page.locator( '[data-sqlpage-js*="apexcharts."], [data-embed]', ); @@ -520,13 +514,9 @@ test("chart documentation renders its examples without browser errors", async ({ const expenses = page.locator(".card").filter({ has: page.getByRole("heading", { name: "Expenses", exact: true }), }); - await expect(expenses.locator(".apexcharts-canvas")).toHaveClass( - /\bapexcharts-theme-dark\b/, - ); const toggle = expenses.getByRole("button", { name: "Menu", exact: true }); const menu = expenses.getByRole("menu"); await toggle.press("ArrowDown"); - await expect(toggle).toHaveAttribute("aria-expanded", "true"); await expect( menu.getByRole("menuitem", { name: "Download SVG" }), ).toBeFocused(); @@ -543,8 +533,13 @@ test("chart documentation renders its examples without browser errors", async ({ await expect(option).toHaveCSS("background-color", hoverColor); await page.keyboard.press("Escape"); - await expect(toggle).toHaveAttribute("aria-expanded", "false"); - await expect(toggle).toBeFocused(); + await expect( + expenses.getByRole("button", { + name: "Menu", + exact: true, + expanded: false, + }), + ).toBeFocused(); }); expect(errors).toEqual([]); }); @@ -603,11 +598,14 @@ test("map marker titles are readable when opened in the dark theme", async ({ await expectContrast(popup.getByRole("button", { name: "Close popup" }), 4.5); }); -test("toast notifications initialize, stack, dismiss, and render safely (page)", async ({ - page, -}) => { +test("the toast documentation example can be dismissed", async ({ page }) => { await page.goto("/documentation.sql?component=toast#component"); - await checkToastNotifications(page); + const notification = page.getByText("This is a SQLPage toast", { + exact: true, + }); + await expect(notification).toBeVisible(); + await page.getByRole("button", { name: "Close notification" }).click(); + await expect(notification).toBeHidden(); }); test("the layout demo keeps its brand when switching to a sidebar", async ({ @@ -713,27 +711,6 @@ test("table filtering (page)", async ({ page }) => { await checkTableFiltering(page); }); -test("table sorts a column when its header is clicked (page)", async ({ - page, -}) => { - await page.goto("/documentation.sql?component=table"); - await checkTableSort(page, "id"); -}); - -test("table reverses the sort when the header is clicked again (page)", async ({ - page, -}) => { - await page.goto("/documentation.sql?component=table"); - await checkTableSort(page, "id", true); -}); - -test("table sorts a column of formatted numbers by value (page)", async ({ - page, -}) => { - await page.goto("/documentation.sql?component=table"); - await checkTableSort(page, "Amount in stock"); -}); - async function checkNoConsoleErrors(page: Page, component: string) { const errors: string[] = []; page.on("console", (msg) => { diff --git a/tests/end-to-end/playwright.config.ts b/tests/end-to-end/playwright.config.ts index a9a8efe98..fae209a20 100644 --- a/tests/end-to-end/playwright.config.ts +++ b/tests/end-to-end/playwright.config.ts @@ -71,6 +71,15 @@ export default defineConfig({ testMatch: "fixtures/**/test.ts", use: { ...devices["Desktop Chrome"], baseURL: fixtures.url }, }, + ...(process.env.AXE_FIXTURES === "1" + ? [ + { + name: "fixture-accessibility", + testMatch: "fixtures.axe.ts", + use: { ...devices["Desktop Chrome"], baseURL: fixtures.url }, + }, + ] + : []), ], webServer: [ { From a52ecc166aabcf869f309060fd9971adda5b797c Mon Sep 17 00:00:00 2001 From: Ophir Lojkine Date: Mon, 30 Nov 2026 10:57:23 +0000 Subject: [PATCH 2/3] Omit empty shell home links and use readable fixture colors --- CHANGELOG.md | 1 + .../sqlpage/migrations/01_documentation.sql | 2 +- sqlpage/templates/shell.handlebars | 14 ++++++++++---- tests/end-to-end/fixtures.axe.ts | 17 +++++++---------- .../end-to-end/fixtures/shell-search/index.sql | 2 ++ tests/end-to-end/fixtures/shell-search/test.ts | 9 +++++++++ tests/end-to-end/fixtures/status-bar/index.sql | 2 +- tests/end-to-end/fixtures/tab/colored/index.sql | 4 ++-- tests/end-to-end/fixtures/tab/colored/test.ts | 4 ++-- 9 files changed, 35 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67191b615..87c974d79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Disabled buttons expose their state to assistive technology and cannot be activated. - Tracking blocks without links now expose their titles to screen readers. - The `shell` sidebar now uses `navbar_title` and preserves the colors of the supplied logo in dark mode. +- Keyboard users no longer encounter empty home links in the `shell` navigation. Logo-only home links have an accessible name. - Chart export menus, tooltips, and series colors now follow the theme surrounding each chart, including in custom shells. Chart labels on colored marks have a contrasting outline that carries over to SVG downloads. - Map marker popups follow the surrounding theme so their titles and links stay readable. Map attribution links are underlined. - Each `login` component’s labels target its own fields. Set `false AS autofocus` to keep the username field from taking focus when the page opens. diff --git a/examples/official-site/sqlpage/migrations/01_documentation.sql b/examples/official-site/sqlpage/migrations/01_documentation.sql index 9063fa289..31cd392cd 100644 --- a/examples/official-site/sqlpage/migrations/01_documentation.sql +++ b/examples/official-site/sqlpage/migrations/01_documentation.sql @@ -1549,7 +1549,7 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S ('theme', 'Set to "dark" to use a dark theme.', 'TEXT', TRUE, TRUE), ('footer', 'Muted text to display in the footer of the page. This can be used to display a link to the terms and conditions of your application, for instance. By default, shows "Built with SQLPage". Supports links with markdown.', 'TEXT', TRUE, TRUE), ('preview_image', 'The URL of an image to display as a link preview when the page is shared on social media', 'URL', TRUE, TRUE), - ('navbar_title', 'The title shown in the navigation bar or sidebar. Defaults to the page title. Set an empty string to show just the logo.', 'TEXT', TRUE, TRUE), + ('navbar_title', 'The title shown in the navigation bar or sidebar. Defaults to the page title. Set an empty string to show just the logo, if configured. With neither a navigation title nor a logo, there is no home link in the navigation bar.', 'TEXT', TRUE, TRUE), ('target', 'Where the menu items should open: "_blank" for a new tab, "_self" for the same tab, "_parent" for the parent frame, or "_top" for the full body of the window. Set it inside a "menu_item" json object; it has no effect when set directly on the shell.', 'TEXT', TRUE, TRUE), ('class', 'class attribute added to the page''s html element. It can be used to apply custom styling to the whole page through css.', 'TEXT', TRUE, TRUE) ) x; diff --git a/sqlpage/templates/shell.handlebars b/sqlpage/templates/shell.handlebars index deb86cefd..001f35a75 100644 --- a/sqlpage/templates/shell.handlebars +++ b/sqlpage/templates/shell.handlebars @@ -174,15 +174,17 @@ - + {{#if (any image icon (default navbar_title title))}} + {{#if image}} - {{#unless (default navbar_title title)}}{{default title 'Home'}}{{/unless}} + {{/if}} {{#if icon}} {{~icon_img icon~}} {{/if}} {{default navbar_title title}} + {{/if}} @@ -191,16 +193,20 @@ {{else}}