Skip to content

Commit 59b63ad

Browse files
committed
OBPIH-6883 add test for user with invoice permission
1 parent 2957023 commit 59b63ad

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/tests/users/userSettings.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import LocationChooser from '@/components/LocationChooser';
2+
import Navbar from '@/components/Navbar';
23
import { expect, test } from '@/fixtures/fixtures';
4+
import CreateInvoicePage from '@/pages/invoice/CreateInvoicePage';
5+
import InvoiceListPage from '@/pages/invoice/InvoiceListPage';
36
import LoginPage from '@/pages/LoginPage';
47
import { CreateUserType } from '@/types';
58
import UniqueIdentifier from '@/utils/UniqueIdentifier';
@@ -152,3 +155,45 @@ test('Add requestor permission to non manage inventory depot', async ({
152155
await expect(newUserLocationChooser.getLocation(location.name)).toBeVisible();
153156
await newUserLocationChooser.getLocation(location.name).click();
154157
});
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

Comments
 (0)