test: add test utilities and mock infrastructure#146
Conversation
Deploying wxyc-dj with
|
| Latest commit: |
f760520
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://196f8edc.dj-site.pages.dev |
| Branch Preview URL: | https://test-01-test-utilities.dj-site.pages.dev |
71e645b to
3904412
Compare
JacksonMeade
left a comment
There was a problem hiding this comment.
The testing infrastructure is extremely clean, I'm a big fan.
There are several places where (I assume, since I never write comments like this) the AI has, in my opinion, over-commented the code, adding unnecessary commentary that could easily become outdated as the codebase drifts.
Hidden in this PR, however, is the total removal of the organization client, a feature of the design that I wish had been made explicit. This is a huge change to the way roles work, and not a decision we have discussed. That is blocking for me until it is justified.
| async function getAuthServiceBaseUrl(): Promise<string> { | ||
| // Check env vars first | ||
| const authUrl = process.env.NEXT_PUBLIC_BETTER_AUTH_URL; | ||
| if (authUrl) { |
There was a problem hiding this comment.
What is the purpose of this replacement? I worry that this is either an artifact of errors while mocking the backend or performing some of the work that now resides in next.config.mjs:
/** @type {import('next').NextConfig} */
const authBaseURL = process.env.NEXT_PUBLIC_BETTER_AUTH_URL || "https://api.wxyc.org/auth";
const nextConfig = {
reactStrictMode: false,
// Explicitly set workspace root to silence lockfile warning
outputFileTracingRoot: import.meta.dirname,
// Required for OpenNext Cloudflare
output: "standalone",
async rewrites() {
return [
{
source: "/auth/:path*",
destination: `${authBaseURL}/:path*`,
},
];
},
};
export default nextConfig;
// OpenNext Cloudflare dev initialization
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
initOpenNextCloudflareForDev();
3904412 to
2908dcd
Compare
|
Addressed all points in the latest force push:
|
307e35c to
f287868
Compare
b3b66a0 to
eeec4f9
Compare
eeec4f9 to
e0fedc5
Compare
e0fedc5 to
ac922ee
Compare
- Add component harness for Redux-wrapped hook testing - Expand fixtures with test data factories - Add auth and bin-api mocks for consistent test setup - Add e2e auth fixture with login/logout helpers and port discovery - Consolidate mock users into shared MOCK_USERS in fixtures.ts - Update package.json with test dependencies
The package requires GitHub Packages auth and nothing in this PR imports it.
ac922ee to
0bd23e8
Compare
The E2E auth fixture imports fixtures.ts which imports time.ts, and
time.ts had a top-level `import { vi } from "vitest"`. Playwright
cannot load vitest in its CommonJS context, causing the E2E run to
fail with "Vitest cannot be imported in a CommonJS module".
Move the vitest-dependent helpers (mockCurrentTime, restoreRealTime)
into time.vitest.ts and keep time.ts as pure utilities. The barrel
export re-exports time.vitest so existing unit test imports are
unaffected.
The E2E tests reference TEST_USERS.adminReset1 and TEST_USERS.demotableSm but those keys were missing from MOCK_USERS in fixtures.ts, causing TypeError at runtime. Add all four missing seeded users: adminReset1, deletableUser, promotableUser, and demotableSm.
Closes #246
Summary
Lay the foundation for the test suite by adding shared infrastructure that all subsequent test PRs depend on:
lib/test-utils/component-harness.ts— Redux-wrapped hook rendering harness (createHookWrapper) so hook tests get a real store without boilerplatelib/test-utils/fixtures.ts— Test data factories and sharedMOCK_USERSfor consistent test identitieslib/test-utils/index.ts— Barrel export for clean importsorganization-utils,organization-config, andutilitiese2e/fixtures/auth.fixture.ts— Playwright-style login/logout helpers with port discovery for e2e testsTest plan
Part 1 of 26 — Test infrastructure. Merge before all other test PRs.