diff --git a/test/graphql/types/Mutation/updateAgendaItem.test.ts b/test/graphql/types/Mutation/updateAgendaItem.test.ts index 787f6167d31..5fd0bb2192f 100644 --- a/test/graphql/types/Mutation/updateAgendaItem.test.ts +++ b/test/graphql/types/Mutation/updateAgendaItem.test.ts @@ -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"], + }, + ], + }, + }), + ); + }); });