Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 7 additions & 2 deletions __tests__/e2e/action-edit-textarea-scroll.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,16 @@ async function setupActionsPage(page: Page) {
})
})

await page.route(`**/users/${MOCK_USER_ID}/actions**`, async (route) => {
// Batch relationship-actions endpoint (used by actions kanban page)
await page.route('**/coaching_relationships/actions**', async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ data: SESSION_ACTIONS }),
body: JSON.stringify({
data: {
coachee_actions: { [RELATIONSHIP_ID]: SESSION_ACTIONS },
},
}),
})
})
}
Expand Down
10 changes: 7 additions & 3 deletions __tests__/e2e/actions-exit-animation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,16 @@ async function setupActionsPage(
})
})

// User actions list endpoint
await page.route(`**/users/${MOCK_USER_ID}/actions**`, async (route) => {
// Batch relationship-actions endpoint (used by actions kanban page)
await page.route('**/coaching_relationships/actions**', async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ data: OPEN_ACTIONS }),
body: JSON.stringify({
data: {
coachee_actions: { 'rel-1': OPEN_ACTIONS },
},
}),
})
})
}
Expand Down
47 changes: 47 additions & 0 deletions __tests__/lib/api/relationship-actions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { describe, it, expect } from "vitest";
import { relationshipActionsUrl } from "@/lib/api/relationship-actions";
import {
AssigneeScope,
UserActionsAssigneeFilter,
} from "@/types/assigned-actions";

describe("relationshipActionsUrl", () => {
const orgId = "org-123";
const relId = "rel-456";

it("includes assignee param in single-relationship URL (regression: was previously dropped)", () => {
const params = {
assignee: AssigneeScope.Coachee,
assignee_filter: UserActionsAssigneeFilter.Assigned,
};

const batchUrl = relationshipActionsUrl(orgId, params);
const singleUrl = relationshipActionsUrl(orgId, {
...params,
coaching_relationship_id: relId,
});

// Both paths must include assignee=coachee so the backend filters
// to coachee-only actions. The single-relationship path previously
// used sharedQueryString which omitted the assignee param, causing
// both "My Actions" and "Coachee Actions" to show identical results.
expect(batchUrl).toContain("assignee=coachee");
expect(singleUrl).toContain("assignee=coachee");
});

it("supports assignee=coach for My Actions path", () => {
const params = {
assignee: AssigneeScope.Coach,
assignee_filter: UserActionsAssigneeFilter.Assigned,
};

const batchUrl = relationshipActionsUrl(orgId, params);
const singleUrl = relationshipActionsUrl(orgId, {
...params,
coaching_relationship_id: relId,
});

expect(batchUrl).toContain("assignee=coach");
expect(singleUrl).toContain("assignee=coach");
});
});
119 changes: 64 additions & 55 deletions __tests__/lib/hooks/use-actions-fetch.test.ts
Original file line number Diff line number Diff line change
@@ -1,80 +1,89 @@
import { describe, it, expect } from "vitest";
import {
assignmentFilterToUserActionsParams,
assignmentFilterToRelationshipActionsParams,
} from "@/lib/hooks/use-actions-fetch";
import { assignmentFilterToRelationshipActionsParams } from "@/lib/hooks/use-actions-fetch";
import {
AssigneeScope,
AssignmentFilter,
UserActionsAssigneeFilter,
UserActionsScope,
} from "@/types/assigned-actions";

describe("assignmentFilterToUserActionsParams", () => {
it("maps Assigned to scope=assigned with no assignee filter", () => {
const result = assignmentFilterToUserActionsParams(AssignmentFilter.Assigned);
expect(result).toEqual({ scope: UserActionsScope.Assigned });
expect(result.assigneeFilter).toBeUndefined();
});

it("maps Unassigned to scope=sessions with assignee_filter=unassigned", () => {
const result = assignmentFilterToUserActionsParams(AssignmentFilter.Unassigned);
expect(result).toEqual({
scope: UserActionsScope.Sessions,
assigneeFilter: UserActionsAssigneeFilter.Unassigned,
describe("assignmentFilterToRelationshipActionsParams", () => {
describe("with coachee scope", () => {
it("maps Assigned to assignee=coachee with assignee_filter=assigned", () => {
const result = assignmentFilterToRelationshipActionsParams(
AssignmentFilter.Assigned,
AssigneeScope.Coachee
);
expect(result).toEqual({
assignee: AssigneeScope.Coachee,
assigneeFilter: UserActionsAssigneeFilter.Assigned,
});
});
});

it("maps All to scope=sessions with no assignee filter", () => {
const result = assignmentFilterToUserActionsParams(AssignmentFilter.All);
expect(result).toEqual({ scope: UserActionsScope.Sessions });
expect(result.assigneeFilter).toBeUndefined();
it("maps All to assignee=coachee with no assignee filter", () => {
const result = assignmentFilterToRelationshipActionsParams(
AssignmentFilter.All,
AssigneeScope.Coachee
);
expect(result).toEqual({ assignee: AssigneeScope.Coachee });
expect(result.assigneeFilter).toBeUndefined();
});
});
});

describe("assignmentFilterToRelationshipActionsParams", () => {
it("maps Assigned to assignee=coachee with assignee_filter=assigned", () => {
const result = assignmentFilterToRelationshipActionsParams(AssignmentFilter.Assigned);
expect(result).toEqual({
assignee: AssigneeScope.Coachee,
assigneeFilter: UserActionsAssigneeFilter.Assigned,
describe("with coach scope", () => {
it("maps Assigned to assignee=coach with assignee_filter=assigned", () => {
const result = assignmentFilterToRelationshipActionsParams(
AssignmentFilter.Assigned,
AssigneeScope.Coach
);
expect(result).toEqual({
assignee: AssigneeScope.Coach,
assigneeFilter: UserActionsAssigneeFilter.Assigned,
});
});
});

it("maps Unassigned to assignee_filter=unassigned with no assignee scope", () => {
const result = assignmentFilterToRelationshipActionsParams(AssignmentFilter.Unassigned);
expect(result).toEqual({
assigneeFilter: UserActionsAssigneeFilter.Unassigned,
it("maps All to assignee=coach with no assignee filter", () => {
const result = assignmentFilterToRelationshipActionsParams(
AssignmentFilter.All,
AssigneeScope.Coach
);
expect(result).toEqual({ assignee: AssigneeScope.Coach });
expect(result.assigneeFilter).toBeUndefined();
});
expect(result.assignee).toBeUndefined();
});

it("maps All to assignee=coachee with no assignee filter", () => {
const result = assignmentFilterToRelationshipActionsParams(AssignmentFilter.All);
expect(result).toEqual({ assignee: AssigneeScope.Coachee });
expect(result.assigneeFilter).toBeUndefined();
it("Unassigned ignores scope — returns only assignee_filter=unassigned", () => {
const coachResult = assignmentFilterToRelationshipActionsParams(
AssignmentFilter.Unassigned,
AssigneeScope.Coach
);
const coacheeResult = assignmentFilterToRelationshipActionsParams(
AssignmentFilter.Unassigned,
AssigneeScope.Coachee
);
const expected = {
assigneeFilter: UserActionsAssigneeFilter.Unassigned,
};
expect(coachResult).toEqual(expected);
expect(coacheeResult).toEqual(expected);
expect(coachResult.assignee).toBeUndefined();
});

it("returns distinct params for each filter value", () => {
const assigned = assignmentFilterToRelationshipActionsParams(AssignmentFilter.Assigned);
const unassigned = assignmentFilterToRelationshipActionsParams(AssignmentFilter.Unassigned);
const all = assignmentFilterToRelationshipActionsParams(AssignmentFilter.All);
const assigned = assignmentFilterToRelationshipActionsParams(
AssignmentFilter.Assigned,
AssigneeScope.Coachee
);
const unassigned = assignmentFilterToRelationshipActionsParams(
AssignmentFilter.Unassigned,
AssigneeScope.Coachee
);
const all = assignmentFilterToRelationshipActionsParams(
AssignmentFilter.All,
AssigneeScope.Coachee
);

// All three produce different param shapes
expect(assigned).not.toEqual(unassigned);
expect(assigned).not.toEqual(all);
expect(unassigned).not.toEqual(all);

// Assigned scopes to coachee AND filters to assigned
expect(assigned.assignee).toBe(AssigneeScope.Coachee);
expect(assigned.assigneeFilter).toBe(UserActionsAssigneeFilter.Assigned);

// Unassigned omits assignee scope (unassigned actions have no assignee to scope by)
expect(unassigned.assignee).toBeUndefined();
expect(unassigned.assigneeFilter).toBe(UserActionsAssigneeFilter.Unassigned);

// All scopes to coachee with no assignee filter (returns everything for coachee)
expect(all.assignee).toBe(AssigneeScope.Coachee);
expect(all.assigneeFilter).toBeUndefined();
});
});
Loading
Loading