Skip to content

Commit

Permalink
chore: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst committed Jun 9, 2024
1 parent e3415a0 commit 232df10
Show file tree
Hide file tree
Showing 15 changed files with 217 additions and 406 deletions.
2 changes: 1 addition & 1 deletion .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# -------------------------------------------------------------------------------------------------
# - public environment variables must be prefixed with `PUBLIC_`.
# - when adding new environment variables, don't forget to also update the
# validation schema in `./config/env.config.ts`.
# validation schema in `./src/config/env.config.ts`.

# -------------------------------------------------------------------------------------------------
# app
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ jobs:
# "PUBLIC_APP_BASE_URL=${{ needs.vars.outputs.public_url }}"
"PUBLIC_APP_BASE_URL=${{ vars.PUBLIC_APP_BASE_URL }}"
"PUBLIC_BOTS=${{ vars.PUBLIC_BOTS }}"
"PUBLIC_GOOGLE_SITE_VERIFICATION=${{ vars.PUBLIC_GOOGLE_SITE_VERIFICATION }}"
"PUBLIC_KEYSTATIC_GITHUB_APP_SLUG=${{ vars.PUBLIC_KEYSTATIC_GITHUB_APP_SLUG }}"
"PUBLIC_KEYSTATIC_GITHUB_REPO_NAME=${{ vars.PUBLIC_KEYSTATIC_GITHUB_REPO_NAME }}"
"PUBLIC_KEYSTATIC_GITHUB_REPO_OWNER=${{ vars.PUBLIC_KEYSTATIC_GITHUB_REPO_OWNER }}"
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ COPY --chown=node:node ./node_modules/.astro ./node_modules/.astro
ARG PUBLIC_APP_BASE_PATH
ARG PUBLIC_APP_BASE_URL
ARG PUBLIC_BOTS
ARG PUBLIC_GOOGLE_SITE_VERIFICATION
ARG PUBLIC_KEYSTATIC_GITHUB_APP_SLUG
ARG PUBLIC_KEYSTATIC_GITHUB_REPO_NAME
ARG PUBLIC_KEYSTATIC_GITHUB_REPO_OWNER
Expand Down
5 changes: 1 addition & 4 deletions Dockerfile.static
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ RUN sed -i "s/use-node-version/# use-node-version/" .npmrc
ARG PUBLIC_APP_BASE_PATH
ARG PUBLIC_APP_BASE_URL
ARG PUBLIC_BOTS
ARG PUBLIC_KEYSTATIC_GITHUB_APP_SLUG
ARG PUBLIC_KEYSTATIC_GITHUB_REPO_NAME
ARG PUBLIC_KEYSTATIC_GITHUB_REPO_OWNER
ARG PUBLIC_KEYSTATIC_MODE
ARG PUBLIC_GOOGLE_SITE_VERIFICATION
ARG PUBLIC_MATOMO_BASE_URL
ARG PUBLIC_MATOMO_ID
ARG PUBLIC_REDMINE_ID
Expand Down
4 changes: 2 additions & 2 deletions e2e/lib/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IndexPage } from "~/e2e/lib/fixtures/index-page";

interface Fixtures {
createAccessibilityScanner: () => Promise<AccessibilityScanner>;
createI18n: (locale: Locale) => Promise<I18n>;
createI18n: (locale?: Locale) => Promise<I18n>;
createImprintPage: (locale?: Locale) => Promise<WithI18n<{ imprintPage: ImprintPage }>>;
createIndexPage: (locale?: Locale) => Promise<WithI18n<{ indexPage: IndexPage }>>;
}
Expand All @@ -21,7 +21,7 @@ export const test = base.extend<Fixtures>({
},

async createI18n({ page }, use) {
await use((locale) => {
await use((locale = defaultLocale) => {
return createI18n(page, locale);
});
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions e2e/tests/app/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ test.describe("app", () => {
}
});

test("should serve a webmanifest", async ({ request }) => {
test("should serve a webmanifest", async ({ createI18n, request }) => {
const response = await request.get("/manifest.webmanifest");
const body = await response.body();

// TODO: use toMatchSnapshot
const i18n = await createI18n();

expect(body.toString()).toEqual(
JSON.stringify({
name: "Nomad's Manuscripts Landscape",
short_name: "NoMansLand",
description:
"Investigating Literary Evidence for Transculturation in Medieval Iran and Central Asia in the 13th – 15th centuries.",
name: i18n.t("metadata.title"),
short_name: i18n.t("metadata.shortTitle"),
description: i18n.t("metadata.description"),
icons: [
{ src: "/android-chrome-192x192.png", sizes: "192x192", type: "image/png" },
{ src: "/android-chrome-512x512.png", sizes: "512x512", type: "image/png" },
Expand Down
54 changes: 28 additions & 26 deletions e2e/tests/app/metadata.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { createUrl } from "@acdh-oeaw/lib";

import { defaultLocale } from "@/config/i18n.config";
import { escape } from "@/lib/safe-json-ld-replacer";
import { expect, test } from "~/e2e/lib/test";

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand All @@ -13,9 +15,12 @@ test("should set a canonical url", async ({ createIndexPage }) => {
await expect(canonicalUrl).toHaveAttribute("href", String(createUrl({ baseUrl, pathname: "/" })));
});

test("should set document title on not-found page", async ({ page }) => {
test("should set document title on not-found page", async ({ createI18n, page }) => {
const i18n = await createI18n();
await page.goto("/unknown/");
await expect(page).toHaveTitle("Page not found | Nomad's Manuscripts Landscape");
await expect(page).toHaveTitle(
[i18n.t("NotFoundPage.meta.title"), i18n.t("metadata.title")].join(" | "),
);
});

test("should disallow indexing of not-found page", async ({ page }) => {
Expand All @@ -25,58 +30,56 @@ test("should disallow indexing of not-found page", async ({ page }) => {
await expect(ogTitle).toHaveAttribute("content", "noindex");
});

// eslint-disable-next-line playwright/no-skipped-test
test.skip("should set page metadata", async ({ createIndexPage }) => {
const { indexPage } = await createIndexPage();
test("should set page metadata", async ({ createIndexPage }) => {
const { indexPage, i18n } = await createIndexPage();
await indexPage.goto();

const { page } = indexPage;

expect(i18n.t("metadata.title")).toBeTruthy();
expect(i18n.t("metadata.shortTitle")).toBeTruthy();
expect(i18n.t("metadata.description")).toBeTruthy();

const ogType = page.locator('meta[property="og:type"]');
await expect(ogType).toHaveAttribute("content", "website");

const twCard = page.locator('meta[name="twitter:card"]');
await expect(twCard).toHaveAttribute("content", "summary_large_image");

const twCreator = page.locator('meta[name="twitter:creator"]');
await expect(twCreator).toHaveAttribute("content", "@NoMansLand_OEAW");
await expect(twCreator).toHaveAttribute("content", i18n.t("metadata.twitter"));

const twSite = page.locator('meta[name="twitter:site"]');
await expect(twSite).toHaveAttribute("content", "@NoMansLand_OEAW");
await expect(twSite).toHaveAttribute("content", i18n.t("metadata.twitter"));

// const googleSiteVerification = page.locator('meta[name="google-site-verification"]');
// await expect(googleSiteVerification).toHaveAttribute("content", "");

await expect(page).toHaveTitle("Home | Nomad's Manuscripts Landscape");
await expect(page).toHaveTitle(
[i18n.t("IndexPage.meta.title"), i18n.t("metadata.title")].join(" | "),
);

const metaDescription = page.locator('meta[name="description"]');
await expect(metaDescription).toHaveAttribute(
"content",
"Investigating Literary Evidence for Transculturation in Medieval Iran and Central Asia in the 13th – 15th centuries.",
);
await expect(metaDescription).toHaveAttribute("content", i18n.t("metadata.description"));

const ogTitle = page.locator('meta[property="og:title"]');
await expect(ogTitle).toHaveAttribute("content", "Home");
await expect(ogTitle).toHaveAttribute("content", i18n.t("IndexPage.meta.title"));

const ogDescription = page.locator('meta[property="og:description"]');
await expect(ogDescription).toHaveAttribute(
"content",
"Investigating Literary Evidence for Transculturation in Medieval Iran and Central Asia in the 13th – 15th centuries.",
);
await expect(ogDescription).toHaveAttribute("content", i18n.t("metadata.description"));

const ogSiteName = page.locator('meta[property="og:site_name"]');
await expect(ogSiteName).toHaveAttribute("content", "Nomad's Manuscripts Landscape");
await expect(ogSiteName).toHaveAttribute("content", i18n.t("metadata.title"));

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

const ogLocale = page.locator('meta[property="og:locale"]');
await expect(ogLocale).toHaveAttribute("content", "en");
await expect(ogLocale).toHaveAttribute("content", defaultLocale);
});

// eslint-disable-next-line playwright/no-skipped-test
test.skip("should add json+ld metadata", async ({ createIndexPage }) => {
const { indexPage } = await createIndexPage();
test("should add json+ld metadata", async ({ createIndexPage }) => {
const { indexPage, i18n } = await createIndexPage();
await indexPage.goto();

const metadata = await indexPage.page.locator('script[type="application/ld+json"]').textContent();
Expand All @@ -85,9 +88,8 @@ test.skip("should add json+ld metadata", async ({ createIndexPage }) => {
JSON.stringify({
"@context": "https://schema.org",
"@type": "WebSite",
name: "Nomad&apos;s Manuscripts Landscape",
description:
"Investigating Literary Evidence for Transculturation in Medieval Iran and Central Asia in the 13th – 15th centuries.",
name: escape(i18n.t("metadata.title")),
description: escape(i18n.t("metadata.description")),
}),
);
});
Expand Down Expand Up @@ -115,5 +117,5 @@ test("should set `lang` attribute on `html` element", async ({ createIndexPage }
const { indexPage } = await createIndexPage();
await indexPage.goto();

await expect(indexPage.page.locator("html")).toHaveAttribute("lang", "en");
await expect(indexPage.page.locator("html")).toHaveAttribute("lang", defaultLocale);
});
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,29 @@
"validate": "run-s format:check lint:check types:check test test:e2e"
},
"dependencies": {
"@acdh-oeaw/lib": "^0.1.11",
"@acdh-oeaw/lib": "^0.1.12",
"@acdh-oeaw/validate-env": "^0.0.3",
"@astrojs/mdx": "^3.0.1",
"@astrojs/mdx": "^3.1.0",
"@astrojs/node": "^8.2.5",
"@astrojs/react": "^3.4.0",
"@astrojs/react": "^3.5.0",
"@astrojs/rss": "^4.0.6",
"@astrojs/sitemap": "^3.1.5",
"@floating-ui/dom": "^1.6.5",
"@fontsource-variable/inter": "^5.0.18",
"@iconify-json/lucide": "^1.1.189",
"@iconify-json/lucide": "^1.1.190",
"@keystatic/astro": "^5.0.0",
"@keystatic/core": "^0.5.18",
"@mdx-js/mdx": "^3.0.1",
"@pagefind/default-ui": "^1.1.0",
"@shikijs/rehype": "^1.6.2",
"astro": "^4.9.3",
"@shikijs/rehype": "^1.6.3",
"astro": "^4.10.0",
"astro-icon": "^1.1.0",
"cva": "^1.0.0-beta.1",
"date-fns": "^3.6.0",
"estree-util-value-to-estree": "^3.1.1",
"hast-util-heading-rank": "^3.0.0",
"hast-util-to-string": "^3.0.0",
"lucide-react": "^0.383.0",
"lucide-react": "^0.390.0",
"nodemailer": "^6.9.13",
"pagefind": "^1.1.0",
"pdfkit": "^0.15.0",
Expand All @@ -73,12 +73,12 @@
"retext-smartypants": "^6.1.0",
"satori": "^0.10.13",
"sharp": "^0.33.4",
"shiki": "^1.6.2",
"shiki": "^1.6.3",
"unified": "^11.0.4",
"unist-util-visit": "^5.0.0",
"valibot": "^0.30.0",
"valibot": "^0.31.0",
"vfile": "^6.0.1",
"vite": "^5.2.12"
"vite": "^5.2.13"
},
"devDependencies": {
"@acdh-oeaw/eslint-config": "^1.0.7",
Expand Down Expand Up @@ -106,7 +106,7 @@
"dotenv": "^16.4.5",
"dotenv-expand": "^11.0.6",
"eslint": "^8.57.0",
"eslint-plugin-tailwindcss": "^3.17.0",
"eslint-plugin-tailwindcss": "^3.17.3",
"is-ci": "^3.0.1",
"lint-staged": "^15.2.5",
"npm-run-all2": "^6.2.0",
Expand All @@ -116,8 +116,8 @@
"schema-dts": "^1.1.2",
"simple-git-hooks": "^2.11.1",
"stylelint": "^16.6.1",
"tailwindcss": "^3.4.3",
"type-fest": "^4.19.0",
"tailwindcss": "^3.4.4",
"type-fest": "^4.20.0",
"typescript": "^5.4.5"
},
"pnpm": {
Expand Down
Loading

0 comments on commit 232df10

Please sign in to comment.