Skip to content

chore(test): fix Windows test failures and eager Cloudflare credential resolution#605

Open
Mkassabov wants to merge 1 commit into
mainfrom
chore/windows-test-fixes
Open

chore(test): fix Windows test failures and eager Cloudflare credential resolution#605
Mkassabov wants to merge 1 commit into
mainfrom
chore/windows-test-fixes

Conversation

@Mkassabov

Copy link
Copy Markdown
Contributor

Fixes the 19 test failures / 2 suite failures from a full local vitest run on Windows. Most were Windows-specific test bugs, but two were real cross-platform source bugs the run surfaced.

Source fixes

  • Eager Cloudflare credential resolution (Gateway/Rule.ts, Tunnel/Configuration.ts): both providers did

    const { accountId } = yield* yield* CloudflareEnvironment; // at layer build!

    forcing auth (or an interactive login prompt) just to construct the provider collection — Providers.test.ts's unknown-profile guard test caught it by hanging on the Clack prompt. Both now hold the env effect and resolve accountId inside lifecycle ops, per the providers convention.

  • PurePlugin.resolvePackageInfo walked above the node_modules/<pkg> root, so a stray package.json higher up (e.g. a drive-root manifest on Windows) masked the path-derived package name. The walk now stops at the package's own root.

  • Drizzle/Schema.diff forced { action: "update" } whenever output.out was absolute (legacy-state migration shim). On Windows an out on a different drive than cwd has no relative form, so every deploy flagged an update. Now compares against today's canonical relativeOut form instead.

  • Cloudflare OAuth DEFAULT_SCOPES: added dns_records:read/edit + teams:read/write so a default oauth login can manage the DnsRecord and Tunnel/Gateway resources alchemy ships.

Test/fixture fixes

  • new URL(...).pathnamefileURLToPath(...) (yields /D:/... on Windows) in Lambda/Function.test.ts, Local/RpcServer.test.ts
  • pidListeningOn fixture: netstat -ano on win32 (lsof doesn't exist) — un-cascades all 7 RpcSpawner/RpcSpawnerCleanup failures
  • PurePlugin.test.ts: junction instead of dir symlink on win32 (no elevation needed; type arg ignored on POSIX)
  • Build.test.ts: normalize platform separators before comparing outdir

Not fixed (credentials, not code)

Zone, Ruleset, Dns, Tunnel suites provision zones, and Cloudflare's OAuth client has no zone:write scope at all — those suites require API-token auth (CLOUDFLARE_API_TOKEN, what CI uses via TEST_CLOUDFLARE_API_TOKEN).

All fixed suites verified locally on Windows (PurePlugin 30/30, RpcSpawner 5/5, RpcSpawnerCleanup 4/4, RpcServer, Build, Drizzle 3/3, Providers, Lambda Function 2/2 incl. live deploys).

@alchemy-version-bot

Copy link
Copy Markdown
Contributor

Install the packages built from this commit:

alchemy

bun add alchemy@https://pkg.ing/alchemy/6fd43e6

@alchemy.run/better-auth

bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/6fd43e6

@alchemy.run/pr-package

bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/6fd43e6

Comment on lines +14 to +16
const timeoutHandlerPath = fileURLToPath(
new URL("./timeout-handler.ts", import.meta.url),
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pathe.resolve(import.meta.dirname, "timeout-handler.ts")?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants