Skip to content

Commit

Permalink
fix: tests for only one locale
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviareichl committed Oct 2, 2024
1 parent 90b0609 commit b1a9674
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion e2e/lib/fixtures/imprint-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class ImprintPage {
this.page = page;
this.locale = locale;
this.i18n = i18n;
this.url = `/${locale}/imprint`;
this.url = `/imprint`;
this.mainContent = page.getByRole("main");
this.title = page.getByRole("heading", { level: 1 });
this.skipLink = page.getByRole("link", { name: i18n.t("DefaultLayout.skip-to-main-content") });
Expand Down
2 changes: 1 addition & 1 deletion e2e/lib/fixtures/index-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class IndexPage {
this.page = page;
this.locale = locale;
this.i18n = i18n;
this.url = `/${locale}`;
this.url = `/`;
this.mainContent = page.getByRole("main");
this.title = page.getByRole("heading", { level: 1 });
this.skipLink = page.getByRole("link", { name: i18n.t("DefaultLayout.skip-to-main-content") });
Expand Down
15 changes: 6 additions & 9 deletions e2e/tests/app/metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createUrl } from "@acdh-oeaw/lib";

import { locales } from "@/config/i18n.config";
import { expect, test } from "@/e2e/lib/test";
import { ensureTrailingSlash } from "@/utils/ensure-trailing-slash";
import { escape } from "@/utils/safe-json-ld-replacer";

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand All @@ -12,10 +13,9 @@ test("should set a canonical url", async ({ createIndexPage }) => {
const { indexPage } = await createIndexPage(locale);
await indexPage.goto();

const canonicalUrl = indexPage.page.locator('link[rel="canonical"]');
await expect(canonicalUrl).toHaveAttribute(
"href",
String(createUrl({ baseUrl, pathname: `/${locale}` })),
const canonicalUrl = await indexPage.page.locator('link[rel="canonical"]').getAttribute("href");
expect(ensureTrailingSlash(String(canonicalUrl))).toBe(
String(createUrl({ baseUrl, pathname: `/` })),
);
}
});
Expand Down Expand Up @@ -80,11 +80,8 @@ test("should set page metadata", async ({ createIndexPage }) => {
const ogDescription = page.locator('meta[property="og:description"]');
await expect(ogDescription).toHaveAttribute("content", i18n.t("Metadata.description"));

const ogUrl = page.locator('meta[property="og:url"]');
await expect(ogUrl).toHaveAttribute(
"content",
String(createUrl({ baseUrl, pathname: `/${locale}` })),
);
const ogUrl = await page.locator('meta[property="og:url"]').getAttribute("content");
expect(ensureTrailingSlash(String(ogUrl))).toBe(String(createUrl({ baseUrl, pathname: `/` })));

const ogLocale = page.locator('meta[property="og:locale"]');
await expect(ogLocale).toHaveAttribute("content", locale);
Expand Down
6 changes: 3 additions & 3 deletions messages/de/project.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"__cms__": true,
"Metadata": {
"name": "OpenAtlas Discovery",
"shortName": "OpenAtlas Discovery",
"description": "OpenAtlas ist eine Open-Source-Datenbanksoftware, die speziell für die Erfassung, Bearbeitung und Verwaltung von Forschungsdaten aus verschiedenen Bereichen der Geisteswissenschaften entwickelt wurde."
"name": "FemCare Vienna",
"shortName": "FemCare Vienna",
"description": "Das Projekt **FemCare Vienna** (FWF-Einzelstipendium P 36459-G) hat das Ziel, die Geschichte der medizinischen Betreuung von Frauen durch eine interdisziplinäre Untersuchung der historischen und bioarchäologischen Aufzeichnungen im Zusammenhang mit dem Krankenhaus der Elisabethianer in Wien aufzuklären. Im Mittelpunkt des Projekts stehen die Lebensgeschichten von 390 Patienten aus dem 18. Jahrhundert, deren menschliche Skelettreste auf dem Krankenhausfriedhof ausgegraben wurden."
}
}
2 changes: 1 addition & 1 deletion server/routes/manifest.webmanifest.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createI18n } from "vue-i18n";
import de from "@/messages/de/common.json";
import projectDe from "@/messages/de/project.json";

const locale = "en";
const locale = "de";

const { t } = createI18n({
legacy: false,
Expand Down
3 changes: 3 additions & 0 deletions utils/ensure-trailing-slash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function ensureTrailingSlash(url: string): string {
return url.endsWith("/") ? url : `${url}/`;
}

0 comments on commit b1a9674

Please sign in to comment.