Skip to content

Commit c3b7f56

Browse files
authored
Merge branch 'main' into copilot/add-fullscreen-image-feature
2 parents 9634c6b + 7536d9c commit c3b7f56

2 files changed

Lines changed: 87 additions & 0 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: 'Copilot Setup Steps'
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- .github/workflows/copilot-setup-steps.yml
8+
pull_request:
9+
paths:
10+
- .github/workflows/copilot-setup-steps.yml
11+
12+
jobs:
13+
copilot-setup-steps:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 10
16+
17+
permissions:
18+
contents: read
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '24'
28+
29+
- name: Setup pnpm
30+
uses: pnpm/action-setup@v4
31+
with:
32+
version: 10.24.0
33+
34+
- name: Get pnpm store directory
35+
shell: bash
36+
run: |
37+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
38+
39+
- name: Setup pnpm cache
40+
uses: actions/cache@v4
41+
with:
42+
path: ${{ env.STORE_PATH }}
43+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
44+
restore-keys: |
45+
${{ runner.os }}-pnpm-store-
46+
47+
- name: Install dependencies
48+
run: pnpm install --frozen-lockfile
49+
50+
- name: Install Playwright browsers
51+
run: pnpm exec playwright install --with-deps chromium

AGENTS.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,42 @@ The project uses Chromatic for visual regression testing. PRs automatically trig
180180
2. PRs will show visual diff status checks
181181
3. Changes to main are auto-accepted as the new baseline
182182

183+
**Deterministic Date Rendering:**
184+
185+
Stories that display relative dates (e.g. "5 days ago", "Pending (14d)") must mock `globalThis.Date` in a `beforeEach` hook to pin `Date.now()` to a fixed timestamp. Without this, Chromatic detects a visual change every day as the rendered text shifts. Use the pattern from `PaymentDetailsModal.stories.tsx`:
186+
187+
```typescript
188+
const FIXED_NOW = new Date('2026-02-15T12:00:00Z')
189+
190+
const meta = {
191+
// ...
192+
beforeEach: () => {
193+
const OriginalDate = globalThis.Date
194+
const fixedTime = FIXED_NOW.getTime()
195+
196+
const MockDate: any = function (...args: any[]) {
197+
if (args.length === 0) return new OriginalDate(fixedTime)
198+
return new (Function.prototype.bind.apply(OriginalDate, [
199+
null,
200+
...args,
201+
]) as typeof OriginalDate)()
202+
}
203+
Object.setPrototypeOf(MockDate, OriginalDate)
204+
MockDate.prototype = Object.create(OriginalDate.prototype)
205+
MockDate.now = () => fixedTime
206+
MockDate.parse = OriginalDate.parse.bind(OriginalDate)
207+
MockDate.UTC = OriginalDate.UTC.bind(OriginalDate)
208+
globalThis.Date = MockDate
209+
210+
return () => {
211+
globalThis.Date = OriginalDate
212+
}
213+
},
214+
} satisfies Meta<typeof MyComponent>
215+
```
216+
217+
This applies to any component using `formatDistanceToNow`, `getDaysPending`, or other relative date calculations.
218+
183219
### Privacy and GDPR Compliance
184220

185221
- **User Data Protection:** Always abide by GDPR regulations when handling any user data, including but not limited to:

0 commit comments

Comments
 (0)