Skip to content

Commit 4e77048

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feature/80-link-sevices-to-a-required-subscription
2 parents 1812cf3 + f267df1 commit 4e77048

39 files changed

Lines changed: 2362 additions & 2163 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
/.next/
1616
/out/
1717

18+
/.react-email
19+
1820
# production
1921
/build
2022

__tests__/services-actions.test.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ jest.mock("next/cache", () => ({
5454
updateTag: jest.fn(),
5555
}));
5656

57-
const COACH_A = "11111111-1111-1111-1111-111111111111";
58-
const COACH_B = "22222222-2222-2222-2222-222222222222";
57+
const COORDINATOR_A = "11111111-1111-1111-1111-111111111111";
58+
const COORDINATOR_B = "22222222-2222-2222-2222-222222222222";
5959
const SERVICE_ID = "33333333-3333-3333-3333-333333333333";
6060

6161
function fd(obj: Record<string, string>): FormData {
@@ -75,7 +75,7 @@ beforeEach(() => {
7575
});
7676

7777
describe("createService", () => {
78-
it("rejects a private lesson without a coach", async () => {
78+
it("rejects a private lesson without a coordinator", async () => {
7979
const result = await createService(
8080
null,
8181
fd({
@@ -87,12 +87,12 @@ describe("createService", () => {
8787
}),
8888
);
8989

90-
expect(result?.errors?.coach_id).toBeDefined();
90+
expect(result?.errors?.coordinator_id).toBeDefined();
9191
expect(insert).not.toHaveBeenCalled();
9292
expect(createProduct).not.toHaveBeenCalled();
9393
});
9494

95-
it("persists the coach when creating a private lesson", async () => {
95+
it("persists the coordinator when creating a private lesson", async () => {
9696
const result = await createService(
9797
null,
9898
fd({
@@ -101,18 +101,21 @@ describe("createService", () => {
101101
type: "private_lessons",
102102
duration_minutes: "60",
103103
price_cad: "50.00",
104-
coach_id: COACH_A,
105104
requires_subscription: "true",
105+
coordinator_id: COORDINATOR_A,
106106
}),
107107
);
108108

109109
expect(result).toEqual({ message: "Service created." });
110110
expect(insertValues).toHaveBeenCalledWith(
111-
expect.objectContaining({ type: "private_lessons", coachId: COACH_A }),
111+
expect.objectContaining({
112+
type: "private_lessons",
113+
coordinatorId: COORDINATOR_A,
114+
}),
112115
);
113116
});
114117

115-
it("creates a program with no coach", async () => {
118+
it("creates a program with no coordinator", async () => {
116119
const result = await createService(
117120
null,
118121
fd({
@@ -130,13 +133,13 @@ describe("createService", () => {
130133

131134
expect(result).toEqual({ message: "Service created." });
132135
expect(insertValues).toHaveBeenCalledWith(
133-
expect.objectContaining({ type: "programs", coachId: null }),
136+
expect.objectContaining({ type: "programs", coordinatorId: null }),
134137
);
135138
});
136139
});
137140

138141
describe("updateService", () => {
139-
it("reassigns the coach on a private lesson", async () => {
142+
it("reassigns the coordinator on a private lesson", async () => {
140143
selectLimit.mockResolvedValue([
141144
{
142145
id: SERVICE_ID,
@@ -148,12 +151,12 @@ describe("updateService", () => {
148151

149152
const result = await updateService(
150153
null,
151-
fd({ service_id: SERVICE_ID, coach_id: COACH_B }),
154+
fd({ service_id: SERVICE_ID, coordinator_id: COORDINATOR_B }),
152155
);
153156

154157
expect(result).toEqual({ message: "Service updated." });
155158
expect(updateSet).toHaveBeenCalledWith(
156-
expect.objectContaining({ coachId: COACH_B }),
159+
expect.objectContaining({ coordinatorId: COORDINATOR_B }),
157160
);
158161
});
159162

@@ -170,7 +173,11 @@ describe("updateService", () => {
170173

171174
const result = await updateService(
172175
null,
173-
fd({ service_id: SERVICE_ID, coach_id: COACH_B, price_cad: "50.00" }),
176+
fd({
177+
service_id: SERVICE_ID,
178+
coordinator_id: COORDINATOR_B,
179+
price_cad: "50.00",
180+
}),
174181
);
175182

176183
expect(result).toEqual({ message: "Service updated." });
@@ -199,7 +206,7 @@ describe("updateService", () => {
199206
expect(createPrice).toHaveBeenCalledWith("prod_1", 7500);
200207
});
201208

202-
it("rejects clearing the coach on a private lesson", async () => {
209+
it("rejects clearing the coordinator on a private lesson", async () => {
203210
selectLimit.mockResolvedValue([
204211
{
205212
id: SERVICE_ID,
@@ -211,10 +218,10 @@ describe("updateService", () => {
211218

212219
const result = await updateService(
213220
null,
214-
fd({ service_id: SERVICE_ID, coach_id: "" }),
221+
fd({ service_id: SERVICE_ID, coordinator_id: "" }),
215222
);
216223

217-
expect(result?.errors?.coach_id).toBeDefined();
224+
expect(result?.errors?.coordinator_id).toBeDefined();
218225
expect(updateSet).not.toHaveBeenCalled();
219226
});
220227
});

__tests__/users-actions.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jest.mock("@/lib/stripe", () => ({
3737
grantComplimentarySubscription: jest.fn(),
3838
}));
3939

40-
const COACH_ID = "11111111-1111-1111-1111-111111111111";
40+
const COORDINATOR_ID = "11111111-1111-1111-1111-111111111111";
4141

4242
function fd(obj: Record<string, string>): FormData {
4343
const f = new FormData();
@@ -56,16 +56,16 @@ describe("deleteUserAdmin", () => {
5656
it("returns Unauthorized when the caller is not an admin", async () => {
5757
requireAdmin.mockRejectedValue(new Error("Forbidden"));
5858

59-
const result = await deleteUserAdmin(null, fd({ user_id: COACH_ID }));
59+
const result = await deleteUserAdmin(null, fd({ user_id: COORDINATOR_ID }));
6060

6161
expect(result).toEqual({ errors: { _form: ["Unauthorized"] } });
6262
expect(deleteUser).not.toHaveBeenCalled();
6363
});
6464

65-
it("blocks deletion when the coach is assigned to a private lesson", async () => {
65+
it("blocks deletion when the coordinator is assigned to a private lesson", async () => {
6666
selectLimit.mockResolvedValue([{ id: "svc-1" }]);
6767

68-
const result = await deleteUserAdmin(null, fd({ user_id: COACH_ID }));
68+
const result = await deleteUserAdmin(null, fd({ user_id: COORDINATOR_ID }));
6969

7070
expect(result?.errors?._form?.[0]).toMatch(/private lesson/i);
7171
expect(deleteUser).not.toHaveBeenCalled();
@@ -74,16 +74,16 @@ describe("deleteUserAdmin", () => {
7474
it("deletes the user when not assigned to any private lesson", async () => {
7575
selectLimit.mockResolvedValue([]);
7676

77-
const result = await deleteUserAdmin(null, fd({ user_id: COACH_ID }));
77+
const result = await deleteUserAdmin(null, fd({ user_id: COORDINATOR_ID }));
7878

7979
expect(result).toEqual({ message: "User deleted." });
80-
expect(deleteUser).toHaveBeenCalledWith(COACH_ID);
80+
expect(deleteUser).toHaveBeenCalledWith(COORDINATOR_ID);
8181
});
8282

8383
it("surfaces an auth error from Supabase", async () => {
8484
deleteUser.mockResolvedValue({ error: { message: "boom" } });
8585

86-
const result = await deleteUserAdmin(null, fd({ user_id: COACH_ID }));
86+
const result = await deleteUserAdmin(null, fd({ user_id: COORDINATOR_ID }));
8787

8888
expect(result).toEqual({ errors: { _form: ["boom"] } });
8989
});

app/(authenticated)/checkout/actions.test.ts

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)