Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(webapp): inherit region on preview branches + test resolver
Preview branches copy the parent env's defaultWorkerGroupId. Adds a unit
test for the env -> project -> global fallback order.
  • Loading branch information
myftija committed Jun 9, 2026
commit f25808f10d45ed41cfb34eaf8d4e8ee360df6141
2 changes: 2 additions & 0 deletions apps/webapp/app/services/upsertBranch.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ export class UpsertBranchService {
pkApiKey,
shortcode,
maximumConcurrencyLimit: parentEnvironment.maximumConcurrencyLimit,
// Inherit the region from the parent preview environment.
defaultWorkerGroupId: parentEnvironment.defaultWorkerGroupId,
organization: {
connect: {
id: parentEnvironment.organization.id,
Expand Down
44 changes: 44 additions & 0 deletions apps/webapp/test/regionAccess.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { describe, expect, it } from "vitest";
import { resolveEffectiveDefaultWorkerGroupId } from "~/v3/regionAccess.server";

describe("resolveEffectiveDefaultWorkerGroupId", () => {
it("prefers the environment default", () => {
expect(
resolveEffectiveDefaultWorkerGroupId({
environmentDefaultWorkerGroupId: "env",
projectDefaultWorkerGroupId: "project",
globalDefaultWorkerGroupId: "global",
})
).toBe("env");
});

it("falls back to the project default when the environment has none", () => {
expect(
resolveEffectiveDefaultWorkerGroupId({
environmentDefaultWorkerGroupId: null,
projectDefaultWorkerGroupId: "project",
globalDefaultWorkerGroupId: "global",
})
).toBe("project");
});

it("falls back to the global default when env and project have none", () => {
expect(
resolveEffectiveDefaultWorkerGroupId({
environmentDefaultWorkerGroupId: null,
projectDefaultWorkerGroupId: null,
globalDefaultWorkerGroupId: "global",
})
).toBe("global");
});

it("returns undefined when nothing is set", () => {
expect(
resolveEffectiveDefaultWorkerGroupId({
environmentDefaultWorkerGroupId: null,
projectDefaultWorkerGroupId: null,
globalDefaultWorkerGroupId: null,
})
).toBeUndefined();
});
});