From 1c73786226b86471d59eaafb774c8bd078dd4370 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 8 Dec 2020 11:43:37 +0000 Subject: [PATCH] Update user editing to support new email field --- .../components/backend/DataTable/Table.svelte | 2 +- .../DataTable/modals/CreateEditUser.svelte | 6 +-- .../server/src/api/routes/tests/role.spec.js | 48 ++++++++++--------- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/Table.svelte b/packages/builder/src/components/backend/DataTable/Table.svelte index 67fc417191..718e56b31b 100644 --- a/packages/builder/src/components/backend/DataTable/Table.svelte +++ b/packages/builder/src/components/backend/DataTable/Table.svelte @@ -50,7 +50,7 @@ $: isUsersTable = tableId === TableNames.USERS $: { if (isUsersTable) { - schema.username.displayFieldName = "Username" + schema.email.displayFieldName = "Email" schema.roleId.displayFieldName = "Role" } } diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditUser.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditUser.svelte index 2f6f9a7e8c..c703e00b23 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditUser.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditUser.svelte @@ -31,7 +31,7 @@ const getCustomSchemaKeys = schema => { let customSchema = { ...schema } - delete customSchema["username"] + delete customSchema["email"] delete customSchema["roleId"] return Object.entries(customSchema) } @@ -72,8 +72,8 @@ onConfirm={saveRow}> {#if creating} { let server @@ -20,8 +24,8 @@ describe("/roles", () => { let view beforeAll(async () => { - ({ request, server } = await supertest()) - }); + ;({ request, server } = await supertest()) + }) afterAll(() => { server.close() @@ -35,30 +39,29 @@ describe("/roles", () => { }) describe("create", () => { - it("returns a success message when role is successfully created", async () => { const res = await request .post(`/api/roles`) .send(roleBody) .set(defaultHeaders(appId)) - .expect('Content-Type', /json/) + .expect("Content-Type", /json/) .expect(200) - expect(res.res.statusMessage).toEqual("Role 'NewRole' created successfully.") + expect(res.res.statusMessage).toEqual( + "Role 'NewRole' created successfully." + ) expect(res.body._id).toBeDefined() expect(res.body._rev).toBeDefined() }) - - }); + }) describe("fetch", () => { - it("should list custom roles, plus 2 default roles", async () => { const createRes = await request .post(`/api/roles`) .send(roleBody) .set(defaultHeaders(appId)) - .expect('Content-Type', /json/) + .expect("Content-Type", /json/) .expect(200) const customRole = createRes.body @@ -66,10 +69,10 @@ describe("/roles", () => { const res = await request .get(`/api/roles`) .set(defaultHeaders(appId)) - .expect('Content-Type', /json/) + .expect("Content-Type", /json/) .expect(200) - expect(res.body.length).toBe(3) + expect(res.body.length).toBe(5) const adminRole = res.body.find(r => r._id === BUILTIN_ROLE_IDS.ADMIN) expect(adminRole).toBeDefined() @@ -84,10 +87,11 @@ describe("/roles", () => { const customRoleFetched = res.body.find(r => r._id === customRole._id) expect(customRoleFetched).toBeDefined() expect(customRoleFetched.inherits).toEqual(BUILTIN_ROLE_IDS.BASIC) - expect(customRoleFetched.permissionId).toEqual(BUILTIN_PERMISSION_IDS.READ_ONLY) + expect(customRoleFetched.permissionId).toEqual( + BUILTIN_PERMISSION_IDS.READ_ONLY + ) }) - - }); + }) describe("destroy", () => { it("should delete custom roles", async () => { @@ -95,7 +99,7 @@ describe("/roles", () => { .post(`/api/roles`) .send({ name: "user", permissionId: BUILTIN_PERMISSION_IDS.READ_ONLY }) .set(defaultHeaders(appId)) - .expect('Content-Type', /json/) + .expect("Content-Type", /json/) .expect(200) const customRole = createRes.body @@ -111,4 +115,4 @@ describe("/roles", () => { .expect(404) }) }) -}); +})