diff --git a/roles/web-app-sphinx/files/playwright/test-design.js b/roles/web-app-sphinx/files/playwright/test-design.js index e0be047f5c..e0633198d3 100644 --- a/roles/web-app-sphinx/files/playwright/test-design.js +++ b/roles/web-app-sphinx/files/playwright/test-design.js @@ -16,6 +16,7 @@ const base = normalizeBaseUrl(process.env.APP_BASE_URL || ""); const logoUrl = decodeDotenvQuotedValue(process.env.DESIGN_LOGO_URL || ""); const iconUrl = decodeDotenvQuotedValue(process.env.DESIGN_ICON_URL || ""); const faviconUrl = decodeDotenvQuotedValue(process.env.DESIGN_FAVICON_URL || ""); +const designTitle = decodeDotenvQuotedValue(process.env.DESIGN_TITLE || ""); const MODES = ["light", "dark"]; const MAIN = "main"; @@ -320,6 +321,23 @@ test("design: logo, icon and favicon come from the design lookup", async ({ page } }); +test("design: the documentation renders the configured title in the tab, header, breadcrumbs and drawer", async ({ + page, +}) => { + skipUnlessServiceEnabled("design"); + test.skip(!designTitle, "title replacement is disabled for this role"); + const escaped = designTitle.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + await page.setViewportSize({ width: 1440, height: 900 }); + await open(page, ROLE_README); + await expect(page).toHaveTitle(new RegExp(`\\| ${escaped}$`)); + await expect(page.locator("header a > span.font-bold")).toHaveText(designTitle); + await expect(page.locator(`${BREADCRUMBS} > a:first-child > span`)).toHaveText(designTitle); + await page.setViewportSize({ width: 390, height: 844 }); + await open(page, "/"); + await openSidebar(page); + await expect(page.locator(`${SIDEBAR} > a > span.font-bold`)).toHaveText(designTitle); +}); + test("design: gallery of index, guides, role pages, generated pages, search, sidebar and switch states", async ({ page, }) => { diff --git a/roles/web-app-sphinx/meta/services.yml b/roles/web-app-sphinx/meta/services.yml index 461c5f21f7..486a299c4f 100644 --- a/roles/web-app-sphinx/meta/services.yml +++ b/roles/web-app-sphinx/meta/services.yml @@ -26,6 +26,7 @@ sphinx: enabled: true image: ghcr.io/kevinveenbirkenbach/infinito-sphinx version: v1.0.70 + custom: true min_storage: 1931MB backup: no_stop_required: true diff --git a/roles/web-app-sphinx/templates/Dockerfile.j2 b/roles/web-app-sphinx/templates/Dockerfile.j2 new file mode 100644 index 0000000000..e3a363b27c --- /dev/null +++ b/roles/web-app-sphinx/templates/Dockerfile.j2 @@ -0,0 +1,4 @@ +FROM {{ SPHINX_IMAGE }}:{{ SPHINX_VERSION }} +{% if SPHINX_DESIGN_TITLE | length > 0 %} +RUN sphinx-build -M html "${INFINITO_SRC_DIR}" "${SPHINX_OUTPUT_DIR}" -c "${SPHINX_EXEC_DIR}src/infinito_docs" -D html_title={{ SPHINX_DESIGN_TITLE | quote }} +{% endif %} diff --git a/roles/web-app-sphinx/templates/compose.yml.j2 b/roles/web-app-sphinx/templates/compose.yml.j2 index 7515185d51..7163f24192 100644 --- a/roles/web-app-sphinx/templates/compose.yml.j2 +++ b/roles/web-app-sphinx/templates/compose.yml.j2 @@ -4,6 +4,7 @@ {% include 'roles/sys-svc-container/templates/base.yml.j2' %} {{ lookup('container_image', application_id, 'sphinx') }} {{ lookup('compose_only', 'container_name', SPHINX_CONTAINER) }} + {{ lookup('template', 'roles/sys-svc-container/templates/build.yml.j2') | indent(4) }} {{ lookup('container_ports', ['sphinx', 'http', DOCKER_BIND_HOST]) | indent(4) }} {{ lookup('container_healthcheck', service_name) | indent(4) }} {{ lookup('container_networks') | indent(4) }} diff --git a/roles/web-app-sphinx/templates/playwright.env.j2 b/roles/web-app-sphinx/templates/playwright.env.j2 index dc85bdac89..5b6c90e7d8 100644 --- a/roles/web-app-sphinx/templates/playwright.env.j2 +++ b/roles/web-app-sphinx/templates/playwright.env.j2 @@ -10,6 +10,8 @@ DESIGN_LOGO_URL={{ (lookup('design', application_id).urls['sidebar-logo'].svg if DESIGN_SERVICE_ENABLED={{ lookup('config', application_id, 'services.design.enabled') | string | lower }} +DESIGN_TITLE={{ (lookup('design', application_id).title if lookup('design', application_id).title is string else '') | dotenv_quote }} + # nocheck: playwright-service-gate — covered by sys-svc-mail integration tests, not the persona surface EMAIL_SERVICE_ENABLED={{ lookup('config', application_id, 'services.email.enabled') | string | lower }} diff --git a/roles/web-app-sphinx/vars/main.yml b/roles/web-app-sphinx/vars/main.yml index f7c9dd3318..f53ca43cd3 100644 --- a/roles/web-app-sphinx/vars/main.yml +++ b/roles/web-app-sphinx/vars/main.yml @@ -3,3 +3,7 @@ application_id: "web-app-sphinx" entity_name: "{{ application_id | get_entity_name }}" SPHINX_CONTAINER: "{{ lookup('config', application_id, 'services.' ~ entity_name ~ '.name') }}" +SPHINX_IMAGE: "{{ lookup('config', application_id, 'services.' ~ entity_name ~ '.image') }}" +SPHINX_VERSION: "{{ lookup('config', application_id, 'services.' ~ entity_name ~ '.version') }}" +SPHINX_DESIGN_TITLE: "{{ lookup('design', application_id).title if (lookup('config', application_id, 'services.design.enabled') | bool) and lookup('design', application_id).title + is string else '' }}"