-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* AB#30150 add e2e test and new seed script --------- Co-authored-by: Domenico Gemoli <dgemoli@redcross.nl>
- Loading branch information
Showing
11 changed files
with
543 additions
and
0 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
52 changes: 52 additions & 0 deletions
52
e2e/portalicious/tests/ManageTeam/AllSystemUsersCanBeAddedToProjectTeam.spec.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,52 @@ | ||
import BasePage from '@121-e2e/portalicious/pages/BasePage'; | ||
import LoginPage from '@121-e2e/portalicious/pages/LoginPage'; | ||
import ProjectTeam from '@121-e2e/portalicious/pages/ProjectTeam'; | ||
import { SeedScript } from '@121-service/src/scripts/seed-script.enum'; | ||
import { resetDB } from '@121-service/test/helpers/utility.helper'; | ||
import { test } from '@playwright/test'; | ||
|
||
const expectedAssignedUsers = ['admin@example.org']; | ||
const expectedAvailablesystemUsers = [ | ||
'program-admin@example.org', | ||
'view-user@example.org', | ||
'kobo-user@example.org', | ||
'cva-manager@example.org', | ||
'cva-officer@example.org', | ||
'finance-manager@example.org', | ||
'finance-officer@example.org', | ||
'view-no-pii@example.org', | ||
]; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await resetDB(SeedScript.oneAdmin); | ||
|
||
// Login | ||
const loginPage = new LoginPage(page); | ||
await page.goto('/'); | ||
await loginPage.login( | ||
process.env.USERCONFIG_121_SERVICE_EMAIL_ADMIN, | ||
process.env.USERCONFIG_121_SERVICE_PASSWORD_ADMIN, | ||
); | ||
}); | ||
|
||
test('[29758] All system-users are available to be added to a "project team"', async ({ | ||
page, | ||
}) => { | ||
const basePage = new BasePage(page); | ||
const manageTeam = new ProjectTeam(page); | ||
const projectTitle = 'Cash program Warsaw'; | ||
|
||
await test.step('Select program and navigate to Manage team', async () => { | ||
await basePage.selectProgram(projectTitle); | ||
await basePage.navigateToProgramPage('Team'); | ||
}); | ||
|
||
await test.step('Validate assigned users are visible', async () => { | ||
await manageTeam.validateAssignedTeamMembers(expectedAssignedUsers); | ||
}); | ||
|
||
await test.step('Validate available system users are visible', async () => { | ||
await manageTeam.openAddUserForm(); | ||
await manageTeam.validateAvailableSystemUsers(expectedAvailablesystemUsers); | ||
}); | ||
}); |
45 changes: 45 additions & 0 deletions
45
e2e/portalicious/tests/ManageTeam/AssignSuccessfullyRolesToUser.spec.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,45 @@ | ||
import BasePage from '@121-e2e/portalicious/pages/BasePage'; | ||
import LoginPage from '@121-e2e/portalicious/pages/LoginPage'; | ||
import ProjectTeam from '@121-e2e/portalicious/pages/ProjectTeam'; | ||
import { SeedScript } from '@121-service/src/scripts/seed-script.enum'; | ||
import { resetDB } from '@121-service/test/helpers/utility.helper'; | ||
import { test } from '@playwright/test'; | ||
|
||
const expectedAssignedUsers = ['admin@example.org', 'cva-officer@example.org']; | ||
const userSearchPhrase = 'cva-officer'; | ||
const userFullEmail = 'cva-officer@example.org'; | ||
const userRole = 'Only CREATE registrations'; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await resetDB(SeedScript.oneAdmin); | ||
|
||
// Login | ||
const loginPage = new LoginPage(page); | ||
await page.goto('/'); | ||
await loginPage.login( | ||
process.env.USERCONFIG_121_SERVICE_EMAIL_ADMIN, | ||
process.env.USERCONFIG_121_SERVICE_PASSWORD_ADMIN, | ||
); | ||
}); | ||
|
||
test('[29759] Assign successfully roles to a user ', async ({ page }) => { | ||
const basePage = new BasePage(page); | ||
const manageTeam = new ProjectTeam(page); | ||
const projectTitle = 'Cash program Warsaw'; | ||
|
||
await test.step('Select program and navigate to Manage team', async () => { | ||
await basePage.selectProgram(projectTitle); | ||
await basePage.navigateToProgramPage('Team'); | ||
}); | ||
|
||
await test.step('Validate available system users are visible', async () => { | ||
await manageTeam.openAddUserForm(); | ||
await manageTeam.addUserToTeam({ | ||
userSearchPhrase: userSearchPhrase, | ||
userEmail: userFullEmail, | ||
role: userRole, | ||
}); | ||
await manageTeam.validateToastMessage('User added'); | ||
await manageTeam.validateAssignedTeamMembers(expectedAssignedUsers); | ||
}); | ||
}); |
59 changes: 59 additions & 0 deletions
59
e2e/portalicious/tests/ManageTeam/RemoveUserFromTeam.spec.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,59 @@ | ||
import BasePage from '@121-e2e/portalicious/pages/BasePage'; | ||
import LoginPage from '@121-e2e/portalicious/pages/LoginPage'; | ||
import ProjectTeam from '@121-e2e/portalicious/pages/ProjectTeam'; | ||
import { SeedScript } from '@121-service/src/scripts/seed-script.enum'; | ||
import { resetDB } from '@121-service/test/helpers/utility.helper'; | ||
import { test } from '@playwright/test'; | ||
|
||
const expectedInitialAssignedUsers = [ | ||
'admin@example.org', | ||
'program-admin@example.org', | ||
'view-user@example.org', | ||
'kobo-user@example.org', | ||
'cva-manager@example.org', | ||
'cva-officer@example.org', | ||
'finance-manager@example.org', | ||
'finance-officer@example.org', | ||
'view-no-pii@example.org', | ||
]; | ||
const userToRemove = 'view-no-pii@example.org'; | ||
const expectedFinalAssignedUsers = expectedInitialAssignedUsers.filter( | ||
(email) => email !== userToRemove, | ||
); | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await resetDB(SeedScript.test); | ||
|
||
// Login | ||
const loginPage = new LoginPage(page); | ||
await page.goto('/'); | ||
await loginPage.login( | ||
process.env.USERCONFIG_121_SERVICE_EMAIL_ADMIN, | ||
process.env.USERCONFIG_121_SERVICE_PASSWORD_ADMIN, | ||
); | ||
}); | ||
|
||
test('[29760] Users should be removable from "project team"', async ({ | ||
page, | ||
}) => { | ||
const basePage = new BasePage(page); | ||
const manageTeam = new ProjectTeam(page); | ||
const projectTitle = 'Cash program Westeros'; | ||
|
||
await test.step('Select program and navigate to Manage team', async () => { | ||
await basePage.selectProgram(projectTitle); | ||
await basePage.navigateToProgramPage('Team'); | ||
}); | ||
|
||
await test.step('Validate assigned users are visible', async () => { | ||
await manageTeam.validateAssignedTeamMembers(expectedInitialAssignedUsers); | ||
}); | ||
|
||
await test.step('Validate available system users are visible', async () => { | ||
await manageTeam.removeUserFromTeam({ | ||
userEmail: userToRemove, | ||
}); | ||
await manageTeam.validateToastMessage('User removed'); | ||
await manageTeam.validateAssignedTeamMembers(expectedFinalAssignedUsers); | ||
}); | ||
}); |
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
24 changes: 24 additions & 0 deletions
24
services/121-service/src/scripts/seed-program-test-one-admin.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,24 @@ | ||
import { InterfaceScript } from '@121-service/src/scripts/scripts.module'; | ||
import { SeedHelper } from '@121-service/src/scripts/seed-helper'; | ||
import messageTemplateTest from '@121-service/src/seed-data/message-template/message-template-test.json'; | ||
import organizationAdmin from '@121-service/src/seed-data/organization/organization-one-admin.json'; | ||
import programTest from '@121-service/src/seed-data/program/program-test-one-admin.json'; | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class SeedTestOneAdmin implements InterfaceScript { | ||
public constructor(private readonly seedHelper: SeedHelper) {} | ||
|
||
public async run(isApiTests = false): Promise<void> { | ||
// ***** CREATE PROGRAM ***** | ||
const program = await this.seedHelper.addProgram(programTest, isApiTests); | ||
|
||
// ***** CREATE MESSAGE TEMPLATES ***** | ||
await this.seedHelper.addMessageTemplates(messageTemplateTest, program); | ||
|
||
await this.seedHelper.addOneDefaultAdminUser(program); | ||
|
||
// ***** CREATE ORGANIZATION ***** | ||
await this.seedHelper.addOrganization(organizationAdmin); | ||
} | ||
} |
Oops, something went wrong.