-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from intuitem/CA-191-Test-that-user-permission…
…s-are-working-correctly Ca 191 Test that a created user can login to his account
- Loading branch information
Showing
13 changed files
with
203 additions
and
135 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { test } from '../utils/test-utils.js'; | ||
|
||
test('startup tests', async ({ loginPage, analyticsPage: overviewPage, page }) => { | ||
await test.step('proper redirection to the login page', async () => { | ||
await page.goto('/'); | ||
await loginPage.hasUrl(1); | ||
await loginPage.login(); | ||
await overviewPage.hasUrl(); | ||
}); | ||
test('startup tests', async ({ loginPage, analyticsPage, page }) => { | ||
await test.step('proper redirection to the login page', async () => { | ||
await page.goto('/'); | ||
await loginPage.hasUrl(1); | ||
await loginPage.login(); | ||
await analyticsPage.hasUrl(); | ||
}); | ||
|
||
await test.step('proper redirection to the overview page after login', async () => { | ||
await overviewPage.hasUrl(); | ||
await overviewPage.hasTitle(); | ||
}); | ||
await test.step('proper redirection to the analytics page after login', async () => { | ||
await analyticsPage.hasUrl(); | ||
await analyticsPage.hasTitle(); | ||
}); | ||
}); |
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,78 @@ | ||
import { test, expect, setHttpResponsesListener, TestContent } from '../utils/test-utils.js'; | ||
|
||
const vars = TestContent.generateTestVars(); | ||
|
||
test.beforeEach('create user', async ({ logedPage, usersPage, foldersPage, sideBar, page }) => { | ||
setHttpResponsesListener(page); | ||
|
||
await foldersPage.goto(); | ||
await foldersPage.createItem({ | ||
name: vars.folderName, | ||
description: vars.description | ||
}); | ||
|
||
await usersPage.goto(); | ||
await usersPage.createItem({ | ||
email: vars.user.email | ||
}); | ||
|
||
await usersPage.editItemButton(vars.user.email).click(); | ||
await usersPage.form.fill({ | ||
first_name: vars.user.firstName, | ||
last_name: vars.user.lastName, | ||
user_groups: [ | ||
`${vars.folderName} - ${vars.usergroups.analyst}`, | ||
`${vars.folderName} - ${vars.usergroups.auditor}`, | ||
`${vars.folderName} - ${vars.usergroups.domainManager}`, | ||
`${vars.folderName} - ${vars.usergroups.validator}`, | ||
], | ||
}); | ||
await usersPage.form.saveButton.click(); | ||
await usersPage.isToastVisible('.+ successfully saved: ' + vars.user.email); | ||
|
||
page.on('dialog', dialog => dialog.accept()); // Accept the alert dialog | ||
|
||
await usersPage.editItemButton(vars.user.email).click(); | ||
await page.getByTestId('set-password-btn').click(); | ||
await expect(page).toHaveURL(/.*\/users\/.+\/edit\/set-password/); | ||
await usersPage.form.fill({ | ||
new_password: vars.user.password, | ||
confirm_new_password: vars.user.password | ||
}); | ||
await usersPage.form.saveButton.click(); | ||
await usersPage.isToastVisible('The password was successfully set'); | ||
|
||
await sideBar.moreButton.click(); | ||
await expect(sideBar.morePanel).not.toHaveAttribute('inert'); | ||
await expect(sideBar.logoutButton).toBeVisible(); | ||
await sideBar.logoutButton.click(); | ||
await logedPage.hasUrl(0); | ||
}); | ||
|
||
test('created user can log to his account', async ({ | ||
loginPage, | ||
page | ||
}) => { | ||
await loginPage.login(vars.user.email, vars.user.password); | ||
await expect(page).toHaveURL(/.*\/analytics/); | ||
}); | ||
|
||
test.afterEach('cleanup', async ({ loginPage, sideBar, foldersPage, usersPage, page }) => { | ||
if (loginPage.email === vars.user.email) { | ||
await sideBar.moreButton.click(); | ||
await expect(sideBar.morePanel).not.toHaveAttribute('inert'); | ||
await expect(sideBar.logoutButton).toBeVisible(); | ||
await sideBar.logoutButton.click(); | ||
await loginPage.hasUrl(0); | ||
await loginPage.login(); | ||
} | ||
await foldersPage.goto(); | ||
await foldersPage.deleteItemButton(vars.folderName).click(); | ||
await foldersPage.deleteModalConfirmButton.click(); | ||
await expect(foldersPage.getRow(vars.folderName)).not.toBeVisible(); | ||
|
||
await usersPage.goto(); | ||
await usersPage.deleteItemButton(vars.user.email).click(); | ||
await usersPage.deleteModalConfirmButton.click(); | ||
await expect(usersPage.getRow(vars.user.email)).not.toBeVisible(); | ||
}); |
Oops, something went wrong.