diff --git a/qa-core/src/config/internal-api/TestConfiguration/applications.ts b/qa-core/src/config/internal-api/TestConfiguration/applications.ts index 1cb9033984..a874ef0cb8 100644 --- a/qa-core/src/config/internal-api/TestConfiguration/applications.ts +++ b/qa-core/src/config/internal-api/TestConfiguration/applications.ts @@ -117,7 +117,7 @@ export default class AppApi { return [response, json] } - async update( + async rename( appId: string, oldName: string, body: any diff --git a/qa-core/src/tests/internal-api/applications/applications.spec.ts b/qa-core/src/tests/internal-api/applications/applications.spec.ts index 4edcd34ca4..e0e07e3fba 100644 --- a/qa-core/src/tests/internal-api/applications/applications.spec.ts +++ b/qa-core/src/tests/internal-api/applications/applications.spec.ts @@ -67,7 +67,7 @@ describe("Internal API - Application creation, update, publish and delete", () = await config.applications.unpublish(app.appId) }) - it("POST - Sync application before deployment", async () => { + it("Sync application before deployment", async () => { const app = await config.applications.create(generateApp()) config.applications.api.appId = app.appId @@ -79,7 +79,7 @@ describe("Internal API - Application creation, update, publish and delete", () = }) }) - it("POST - Sync application after deployment", async () => { + it("Sync application after deployment", async () => { const app = await config.applications.create(generateApp()) config.applications.api.appId = app.appId @@ -94,12 +94,12 @@ describe("Internal API - Application creation, update, publish and delete", () = }) }) - it("PUT - Update an application", async () => { + it("Rename an application", async () => { const app = await config.applications.create(generateApp()) config.applications.api.appId = app.appId - await config.applications.update(app.appId, app.name, { + await config.applications.rename(app.appId, app.name, { name: generator.word(), }) }) @@ -112,14 +112,14 @@ describe("Internal API - Application creation, update, publish and delete", () = await config.applications.updateIcon(app.appId) }) - it("POST - Revert Changes without changes", async () => { + it("Revert Changes without changes", async () => { const app = await config.applications.create(generateApp()) config.applications.api.appId = app.appId await config.applications.revertUnpublished(app.appId) }) - it("POST - Revert Changes", async () => { + it("Revert Changes", async () => { const app = await config.applications.create(generateApp()) config.applications.api.appId = app.appId @@ -137,7 +137,7 @@ describe("Internal API - Application creation, update, publish and delete", () = await config.applications.getRoutes() }) - it("DELETE - Delete an application", async () => { + it("Delete an application", async () => { const app = await config.applications.create(generateApp()) await config.applications.delete(app.appId) diff --git a/qa-core/src/tests/internal-api/screens/screens.spec.ts b/qa-core/src/tests/internal-api/screens/screens.spec.ts index 1d2a21a8c7..2e4292afa8 100644 --- a/qa-core/src/tests/internal-api/screens/screens.spec.ts +++ b/qa-core/src/tests/internal-api/screens/screens.spec.ts @@ -18,7 +18,7 @@ describe("Internal API - /screens endpoints", () => { await config.afterAll() }) - it("POST - Create a screen with each role type", async () => { + it("Create a screen with each role type", async () => { // Create app const app = await appConfig.applications.create(generateApp()) @@ -32,7 +32,7 @@ describe("Internal API - /screens endpoints", () => { } }) - it("GET - Fetch screens", async () => { + it("Get screens", async () => { // Create app const app = await appConfig.applications.create(generateApp()) @@ -44,7 +44,7 @@ describe("Internal API - /screens endpoints", () => { await appConfig.applications.getRoutes(true) }) - it("DELETE - Delete a screen", async () => { + it("Delete a screen", async () => { // Create app const app = await appConfig.applications.create(generateApp()) diff --git a/qa-core/src/tests/internal-api/userManagement/appSpecificRoles.spec.ts b/qa-core/src/tests/internal-api/userManagement/appSpecificRoles.spec.ts index 2447a31558..fe985094fd 100644 --- a/qa-core/src/tests/internal-api/userManagement/appSpecificRoles.spec.ts +++ b/qa-core/src/tests/internal-api/userManagement/appSpecificRoles.spec.ts @@ -22,15 +22,21 @@ describe("Internal API - App Specific Roles & Permissions", () => { }) it("Add BASIC user to app", async () => { + // Create a user with BASIC role and check if it was created successfully const appUser = generateUser() expect(appUser[0].builder?.global).toEqual(false) expect(appUser[0].admin?.global).toEqual(false) + + // Add the user to the tenant. const [createUserResponse, createUserJson] = await config.users.addMultiple(appUser) const app = await config.applications.create(appFromTemplate()) config.applications.api.appId = app.appId + // Get all the information from the create user const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) + + // Create the body with the information from the user and add the role to the app const body: User = { ...userInfoJson, roles: { @@ -39,6 +45,7 @@ describe("Internal API - App Specific Roles & Permissions", () => { } await config.users.updateInfo(body) + // Get the user information again and check if the role was added const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) expect(changedUserInfoJson.roles[app.appId]).toBeDefined() expect(changedUserInfoJson.roles[app.appId]).toEqual("BASIC") @@ -46,18 +53,19 @@ describe("Internal API - App Specific Roles & Permissions", () => { }) it("Add ADMIN user to app", async () => { + // Create a user with ADMIN role and check if it was created successfully const adminUser = generateUser(1, "admin") expect(adminUser[0].builder?.global).toEqual(true) expect(adminUser[0].admin?.global).toEqual(true) const [createUserResponse, createUserJson] = await config.users.addMultiple(adminUser) - //const app = await config.applications.create(generateApp()) - //config.applications.api.appId = app.appId - const app = await config.applications.create(appFromTemplate()) config.applications.api.appId = app.appId + // Get all the information from the create user const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) + + // Create the body with the information from the user and add the role to the app const body: User = { ...userInfoJson, roles: { @@ -66,28 +74,26 @@ describe("Internal API - App Specific Roles & Permissions", () => { } await config.users.updateInfo(body) + // Get the user information again and check if the role was added const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) expect(changedUserInfoJson.roles[app.appId]).toBeDefined() expect(changedUserInfoJson.roles[app.appId]).toEqual("ADMIN") - // publish app - await config.applications.publish(app.appId) - // check published app renders - config.applications.api.appId = db.getProdAppID(app.appId!) - await config.applications.canRender() - }) it("Add POWER user to app", async () => { + // Create a user with POWER role and check if it was created successfully const powerUser = generateUser(1, 'developer') expect(powerUser[0].builder?.global).toEqual(true) - const [createUserResponse, createUserJson] = await config.users.addMultiple(powerUser) const app = await config.applications.create(generateApp()) config.applications.api.appId = app.appId + // Get all the information from the create user const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) + + // Create the body with the information from the user and add the role to the app const body: User = { ...userInfoJson, roles: { @@ -96,6 +102,7 @@ describe("Internal API - App Specific Roles & Permissions", () => { } await config.users.updateInfo(body) + // Get the user information again and check if the role was added const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) expect(changedUserInfoJson.roles[app.appId]).toBeDefined() expect(changedUserInfoJson.roles[app.appId]).toEqual("POWER") @@ -104,6 +111,7 @@ describe("Internal API - App Specific Roles & Permissions", () => { describe("Check Access for default roles", () => { it("Check Table access for app user", async () => { + // Create a user with BASIC role and check if it was created successfully const appUser = generateUser() expect(appUser[0].builder?.global).toEqual(false) expect(appUser[0].admin?.global).toEqual(false) @@ -112,7 +120,10 @@ describe("Internal API - App Specific Roles & Permissions", () => { const app = await config.applications.create(generateApp()) config.applications.api.appId = app.appId + // Get all the information from the create user const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) + + // Create the body with the information from the user and add the role to the app const body: User = { ...userInfoJson, roles: { @@ -121,13 +132,17 @@ describe("Internal API - App Specific Roles & Permissions", () => { } await config.users.updateInfo(body) + // Get the user information again and check if the role was added const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) expect(changedUserInfoJson.roles[app.appId]).toBeDefined() expect(changedUserInfoJson.roles[app.appId]).toEqual("BASIC") + // Create a table const [createdTableResponse, createdTableData] = await config.tables.save( generateTable() ) + + // Login with the user created and try to create a column await config.login(appUser[0].email, appUser[0].password) const newColumn = generateNewColumnForTable(createdTableData) await config.tables.forbiddenSave( @@ -136,6 +151,7 @@ describe("Internal API - App Specific Roles & Permissions", () => { }) it("Check Table access for developer", async () => { + // Create a user with POWER role and check if it was created successfully const developer = generateUser(1, 'developer') expect(developer[0].builder?.global).toEqual(true) @@ -144,7 +160,10 @@ describe("Internal API - App Specific Roles & Permissions", () => { const app = await config.applications.create(generateApp()) config.applications.api.appId = app.appId + // Get all the information from the create user const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) + + // Create the body with the information from the user and add the role to the app const body: User = { ...userInfoJson, roles: { @@ -153,13 +172,17 @@ describe("Internal API - App Specific Roles & Permissions", () => { } await config.users.updateInfo(body) + // Get the user information again and check if the role was added const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) expect(changedUserInfoJson.roles[app.appId]).toBeDefined() expect(changedUserInfoJson.roles[app.appId]).toEqual("POWER") + // Create a table const [createdTableResponse, createdTableData] = await config.tables.save( generateTable() ) + + // Login with the user created and try to create a column await config.login(developer[0].email, developer[0].password) const newColumn = generateNewColumnForTable(createdTableData) const [addColumnResponse, addColumnData] = await config.tables.save( @@ -169,6 +192,7 @@ describe("Internal API - App Specific Roles & Permissions", () => { }) it("Check Table access for admin", async () => { + // Create a user with ADMIN role and check if it was created successfully const adminUser = generateUser(1, "admin") expect(adminUser[0].builder?.global).toEqual(true) expect(adminUser[0].admin?.global).toEqual(true) @@ -177,7 +201,10 @@ describe("Internal API - App Specific Roles & Permissions", () => { const app = await config.applications.create(generateApp()) config.applications.api.appId = app.appId + // Get all the information from the create user const [userInfoResponse, userInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) + + // Create the body with the information from the user and add the role to the app const body: User = { ...userInfoJson, roles: { @@ -186,10 +213,12 @@ describe("Internal API - App Specific Roles & Permissions", () => { } await config.users.updateInfo(body) + // Get the user information again and check if the role was added const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id) expect(changedUserInfoJson.roles[app.appId]).toBeDefined() expect(changedUserInfoJson.roles[app.appId]).toEqual("ADMIN") + // Login with the created user and create a table await config.login(adminUser[0].email, adminUser[0].password) const [createdTableResponse, createdTableData] = await config.tables.save( generateTable() diff --git a/qa-core/src/tests/internal-api/userManagement/userManagement.spec.ts b/qa-core/src/tests/internal-api/userManagement/userManagement.spec.ts index 32820b8b7f..2290106731 100644 --- a/qa-core/src/tests/internal-api/userManagement/userManagement.spec.ts +++ b/qa-core/src/tests/internal-api/userManagement/userManagement.spec.ts @@ -18,9 +18,13 @@ describe("Internal API - User Management & Permissions", () => { }) it("Add Users with different roles", async () => { + // Get all users await config.users.search() + + // Get all roles await config.users.getRoles() + // Add users with each role const admin = generateUser(1, "admin") expect(admin[0].builder?.global).toEqual(true) expect(admin[0].admin?.global).toEqual(true) @@ -34,6 +38,7 @@ describe("Internal API - User Management & Permissions", () => { await config.users.addMultiple(userList) + // Check users are added const [allUsersResponse, allUsersJson] = await config.users.getAll() expect(allUsersJson.length).toBeGreaterThan(0)