Skip to content

Commit

Permalink
fix:coderabbit sugg
Browse files Browse the repository at this point in the history
  • Loading branch information
shivasankaran18 committed Feb 10, 2025
1 parent 2b69a06 commit 1da887f
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions test/graphql/types/Mutation/updateAgendaItem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,4 +815,96 @@ describe("updateAgendaItemResolver", () => {
}),
);
});

it("should handle note-type agenda item validations", async () => {
drizzleClientMock.query.usersTable.findFirst.mockResolvedValue({
role: "administrator",
});
drizzleClientMock.query.agendaItemsTable.findFirst.mockResolvedValue({
type: "note",
folder: {
eventId: "event_1",
event: {
organization: {
membershipsWhereOrganization: [{ role: "administrator" }],
},
},
},
});

// Test both duration and key provided (lines 80, 90)
await expect(
updateAgendaItemResolver(
{},
{
input: {
id: "123e4567-e89b-12d3-a456-426614174000",
duration: "10",
key: "C",
},
},
authenticatedContext,
),
).rejects.toThrowError(
expect.objectContaining({
extensions: {
code: "forbidden_action_on_arguments_associated_resources",
issues: [
{
argumentPath: ["input", "duration"],
message: 'Cannot be provided for an agenda item of type "note"',
},
{
argumentPath: ["input", "key"],
message: 'Cannot be provided for an agenda item of type "note"',
},
],
},
}),
);
});

it("should handle folder validation and update authorization", async () => {
drizzleClientMock.query.usersTable.findFirst.mockResolvedValue({
role: "regular", // Non-admin user
});
drizzleClientMock.query.agendaItemsTable.findFirst.mockResolvedValue({
type: "general",
folder: {
eventId: "event_1",
event: {
organization: {
membershipsWhereOrganization: [
{ role: "regular" }, // Non-admin role in organization (lines 242-243)
],
},
},
},
});

// Test unauthorized update attempt
await expect(
updateAgendaItemResolver(
{},
{
input: {
id: "123e4567-e89b-12d3-a456-426614174000",
name: "Updated Name",
},
},
authenticatedContext,
),
).rejects.toThrowError(
expect.objectContaining({
extensions: {
code: "unauthorized_action_on_arguments_associated_resources",
issues: [
{
argumentPath: ["input", "id"],
},
],
},
}),
);
});
});

0 comments on commit 1da887f

Please sign in to comment.