better cards
This commit is contained in:
@@ -22,9 +22,9 @@ describe("blog umami event attributes", () => {
|
||||
it("instruments blog post cards with deterministic target_id and placement", async () => {
|
||||
const src = await read("src/components/BlogPostCard.astro");
|
||||
|
||||
expect(src).toContain('data-umami-event="click"');
|
||||
expect(src).toContain("data-umami-event-target_id={targetId}");
|
||||
expect(src).toContain("data-umami-event-placement={placement}");
|
||||
expect(src).toContain('"data-umami-event": "click"');
|
||||
expect(src).toContain('"data-umami-event-target_id": targetId');
|
||||
expect(src).toContain('"data-umami-event-placement": placement');
|
||||
expect(src).toContain("data-umami-event-target_url");
|
||||
});
|
||||
|
||||
@@ -61,4 +61,3 @@ describe("blog umami event attributes", () => {
|
||||
expect(categorySrc).toContain("targetId={`blog.category.${activeCategory.slug}.card.post.${p.slug}`}");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
29
site/tests/card-layout.test.ts
Normal file
29
site/tests/card-layout.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
async function read(rel: string) {
|
||||
return await readFile(path.join(process.cwd(), rel), "utf8");
|
||||
}
|
||||
|
||||
describe("card layout", () => {
|
||||
it("uses a shared StandardCard component for content and blog cards", async () => {
|
||||
const contentCard = await read("src/components/ContentCard.astro");
|
||||
expect(contentCard).toContain('import StandardCard from "./StandardCard.astro";');
|
||||
expect(contentCard).toContain("<StandardCard");
|
||||
|
||||
const blogPostCard = await read("src/components/BlogPostCard.astro");
|
||||
expect(blogPostCard).toContain('import StandardCard from "./StandardCard.astro";');
|
||||
expect(blogPostCard).toContain("<StandardCard");
|
||||
});
|
||||
|
||||
it("defines standardized card CSS (content band + footer bar)", async () => {
|
||||
const css = await read("public/styles/global.css");
|
||||
|
||||
expect(css).toContain(".card-content");
|
||||
expect(css).toContain("justify-content: space-between");
|
||||
expect(css).toContain(".card-footer");
|
||||
expect(css).toContain(".card-summary");
|
||||
});
|
||||
});
|
||||
@@ -31,7 +31,7 @@ describe("content link umami title/type attributes", () => {
|
||||
|
||||
it("adds title/type on blog post cards and pages links", async () => {
|
||||
const cardSrc = await read("src/components/BlogPostCard.astro");
|
||||
expect(cardSrc).toContain('data-umami-event-type="blog_post"');
|
||||
expect(cardSrc).toContain('"data-umami-event-type": "blog_post"');
|
||||
expect(cardSrc).toContain("data-umami-event-title");
|
||||
|
||||
const blogIndexSrc = await read("src/pages/blog/index.astro");
|
||||
@@ -43,4 +43,3 @@ describe("content link umami title/type attributes", () => {
|
||||
expect(blogPagesSrc).toContain("data-umami-event-title={p.title}");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ describe("umami event attributes", () => {
|
||||
|
||||
it("instruments content cards using outbound_click", async () => {
|
||||
const src = await read("src/components/ContentCard.astro");
|
||||
expect(src).toContain('data-umami-event="outbound_click"');
|
||||
expect(src).toContain('"data-umami-event": "outbound_click"');
|
||||
expect(src).toContain("data-umami-event-target_id");
|
||||
expect(src).toContain("data-umami-event-domain");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user