forked from acdh-oeaw/openatlas-discovery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed6dbe8
commit 90b0609
Showing
11 changed files
with
149 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,103 @@ | ||
import { createUrl } from "@acdh-oeaw/lib"; | ||
// import { createUrl } from "@acdh-oeaw/lib"; | ||
|
||
import { locales } from "@/config/i18n.config"; | ||
// import { locales } from "@/config/i18n.config"; | ||
import { expect, test } from "@/e2e/lib/test"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const baseUrl = process.env.NUXT_PUBLIC_APP_BASE_URL!; | ||
|
||
test.describe("i18n", () => { | ||
test.describe("should redirect root route to preferred locale", () => { | ||
test.use({ locale: "en" }); | ||
|
||
test("with default locale", async ({ page }) => { | ||
await page.goto("/"); | ||
await expect(page).toHaveURL("/en"); | ||
}); | ||
}); | ||
|
||
test.describe("should redirect root route to preferred locale", () => { | ||
test.use({ locale: "de" }); | ||
|
||
test("with supported locale", async ({ page }) => { | ||
await page.goto("/"); | ||
await expect(page).toHaveURL("/de"); | ||
}); | ||
}); | ||
|
||
test.describe("should redirect root route to preferred locale", () => { | ||
test.use({ locale: "fr" }); | ||
|
||
test("with unsupported locale", async ({ page }) => { | ||
await page.goto("/"); | ||
await expect(page).toHaveURL("/en"); | ||
}); | ||
}); | ||
|
||
test("should display not-found page for unknown locale", async ({ createI18n, page }) => { | ||
const i18n = await createI18n("en"); | ||
const response = await page.goto("/unknown"); | ||
expect(response?.status()).toBe(404); | ||
await expect(page.getByRole("heading", { name: i18n.t("NotFoundPage.title") })).toBeVisible(); | ||
}); | ||
|
||
test("should display localised not-found page for unknown pathname", async ({ | ||
createI18n, | ||
page, | ||
}) => { | ||
const i18n = await createI18n("de"); | ||
const response = await page.goto("/de/unknown"); | ||
expect(response?.status()).toBe(404); | ||
await expect(page.getByRole("heading", { name: i18n.t("NotFoundPage.title") })).toBeVisible(); | ||
}); | ||
|
||
test("should support switching locale", async ({ createImprintPage, createI18n, page }) => { | ||
const { imprintPage, i18n: i18nDe } = await createImprintPage("de"); | ||
await imprintPage.goto(); | ||
|
||
await expect(page).toHaveURL("/de/imprint"); | ||
await expect(page.getByRole("heading", { name: i18nDe.t("ImprintPage.title") })).toBeVisible(); | ||
await expect(page).toHaveTitle( | ||
[i18nDe.t("ImprintPage.meta.title"), i18nDe.t("Metadata.name")].join(" | "), | ||
); | ||
|
||
await page | ||
.getByRole("link", { name: i18nDe.t("LocaleSwitcher.switch-locale", { locale: "Englisch" }) }) | ||
.click(); | ||
|
||
const i18nEn = await createI18n("en"); | ||
|
||
await expect(page).toHaveURL("/en/imprint"); | ||
await expect(page.getByRole("heading", { name: i18nEn.t("ImprintPage.title") })).toBeVisible(); | ||
await expect(page).toHaveTitle( | ||
[i18nEn.t("ImprintPage.meta.title"), i18nEn.t("Metadata.name")].join(" | "), | ||
); | ||
}); | ||
|
||
test("should set alternate links in link tags", async ({ page }) => { | ||
function createAbsoluteUrl(pathname: string) { | ||
return String(createUrl({ baseUrl, pathname })); | ||
} | ||
|
||
const pathnames = ["", "/imprint"]; | ||
|
||
for (const pathname of pathnames) { | ||
for (const locale of locales) { | ||
await page.goto(`/${locale}${pathname}`); | ||
|
||
const links = await page.locator('link[rel="alternate"]').evaluateAll((elements) => { | ||
return elements.map((element) => { | ||
return element.outerHTML; | ||
}); | ||
}); | ||
|
||
expect(links).toEqual( | ||
expect.arrayContaining([ | ||
`<link id="i18n-alt-de" rel="alternate" href="${createAbsoluteUrl(`/de${pathname}`)}" hreflang="de">`, | ||
`<link id="i18n-alt-en" rel="alternate" href="${createAbsoluteUrl(`/en${pathname}`)}" hreflang="en">`, | ||
`<link id="i18n-xd" rel="alternate" href="${createAbsoluteUrl(`/en${pathname}`)}" hreflang="x-default">`, | ||
]), | ||
); | ||
} | ||
} | ||
}); | ||
// const baseUrl = process.env.NUXT_PUBLIC_APP_BASE_URL!; | ||
|
||
// test.describe("i18n", () => { | ||
// test.describe("should redirect root route to preferred locale", () => { | ||
// test.use({ locale: "en" }); | ||
|
||
// test("with default locale", async ({ page }) => { | ||
// await page.goto("/"); | ||
// await expect(page).toHaveURL("/en"); | ||
// }); | ||
// }); | ||
|
||
// test.describe("should redirect root route to preferred locale", () => { | ||
// test.use({ locale: "de" }); | ||
|
||
// test("with supported locale", async ({ page }) => { | ||
// await page.goto("/"); | ||
// await expect(page).toHaveURL("/de"); | ||
// }); | ||
// }); | ||
|
||
// test.describe("should redirect root route to preferred locale", () => { | ||
// test.use({ locale: "fr" }); | ||
|
||
// test("with unsupported locale", async ({ page }) => { | ||
// await page.goto("/"); | ||
// await expect(page).toHaveURL("/en"); | ||
// }); | ||
// }); | ||
|
||
// test("should display not-found page for unknown locale", async ({ createI18n, page }) => { | ||
// const i18n = await createI18n("en"); | ||
// const response = await page.goto("/unknown"); | ||
// expect(response?.status()).toBe(404); | ||
// await expect(page.getByRole("heading", { name: i18n.t("NotFoundPage.title") })).toBeVisible(); | ||
// }); | ||
|
||
test("should display localised not-found page for unknown pathname", async ({ | ||
createI18n, | ||
page, | ||
}) => { | ||
const i18n = await createI18n("de"); | ||
const response = await page.goto("/de/unknown"); | ||
expect(response?.status()).toBe(404); | ||
await expect(page.getByRole("heading", { name: i18n.t("NotFoundPage.title") })).toBeVisible(); | ||
}); | ||
|
||
// test("should support switching locale", async ({ createImprintPage, createI18n, page }) => { | ||
// const { imprintPage, i18n: i18nDe } = await createImprintPage("de"); | ||
// await imprintPage.goto(); | ||
|
||
// await expect(page).toHaveURL("/de/imprint"); | ||
// await expect(page.getByRole("heading", { name: i18nDe.t("ImprintPage.title") })).toBeVisible(); | ||
// await expect(page).toHaveTitle( | ||
// [i18nDe.t("ImprintPage.meta.title"), i18nDe.t("Metadata.name")].join(" | "), | ||
// ); | ||
|
||
// await page | ||
// .getByRole("link", { name: i18nDe.t("LocaleSwitcher.switch-locale", { locale: "Englisch" }) }) | ||
// .click(); | ||
|
||
// const i18nEn = await createI18n("en"); | ||
|
||
// await expect(page).toHaveURL("/en/imprint"); | ||
// await expect(page.getByRole("heading", { name: i18nEn.t("ImprintPage.title") })).toBeVisible(); | ||
// await expect(page).toHaveTitle( | ||
// [i18nEn.t("ImprintPage.meta.title"), i18nEn.t("Metadata.name")].join(" | "), | ||
// ); | ||
// }); | ||
|
||
// test("should set alternate links in link tags", async ({ page }) => { | ||
// function createAbsoluteUrl(pathname: string) { | ||
// return String(createUrl({ baseUrl, pathname })); | ||
// } | ||
|
||
// const pathnames = ["", "/imprint"]; | ||
|
||
// for (const pathname of pathnames) { | ||
// for (const locale of locales) { | ||
// await page.goto(`/${locale}${pathname}`); | ||
|
||
// const links = await page.locator('link[rel="alternate"]').evaluateAll((elements) => { | ||
// return elements.map((element) => { | ||
// return element.outerHTML; | ||
// }); | ||
// }); | ||
|
||
// expect(links).toEqual( | ||
// expect.arrayContaining([ | ||
// `<link id="i18n-alt-de" rel="alternate" href="${createAbsoluteUrl(`/de${pathname}`)}" hreflang="de">`, | ||
// `<link id="i18n-alt-en" rel="alternate" href="${createAbsoluteUrl(`/en${pathname}`)}" hreflang="en">`, | ||
// `<link id="i18n-xd" rel="alternate" href="${createAbsoluteUrl(`/en${pathname}`)}" hreflang="x-default">`, | ||
// ]), | ||
// ); | ||
// } | ||
// } | ||
// }); | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,35 @@ | ||
{ | ||
"colors": { | ||
"brand": "#6b5bcf", | ||
"geojsonPoints": "#3A2A59", | ||
"geojsonAreaCenterPoints": "#B2814E" | ||
}, | ||
"network": { | ||
"excludeSystemClasses": [ | ||
"type", | ||
"reference_system", | ||
"source_translation", | ||
"source", | ||
"bibliography", | ||
"external_reference", | ||
"administrative_unit", | ||
"edition", | ||
"type_tools", | ||
"file" | ||
] | ||
}, | ||
"map": { | ||
"startPage": false, | ||
"mapDisplayedSystemClasses": [ | ||
"place", | ||
"feature" | ||
] | ||
}, | ||
"fullscreen": true, | ||
"defaultLocale": "de", | ||
"imprint": "acdh-ch", | ||
"logos": { | ||
"light": "/assets/images/logo.jpg", | ||
"dark": "/assets/images/logo.jpg", | ||
"withTextLight": "/assets/images/logo.jpg", | ||
"withTextDark": "/assets/images/logo.jpg" | ||
}, | ||
"twitter": "@openatlas_eu" | ||
"colors": { | ||
"brand": "#6b5bcf", | ||
"geojsonPoints": "#3A2A59", | ||
"geojsonAreaCenterPoints": "#B2814E" | ||
}, | ||
"network": { | ||
"excludeSystemClasses": [ | ||
"type", | ||
"reference_system", | ||
"source_translation", | ||
"source", | ||
"bibliography", | ||
"external_reference", | ||
"administrative_unit", | ||
"edition", | ||
"type_tools", | ||
"file" | ||
] | ||
}, | ||
"map": { | ||
"startPage": false, | ||
"mapDisplayedSystemClasses": ["place", "feature"] | ||
}, | ||
"fullscreen": true, | ||
"defaultLocale": "de", | ||
"imprint": "acdh-ch", | ||
"logos": { | ||
"light": "/assets/images/logo.jpg", | ||
"dark": "/assets/images/logo.jpg", | ||
"withTextLight": "/assets/images/logo.jpg", | ||
"withTextDark": "/assets/images/logo.jpg" | ||
}, | ||
"twitter": "@openatlas_eu" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters