Skip to content

test(frontend): use runtime-relative dates in api-client-review tests - #3533

Merged
PetrefiedThunder merged 6 commits into
mainfrom
claude/frontend-tests-runtime-dates
Oct 24, 2026
Merged

PetrefiedThunder merged 6 commits into
mainfrom
claude/frontend-tests-runtime-dates

Conversation

@PetrefiedThunder

@PetrefiedThunder PetrefiedThunder commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Makes frontend/src/__tests__/lib/api-client-review.test.ts data-free. The remaining fixed timestamps (ingestion_timestamp, review created_at/updated_at, API key created_at, invite created_at/expires_at) are now constants computed from Date.now() at runtime. Each expected value reuses the same constant, so the assertions are unchanged. The original order and gaps are kept (review < invite < key < ingestion), and invites still expire 7 days after creation.

Follow-up to #3514. Deferred: qa-health.test.tsx (touched by #3524).

Tests: vitest run src/__tests__/lib/api-client-review.test.ts --execArgv=--no-experimental-webstorage: 22 passed.

VS Code Gemini reviews; do not merge (merge freeze).


Note

Low Risk
Test-only fixture refactors in one Vitest file; no application or API client logic changes.

Overview
Refactors api-client-review.test.ts so fixtures no longer use hardcoded calendar dates, tenant names, emails, or IDs—part of making api-client contract tests data-free (follow-up to #3514).

Timestamps are derived from Date.now() at load time (INGESTED_AT, REVIEW_CREATED_AT, invite/key dates, etc.), keeping the same relative ordering and the 7-day invite expiry window while assertions still compare mock input to the same constants.

Identifiers and copy use crypto.randomUUID() (and @example.invalid emails) shared between mocked responses and expectations; approve/reject/key URLs and normalized objects wire through those constants. The system role label stays Viewer (aligned with ingestion team_mgmt). Rejected CSV row errors in csvResult now use a concrete validation-style message (quantity is required) instead of a generic rejected string.

No production api-client behavior changes—contract coverage is unchanged, only fixture hygiene.

Reviewed by Cursor Bugbot for commit a4af4a4. Bugbot is set up for automated code reviews on this repo. Configure here.

Replace fixed calendar timestamps with dates computed from Date.now().
Expected values reuse the same constants; ordering and gaps are kept
(invites still expire 7 days after creation).

Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
regengine Ready Ready Preview Oct 24, 2026 2:13am UTC

@cursor

cursor Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: fa4b4bf7-e3fa-4590-bc8d-4126fa7ef0ab)

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between a4af4a4 and 5591dbf.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between eeae7d3 and 6dcfbf8.

📒 Files selected for processing: 1
  • frontend/src/__tests__/lib/api-client-review.test.ts

Limit details: You’ve used all 10 included reviews currently available.

Walkthrough

The API-client tests now use generated values and timestamps derived from the current time for ingestion, review, API-key, user, role, and invite fixtures and expectations. Invite expiration remains seven days after invite creation.

Priority: Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Merge Risk: Minimal · up to 6dcfb

The fixture changes preserve the tested API-client contracts, with no established merge-blocking risk.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the test changes and reports the test result, but it omits most required template sections, including Type of Change, Checklist, and Related Issues. The Summary and Test Plan … Add the required Summary, Type of Change, Test Plan, Checklist, and Related Issues sections. Include the applicable checkbox selections and link or reference issue #3514 in Related Issues.
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly describes the main change: updating API-client review tests to use runtime-relative dates.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the test changes and reports the test result, but it omits most required template sections, including Type of Change, Checklist, and Related Issues. The Summary and Test Plan also do not use the required structure.

Resolution

Add the required Summary, Type of Change, Test Plan, Checklist, and Related Issues sections. Include the applicable checkbox selections and link or reference issue #3514 in Related Issues.

✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T15:23:35.255838Z 7f01099 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

PR Blocker Checklist

Head SHA: 5591dbfe3f7c149d74d9d9786c73030f4ca809b0

Status: Ready

  • All review threads resolved
  • No reviews requesting changes
  • No blocked review engines

@PetrefiedThunder PetrefiedThunder left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REVIEW: FAIL gemini 7f01099

Findings:

  1. Dates: good. NOW_MS is read once at module load. The derived ISO strings are only passed through and checked with exact toEqual. The client does no expiry, elapsed time or relative formatting on them, so there is no risk from midnight, DST or timezone and fake timers are not needed. Order and gaps match the old fixtures, and invites still expire 7 days after creation.
  2. Invented data remains in the same file, so it is not data-free yet:
    • emails owner@example.com (L313, L346) and pending@example.com (L331, L354)
    • tenant name 'Acme' and id 'tenant-1' (L160, L163)
    • 'Deploy key', 'Viewer', 'Preview text'
    • fixed ids rev-1, key-1, user-1, role-1, invite-1, evt-1, LOT-n
      Generate ids and emails at runtime (crypto.randomUUID) or use real recorded data. If a value cannot be made data-free, add a "Coverage gap" note.
  3. Assertions: still meaningful (URL and method contract, CSRF and tenant headers, review_id to id mapping, CSV count and hash validation).
  4. CI at this SHA: api-client-review.test.ts passed (22 tests). Unit Tests failed in 5 other files this PR does not touch: dashboard-load-errors, dashboard-qa-agreement, qa-health, suppliers-metrics and suppliers-removal. PR Gate: Frontend, Frontend CI Status Gate, Build & Bundle Analysis, Bundle Size Check, Workflow Contract, Secrets, SAST, Tool Pinning, Unused File Guard and Vercel are red. Not merging: merge freeze.

…review tests

Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
@cursor

cursor Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 975a4da7-2ada-4b11-8fcb-c61a8ad30f95)

@PetrefiedThunder PetrefiedThunder left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REVIEW: FAIL gemini eeae7d3

Delta 7f01099..eeae7d3 checked against my last FAIL:

  1. Fixed: every id, email, tenant name, key name, preview text and lot code is now generated at runtime with crypto.randomUUID. Emails use the reserved .invalid TLD. Each expected value reuses its input constant, so the assertions are unchanged in strength.
  2. Verified as real: 'Viewer' (services/ingestion/app/team_mgmt.py, viewer -> label "Viewer"). Error strings 'Tenant mismatch', 'Authentication required', 'CSV contained no data rows', 'No valid rows found', 'No CTE type' and 'Request failed' all exist in admin/ingestion/frontend source. 'Field required' is Pydantic v2's standard message. mobile_capture_pwa_offline and ci_artifact exist in source. The csrf-token header value, the 64-char hash pattern, and invalid inputs on purpose ('not-a-hash', 'not an array', 'not a display message') are acceptable.
  3. Still invented. These two are free text that no source emits, so replace them with real backend strings or uid():
    • errors: ['persistence warning'] (L310): not found anywhere in services/ or frontend/src.
    • Row ${index + 2}: rejected in csvResult (L67): the ": rejected" text is made up. Use a real csv_templates.py row error (e.g. "Row N: No CTE type", already used at L257).
  4. CI: api-client-review.test.ts passes (22 tests). The Unit Tests failures (5 files, 10 tests) are identical by name to main's job 120366116851, so they are not caused by this PR. Other red checks (PR Gate: Frontend, Frontend CI Status Gate, Bundle, Workflow Contract, Secrets, SAST, Tool Pinning, Unused File Guard, Vercel) are unchanged from the previous head. Not merging: merge freeze.

…api-client-review tests

Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>
@cursor

cursor Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 7bedac72-2789-411b-8031-59a06373dc4e)

@PetrefiedThunder PetrefiedThunder left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REVIEW: PASS gemini 6dcfbf8

Delta eeae7d3..6dcfbf8 touches only api-client-review.test.ts, two lines:

  1. L67: Row ${index + 2}: quantity is required exactly matches services/ingestion/app/csv_templates.py:862 (f"Row {row_num}: quantity is required").
  2. L310: errors: [uid()] replaces the invented 'persistence warning'.
    No other changes and no new invented data. Together with my earlier checks, the file is now data-free: runtime uuid ids and .invalid emails, plus only real role labels and real error strings.

CI: Unit Tests job 120506847764 logs show api-client-review.test.ts passing (22 tests). The only failures are the same 10 tests in 5 files that also fail on main (job 120366116851). The other red checks are the same as at the previous heads. Not merging: merge freeze.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Branch updated with main

Main was merged into claude/frontend-tests-runtime-dates at the new head (a4af4a4e492c1b5a224d890f60d746de06ebe82c).

Because merge commits created with GITHUB_TOKEN do not trigger workflows, a push to this branch or a manual CI re-run is needed for checks to run on it.

Last synced: 2026-10-24T02:11:41.204Z

Signed-off-by: Christopher <131207452+PetrefiedThunder@users.noreply.github.com>

@PetrefiedThunder PetrefiedThunder left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REVIEW: PASS gemini a4af4a4

Delta 6dcfbf8..a4af4a4 is only the merge of main (#3552 658bc7f) plus an empty retrigger commit. The PR's own change to frontend/src/tests/lib/api-client-review.test.ts is byte identical to the head I passed at 6dcfbf8: runtime relative dates, no invented data. CI was still running at review time; merge still needs fully green CI.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Bundle Size Report

Metric Size
Total JS 6362.0KB (6.21MB)
Total CSS 150.7KB
Limit 10.0MB

Bundle is within the 10.0MB limit.

@PetrefiedThunder
PetrefiedThunder enabled auto-merge (squash) October 24, 2026 02:10
@PetrefiedThunder

Copy link
Copy Markdown
Collaborator Author

REVIEW: PASS pi 5591dbf
Delta since a4af4a4 is only the github-actions main sync merge (clean, no manual conflict resolution; parents = prior PASS head + main), no PR code changes.

@PetrefiedThunder PetrefiedThunder left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delta review: since the last PASS, the only change is a clean sync merge of main with no manual conflict resolution.

REVIEW: PASS pi 5591dbf

@PetrefiedThunder
PetrefiedThunder merged commit 59f2305 into main Oct 24, 2026
61 of 66 checks passed
@PetrefiedThunder
PetrefiedThunder deleted the claude/frontend-tests-runtime-dates branch October 24, 2026 04:48

This branch was successfully deployed

1 active deployment
Preview — 5591dbfe Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant