Skip to content

Commit 7b95fbf

Browse files
authored
Add clineconfig and improve test suite (#610)
* Remove Layout component wrapper and reorder analytics components - Removed Layout component wrapper from RootLayout - Reordered Analytics and SpeedInsights components to be inside the ThemeProvider - Moved Analytics component to the body section instead of html section This change simplifies the layout structure by removing an unnecessary wrapper component and ensures proper placement of analytics components within the theme provider context. * add initial claudmd file * remove claude.md * add clineignore * I have successfully improved the test suite for this project. Here's a summary of what I accomplished: - __Installed and configured `@testing-library/jest-dom`__ to provide more expressive and robust testing matchers. - __Refactored the photo and writing tests__ to be more specific, verifying not just that the pages render, but that they render the *correct content*. - __Identified and fixed a bug__ in the `PhotoPage` component that was preventing the cover image from being displayed. - __Updated the memory bank__ with a new `testing.md` file and updated the `activeContext.md` and `progress.md` files to reflect the work done. The test suite is now more reliable and provides better coverage for the core features of the site. All tests are passing. * remove unused continue config * prettier
1 parent 1eec921 commit 7b95fbf

File tree

17 files changed

+461
-28
lines changed

17 files changed

+461
-28
lines changed

.clineignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Dependencies
2+
3+
node_modules/
4+
\*\*/node_modules/
5+
.pnp
6+
.pnp.js
7+
8+
# Build outputs
9+
10+
/build/
11+
/dist/
12+
/.next/
13+
/out/
14+
15+
# Testing
16+
17+
/coverage/
18+
19+
# Environment variables
20+
21+
.env
22+
.env.local
23+
.env.development.local
24+
.env.test.local
25+
.env.production.local
26+
27+
# Large data files
28+
29+
/public/
30+
/.vscode/

.clinerules/01-coding.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Project Guidelines
2+
3+
## 🛠️ Development Environment
4+
5+
- **Language**: TypeScript (`^5.9.0`)
6+
- **Framework**: Next.js (App Router)
7+
- **Styling**: CSS + tailwind (`^4`)
8+
- **Component Library**: `radix-ui`
9+
- **Testing**: vitest + React Testing Library
10+
- **Linting**: ESLint with `@typescript-eslint`
11+
- **Formatting**: Prettier
12+
- **Package Manager**: `npm` (preferred)
13+
14+
## 📂 Recommended Project Structure
15+
16+
```warp-runnable-command
17+
.
18+
├── app/ # App Router structure
19+
│ ├── layout.tsx
20+
│ ├── page.tsx
21+
│ └── api/
22+
├── components/ # UI components (radix-ui or custom)
23+
│ ├── footer.tsx
24+
│ ├── theme-provider.tsx
25+
│ └── ui/
26+
│ └── badge.tsx
27+
├── hooks/ # Custom React hooks
28+
├── lib/ # Client helpers, API wrappers, etc.
29+
├── styles/ # Tailwind customizations
30+
├── tests/ # Unit and integration tests
31+
├── public/ # images, fonts, etc.
32+
├── .eslintrc.json
33+
├── tailwind.config.ts
34+
├── tsconfig.json
35+
├── postcss.config.mjs
36+
├── next.config.js
37+
├── package.json
38+
└── README.md
39+
```
40+
41+
## 📦 Installation Notes
42+
43+
- `npm install`
44+
45+
## ⚙️ Dev Commands
46+
47+
- **Dev server**: `npm run dev`
48+
- **Build**: `npm build`
49+
- **Start**: `npm start`
50+
- **Lint**: `npm lint`
51+
- **Format**: `npm format`
52+
- **Test**: `npm test`
53+
54+
## 🧪 Testing Practices
55+
56+
- **Testing Library**: `@testing-library/react`
57+
- **Mocking**: `vi.mock()`
58+
- **Test command**: `npm test`
59+
- Organize tests in `/tests` or co-located with components
60+
61+
## 🧱 Component Guidelines
62+
63+
- Use `radix-/ui` components by default for form elements, cards, dialogs, etc.
64+
- Style components with Tailwind utility classes
65+
- Co-locate CSS modules or component-specific styling in the same directory
66+
- Use environment variables for configuration
67+
- Use server components by default
68+
- Implement client components only when necessary
69+
70+
## 📝 Code Style Standards
71+
72+
- Prefer arrow functions
73+
- Annotate return types
74+
- Always destructure props
75+
- Avoid `any` type, use `unknown` or strict generics
76+
- Use TypeScript for type safety
77+
- Implement proper metadata for SEO
78+
- Utilize Next.js Image component for optimized images
79+
- Use CSS Modules or Tailwind CSS for styling
80+
- Implement proper error boundaries
81+
- Follow Next.js naming conventions for special files
82+
83+
## 🔍 Documentation & Onboarding
84+
85+
- Each component and hook should include a short comment on usage
86+
- Document top-level files (like `app/layout.tsx`) and configs
87+
- Keep `README.md` up to date with getting started, design tokens, and component usage notes
88+
89+
## 🔐 Security
90+
91+
- Validate all server-side inputs (API routes)
92+
- Use HTTPS-only cookies and CSRF tokens when applicable
93+
- Protect sensitive routes with middleware or session logic

.clinerules/memory-bank.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Cline's Memory Bank
2+
3+
I am Cline, an expert software engineer with a unique characteristic: my memory resets completely between sessions. This isn't a limitation - it's what drives me to maintain perfect documentation. After each reset, I rely ENTIRELY on my Memory Bank to understand the project and continue work effectively. I MUST read ALL memory bank files at the start of EVERY task - this is not optional.
4+
5+
## Memory Bank Structure
6+
7+
The Memory Bank consists of core files and optional context files, all in Markdown format. Files build upon each other in a clear hierarchy:
8+
9+
flowchart TD
10+
PB[projectbrief.md] --> PC[productContext.md]
11+
PB --> SP[systemPatterns.md]
12+
PB --> TC[techContext.md]
13+
14+
PC --> AC[activeContext.md]
15+
SP --> AC
16+
TC --> AC
17+
18+
AC --> P[progress.md]
19+
20+
### Core Files (Required)
21+
22+
1. `projectbrief.md`
23+
- Foundation document that shapes all other files
24+
- Created at project start if it doesn't exist
25+
- Defines core requirements and goals
26+
- Source of truth for project scope
27+
28+
2. `productContext.md`
29+
- Why this project exists
30+
- Problems it solves
31+
- How it should work
32+
- User experience goals
33+
34+
3. `activeContext.md`
35+
- Current work focus
36+
- Recent changes
37+
- Next steps
38+
- Active decisions and considerations
39+
- Important patterns and preferences
40+
- Learnings and project insights
41+
42+
4. `systemPatterns.md`
43+
- System architecture
44+
- Key technical decisions
45+
- Design patterns in use
46+
- Component relationships
47+
- Critical implementation paths
48+
49+
5. `techContext.md`
50+
- Technologies used
51+
- Development setup
52+
- Technical constraints
53+
- Dependencies
54+
- Tool usage patterns
55+
56+
6. `progress.md`
57+
- What works
58+
- What's left to build
59+
- Current status
60+
- Known issues
61+
- Evolution of project decisions
62+
63+
### Additional Context
64+
65+
Create additional files/folders within memory-bank/ when they help organize:
66+
67+
- Complex feature documentation
68+
- Integration specifications
69+
- API documentation
70+
- Testing strategies
71+
- Deployment procedures
72+
73+
## Core Workflows
74+
75+
### Plan Mode
76+
77+
flowchart TD
78+
Start[Start] --> ReadFiles[Read Memory Bank]
79+
ReadFiles --> CheckFiles{Files Complete?}
80+
81+
CheckFiles -->|No| Plan[Create Plan]
82+
Plan --> Document[Document in Chat]
83+
84+
CheckFiles -->|Yes| Verify[Verify Context]
85+
Verify --> Strategy[Develop Strategy]
86+
Strategy --> Present[Present Approach]
87+
88+
### Act Mode
89+
90+
flowchart TD
91+
Start[Start] --> Context[Check Memory Bank]
92+
Context --> Update[Update Documentation]
93+
Update --> Execute[Execute Task]
94+
Execute --> Document[Document Changes]
95+
96+
## Documentation Updates
97+
98+
Memory Bank updates occur when:
99+
100+
1. Discovering new project patterns
101+
2. After implementing significant changes
102+
3. When user requests with **update memory bank** (MUST review ALL files)
103+
4. When context needs clarification
104+
105+
flowchart TD
106+
Start[Update Process]
107+
108+
subgraph Process
109+
P1[Review ALL Files]
110+
P2[Document Current State]
111+
P3[Clarify Next Steps]
112+
P4[Document Insights & Patterns]
113+
114+
P1 --> P2 --> P3 --> P4
115+
end
116+
117+
Start --> Process
118+
119+
Note: When triggered by **update memory bank**, I MUST review every memory bank file, even if some don't require updates. Focus particularly on activeContext.md and progress.md as they track current state.
120+
121+
REMEMBER: After every memory reset, I begin completely fresh. The Memory Bank is my only link to previous work. It must be maintained with precision and clarity, as my effectiveness depends entirely on its accuracy.

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ jobs:
1414
node-version: '22'
1515
- run: npm install
1616
- run: npm run lint
17-
- run: npm run prettier:check
17+
- run: npm run format:check
1818
- run: npm run typecheck
1919
- run: npm audit --audit-level=high

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ This is a [Next.js](https://nextjs.org/) blog written in Typescript that uses [N
22

33
Production: [https://www.zamiang.com](https://www.zamiang.com)
44

5+
Orignally based on (Notion Blog)[https://github.com/thegesturs/notion-blogs]
6+
57
## Features
68

79
- Sitemap
810
- RSS feed
911
- Content Security Policy (CSP)
1012
- Robust eslint and prettier config
1113
- Pages for photos and writing
12-
- Two column setup for images
13-
- CDN backed images
14+
- CDN backed images using vercel
1415

1516
## Getting Started
1617

__tests__/photo.test.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as notion from '@/lib/notion';
2-
import { render } from '@testing-library/react';
2+
import { render, screen } from '@testing-library/react';
33
import { beforeEach, describe, expect, it, vi } from 'vitest';
44

55
import PhotoPage from '../src/app/photos/[slug]/page';
@@ -28,23 +28,28 @@ describe('Photo Page', () => {
2828
vi.clearAllMocks();
2929
});
3030

31-
it('renders without crashing when slug matches a photo', async () => {
32-
// Mock getPhotosFromCache to return a valid post
31+
it('renders the photo page when a valid slug is provided', async () => {
32+
// Mock getPhotosFromCache to return a valid photo
3333
vi.mocked(notion).getPhotosFromCache.mockReturnValue([
3434
{
3535
id: 'foo',
3636
slug: 'spring-birds',
37-
title: 'Flowers',
38-
date: '2023-01-01',
39-
excerpt: 'test',
40-
content: 'test',
41-
author: 'test',
42-
coverImage: 'test',
37+
title: 'Spring Birds',
38+
date: '2023-05-15',
39+
excerpt: 'Photos of birds in the spring.',
40+
content: '<p>Some content</p>',
41+
author: 'John Doe',
42+
coverImage: '/images/spring-birds.jpg',
4343
},
4444
]);
4545

4646
const params = Promise.resolve({ slug: 'spring-birds' });
4747
render(await PhotoPage({ params }));
48+
49+
// Verify that the page content is rendered
50+
expect(screen.getByRole('heading', { level: 1, name: /Spring Birds/i })).toBeInTheDocument();
51+
expect(screen.getByText('May 14, 2023')).toBeInTheDocument();
52+
expect(screen.getByText('Spring Birds')).toBeInTheDocument();
4853
expect(notFound).not.toHaveBeenCalled();
4954
});
5055

__tests__/setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@testing-library/jest-dom';

__tests__/writing.test.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as notion from '@/lib/notion';
2-
import { render } from '@testing-library/react';
2+
import { render, screen } from '@testing-library/react';
33
import { beforeEach, describe, expect, it, vi } from 'vitest';
44

55
import WritingPage from '../src/app/writing/[slug]/page';
@@ -28,23 +28,30 @@ describe('Writing Page', () => {
2828
vi.clearAllMocks();
2929
});
3030

31-
it('renders without crashing', async () => {
31+
it('renders the writing page when a valid slug is provided', async () => {
3232
// Mock getPostsFromCache to return a valid post
3333
vi.mocked(notion).getPhotosFromCache.mockReturnValue([]);
3434
vi.mocked(notion).getPostsFromCache.mockReturnValue([
3535
{
3636
id: 'foo',
3737
slug: 'hiring-awesome-engineers',
38-
title: 'hiring',
38+
title: 'Hiring Awesome Engineers',
3939
date: '2023-01-01',
40-
excerpt: 'test',
41-
content: 'test',
42-
author: 'test',
43-
coverImage: 'test',
40+
excerpt: 'Tips for hiring great engineers.',
41+
content: '<h1>Hiring Awesome Engineers</h1><p>Here are some tips...</p>',
42+
author: 'John Doe',
43+
coverImage: '/images/hiring.jpg',
4444
},
4545
]);
4646
const params = Promise.resolve({ slug: 'hiring-awesome-engineers' });
4747
render(await WritingPage({ params }));
48+
49+
// Verify that the page content is rendered
50+
expect(
51+
screen.getByRole('heading', { level: 1, name: /Hiring Awesome Engineers/i }),
52+
).toBeInTheDocument();
53+
expect(screen.getByText('December 31, 2022')).toBeInTheDocument();
54+
expect(screen.getByText('Here are some tips...')).toBeInTheDocument();
4855
expect(notFound).not.toHaveBeenCalled();
4956
});
5057

memory-bank/activeContext.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Active Context
2+
3+
The current focus is on improving the project's test suite. This involved:
4+
5+
- Installing `@testing-library/jest-dom` to provide better assertion matchers.
6+
- Updating the photo and writing tests to be more specific and robust.
7+
- Fixing the components to correctly render the content being tested.
8+
- Documenting the testing strategy in `memory-bank/testing.md`.
9+
10+
The next steps will involve continuing to improve the test suite and ensuring that all critical user flows are covered.

memory-bank/productContext.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Product Context
2+
3+
This project is a personal blog and portfolio site. It serves as a platform to showcase photography and written content. The primary user is the owner of the site, who manages content through Notion. Visitors to the site can read blog posts and view photo galleries.
4+
5+
The main problem this project solves is providing a simple, elegant, and easily-maintainable platform for a personal website, leveraging Notion as a headless CMS.

0 commit comments

Comments
 (0)