Skip to content

Commit c768b16

Browse files
Align test filenames with source modules
Document the convention and rename the SEO metadata test to match the Seo layout component it exercises.
1 parent e7b52b7 commit c768b16

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
any reported issues until the command passes cleanly.
55
- When changing application code, content schemas, build behavior, or tests,
66
also run `npm test`.
7+
- Mirror source paths when naming tests for application modules. For example,
8+
tests for `src/config/site.ts` belong in `test/config/site.test.ts`.
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import assert from "node:assert/strict"
22
import { readdir, readFile } from "node:fs/promises"
33
import test from "node:test"
44
import { parse } from "yaml"
5-
import { getSiteUrl } from "../src/config/site.ts"
5+
import { getSiteUrl } from "../../../src/config/site.ts"
66

77
const expectedSiteUrl = getSiteUrl()
88

@@ -20,7 +20,7 @@ const getMetaContent = (html: string, attribute: string, value: string) => {
2020
}
2121

2222
test("all posts make an explicit social preview image decision", async () => {
23-
const postsDirectory = new URL("../src/content/posts/", import.meta.url)
23+
const postsDirectory = new URL("../../../src/content/posts/", import.meta.url)
2424
const filenames = await readdir(postsDirectory)
2525

2626
for (const filename of filenames.filter((name) => name.endsWith(".mdx"))) {
@@ -37,7 +37,7 @@ test("all posts make an explicit social preview image decision", async () => {
3737

3838
test("article pages expose description metadata for link previews", async () => {
3939
const html = await readPage(
40-
"../dist/posts/hands-on-home-row-for-ai-assisted-coding/index.html",
40+
"../../../dist/posts/hands-on-home-row-for-ai-assisted-coding/index.html",
4141
)
4242
const description =
4343
"AI-assisted coding has fit surprisingly well with the terminal and text-first tools I spent years sharpening. Agent orchestration may be the industry productivity boost I long wanted. While engineering discipline still matters, I feel wistful for hands-on coding."
@@ -77,7 +77,7 @@ test("image-backed articles expose absolute social preview images and alt text",
7777
]
7878

7979
for (const { alt, file, slug } of cases) {
80-
const html = await readPage(`../dist/posts/${slug}/index.html`)
80+
const html = await readPage(`../../../dist/posts/${slug}/index.html`)
8181
const [name, extension] = file.split(".")
8282
const imageUrl = getMetaContent(html, "property", "og:image")
8383

@@ -88,7 +88,9 @@ test("image-backed articles expose absolute social preview images and alt text",
8888
})
8989

9090
test("articles without a preview image use the large social image fallback", async () => {
91-
const html = await readPage("../dist/posts/avoid-git-first-drafts/index.html")
91+
const html = await readPage(
92+
"../../../dist/posts/avoid-git-first-drafts/index.html",
93+
)
9294

9395
assert.equal(
9496
getMetaContent(html, "property", "og:image"),
@@ -103,7 +105,7 @@ test("articles without a preview image use the large social image fallback", asy
103105
})
104106

105107
test("post pages identify themselves as Open Graph articles", async () => {
106-
const html = await readPage("../dist/posts/paint-by-types/index.html")
108+
const html = await readPage("../../../dist/posts/paint-by-types/index.html")
107109

108110
assert.equal(getMetaContent(html, "property", "og:type"), "article")
109111
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from "node:assert/strict"
22
import test from "node:test"
3-
import { getSiteUrl, productionSiteUrl } from "../src/config/site.ts"
3+
import { getSiteUrl, productionSiteUrl } from "../../src/config/site.ts"
44

55
test("site URL falls back to production outside deploy environments", () => {
66
assert.equal(getSiteUrl({}), productionSiteUrl)

0 commit comments

Comments
 (0)