-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat(organizations): add color scheme, change member role (#765)
* ✨ feat(organizations): color and change role * chore: test color validation * chore: use docker hub for base image
- Loading branch information
Showing
21 changed files
with
536 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM public.ecr.aws/docker/library/node:lts | ||
FROM node:lts | ||
WORKDIR /usr/src/app | ||
|
||
ENV PNPM_HOME="/pnpm" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/graphql/organizations/resolvers/Mutation/updateRole.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { MutationResolvers } from "./../../../types.generated.js"; | ||
export const updateRole: NonNullable<MutationResolvers["updateRole"]> = async ( | ||
_parent, | ||
{ data }, | ||
ctx, | ||
) => { | ||
const result = await ctx.organizations.members.updateRole(ctx, { | ||
memberId: data.memberId, | ||
newRole: data.role, | ||
}); | ||
|
||
if (!result.ok) { | ||
throw result.error; | ||
} | ||
return result.data; | ||
}; |
84 changes: 84 additions & 0 deletions
84
src/graphql/organizations/resolvers/Mutation/updateRole.unit.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { faker } from "@faker-js/faker"; | ||
import { InternalServerError } from "~/domain/errors.js"; | ||
import { | ||
OrganizationMember, | ||
OrganizationRole, | ||
} from "~/domain/organizations.js"; | ||
import { createMockApolloServer } from "~/graphql/test-clients/mock-apollo-server.js"; | ||
import { graphql } from "~/graphql/test-clients/unit/gql.js"; | ||
import { Result } from "~/lib/result.js"; | ||
|
||
describe("Organiation mutations", () => { | ||
describe("updateRole", () => { | ||
it("updates a role", async () => { | ||
const { client, organizationService } = createMockApolloServer(); | ||
|
||
organizationService.members.updateRole.mockResolvedValue({ | ||
ok: true, | ||
data: { | ||
member: new OrganizationMember({ | ||
id: faker.string.uuid(), | ||
role: OrganizationRole.ADMIN, | ||
organizationId: faker.string.uuid(), | ||
userId: faker.string.uuid(), | ||
}), | ||
}, | ||
}); | ||
|
||
const { errors, data } = await client.mutate({ | ||
mutation: graphql(` | ||
mutation UpdateRole($data: UpdateRoleInput!) { | ||
updateRole(data: $data) { | ||
member { | ||
id | ||
} | ||
} | ||
} | ||
`), | ||
variables: { | ||
data: { | ||
memberId: faker.string.uuid(), | ||
role: OrganizationRole.ADMIN, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(errors).toBeUndefined(); | ||
expect(data).toEqual({ | ||
updateRole: { | ||
member: { | ||
id: expect.any(String), | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
it("throws on error", async () => { | ||
const { client, organizationService } = createMockApolloServer(); | ||
|
||
organizationService.members.updateRole.mockResolvedValue( | ||
Result.error(new InternalServerError("")), | ||
); | ||
|
||
const { errors } = await client.mutate({ | ||
mutation: graphql(` | ||
mutation UpdateRole($data: UpdateRoleInput!) { | ||
updateRole(data: $data) { | ||
member { | ||
id | ||
} | ||
} | ||
} | ||
`), | ||
variables: { | ||
data: { | ||
memberId: faker.string.uuid(), | ||
role: OrganizationRole.ADMIN, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(errors).toBeDefined(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import type { UpdateRoleResponseResolvers } from "./../../types.generated.js"; | ||
export const UpdateRoleResponse: UpdateRoleResponseResolvers = { | ||
/* Implement UpdateRoleResponse resolver logic here */ | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.