Skip to content

Commit fe4f628

Browse files
Copilotmodkaffes
andauthored
test: add Vitest test suite for data files and layout logic (#25)
* test: add Vitest test suite for data files and layout logic Agent-Logs-Url: https://github.com/modkaffes/personal-website/sessions/a75038f3-51bc-495b-b6f4-be4c8b4729cc Co-authored-by: modkaffes <1829897+modkaffes@users.noreply.github.com> * ci: add GitHub Actions workflow to run tests on push and PRs Agent-Logs-Url: https://github.com/modkaffes/personal-website/sessions/35360265-f4f0-425d-8a83-250299db98af Co-authored-by: modkaffes <1829897+modkaffes@users.noreply.github.com> * fix: address PR review comments — centralize site config and fix unsafe describe labels Agent-Logs-Url: https://github.com/modkaffes/personal-website/sessions/469cd379-fbec-425b-ba0d-dacc394a26fe Co-authored-by: modkaffes <1829897+modkaffes@users.noreply.github.com> * fix: address second round of review comments — rename astro config and use toMatch assertions Agent-Logs-Url: https://github.com/modkaffes/personal-website/sessions/e7692af8-736c-426e-9580-2a668f2e2641 Co-authored-by: modkaffes <1829897+modkaffes@users.noreply.github.com> * chore: pin CI actions to commit SHAs and revert node to lts * test: exercise real OG image logic and drop unused vitest aliases The layout tests previously re-implemented `new URL(image, base)` inline, so they validated the built-in URL constructor rather than Layout.astro's own behavior — a regression in the layout would not have failed them. Extract the OG image URL resolution into a shared `resolveImageUrl` helper in site-config.ts and call it from both Layout.astro and the test, so the suite now covers the production code path. Also: - add a case for resolving against an explicitly provided base URL - switch the default-prop assertions to `toMatch(/\S/)` for consistency with the JSON data tests - remove the three unused path aliases from vitest.config.ts Verified: 93 tests pass and the build emits the correct absolute og:image. * ci: run build, restrict token permissions, cancel superseded runs Harden and broaden the CI workflow: - add `npm run build` so compile/build regressions are caught (the prior config-rename bug would have slipped past a test-only pipeline) - set `permissions: contents: read` to drop the GITHUB_TOKEN down to the minimum this read-only job needs - add a concurrency group keyed on the ref with cancel-in-progress, so a new push to a branch/PR cancels the now-stale run and saves CI minutes --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: modkaffes <1829897+modkaffes@users.noreply.github.com> Co-authored-by: Modestos Kaffes <modkaffes@hackthebox.eu>
1 parent cd70ec8 commit fe4f628

12 files changed

Lines changed: 585 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ci-${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
test:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
21+
22+
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
23+
with:
24+
node-version: lts/*
25+
cache: npm
26+
27+
- run: npm ci
28+
29+
- run: npm test
30+
31+
- run: npm run build

astro.config.mjs renamed to astro.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { defineConfig } from "astro/config";
22
import partytown from "@astrojs/partytown";
33
import tailwindcss from "@tailwindcss/vite";
4+
import { SITE_URL } from "./src/site-config";
45

56
// https://astro.build/config
67
export default defineConfig({
7-
site: "https://modkaffes.com",
8+
site: SITE_URL,
89

910
integrations: [
1011
partytown({

0 commit comments

Comments
 (0)