|
1 | 1 | import LocationChooser from '@/components/LocationChooser'; |
| 2 | +import Navbar from '@/components/Navbar'; |
2 | 3 | import { expect, test } from '@/fixtures/fixtures'; |
| 4 | +import CreateInvoicePage from '@/pages/invoice/CreateInvoicePage'; |
| 5 | +import InvoiceListPage from '@/pages/invoice/InvoiceListPage'; |
3 | 6 | import LoginPage from '@/pages/LoginPage'; |
4 | 7 | import { CreateUserType } from '@/types'; |
5 | 8 | import UniqueIdentifier from '@/utils/UniqueIdentifier'; |
@@ -152,3 +155,45 @@ test('Add requestor permission to non manage inventory depot', async ({ |
152 | 155 | await expect(newUserLocationChooser.getLocation(location.name)).toBeVisible(); |
153 | 156 | await newUserLocationChooser.getLocation(location.name).click(); |
154 | 157 | }); |
| 158 | + |
| 159 | +test('Add new user with invoice permission', async ({ |
| 160 | + editUserPage, |
| 161 | + mainLocationService, |
| 162 | + emptyUserContext, |
| 163 | +}) => { |
| 164 | + await test.step('Select role "Admin"', async () => { |
| 165 | + await editUserPage.authorizationTabSection.defaultRoleSelect.click(); |
| 166 | + await editUserPage.authorizationTabSection.getUserRole('Admin').click(); |
| 167 | + await editUserPage.authorizationTabSection.defaultRoleSelect.click(); |
| 168 | + await editUserPage.authorizationTabSection |
| 169 | + .getUserRole('Invoice user') |
| 170 | + .click(); |
| 171 | + await editUserPage.authorizationTabSection.saveButton.click(); |
| 172 | + }); |
| 173 | + |
| 174 | + const location = await mainLocationService.getLocation(); |
| 175 | + const newUserPage = await emptyUserContext.newPage(); |
| 176 | + const newUserLoginPage = new LoginPage(newUserPage); |
| 177 | + const newUserLocationChooser = new LocationChooser(newUserPage); |
| 178 | + const newUserCreateInvoicePage = new CreateInvoicePage(newUserPage); |
| 179 | + const newUserListInvoicePage = new InvoiceListPage(newUserPage); |
| 180 | + |
| 181 | + await test.step('Login as new user', async () => { |
| 182 | + await newUserLoginPage.goToPage(); |
| 183 | + await newUserLoginPage.fillLoginForm(formData.username, formData.password); |
| 184 | + await newUserLoginPage.loginButton.click(); |
| 185 | + }); |
| 186 | + |
| 187 | + await newUserLocationChooser |
| 188 | + .getOrganization(location.organization?.name) |
| 189 | + .click(); |
| 190 | + await expect(newUserLocationChooser.getLocation(location.name)).toBeVisible(); |
| 191 | + await newUserLocationChooser.getLocation(location.name).click(); |
| 192 | + |
| 193 | + await test.step('Assert access to invoice pages', async () => { |
| 194 | + await newUserCreateInvoicePage.goToPage(); |
| 195 | + await expect(newUserPage.getByText('Vendor Invoice Number')).toBeVisible(); |
| 196 | + await newUserListInvoicePage.goToPage(); |
| 197 | + await expect(newUserListInvoicePage.invoiceListHeader).toBeVisible(); |
| 198 | + }); |
| 199 | +}); |
0 commit comments