diff --git a/end2end/tests/userAccessGroup.spec.ts b/end2end/tests/userAccessGroup.spec.ts index a1150dbe..df54eb90 100644 --- a/end2end/tests/userAccessGroup.spec.ts +++ b/end2end/tests/userAccessGroup.spec.ts @@ -1,21 +1,25 @@ import { test, expect } from '@playwright/test'; -test('Validate group creation and an employee addition', async ({ page }) => { +test('Create group and add an employee', async ({ page }) => { await page.goto('https://host.docker.internal/Test_Request_Portal/admin/?a=mod_groups'); + // Generate a unique group name + let randNum = Math.floor(Math.random() * 10000); + let uniqueText = `New Test Group ${randNum}`; + // Create a new group const createGroupButton = page.getByRole('button', { name: '+ Create group' }); await createGroupButton.click(); const groupTitle = page.getByLabel('Group Title'); - await groupTitle.fill('New Test Group 0'); + await groupTitle.fill(uniqueText); const saveButton = page.getByRole('button', { name: 'Save' }); await saveButton.click(); + await page.reload(); // Validate that the new group is successfully created and visible - const newGroup = page.getByRole('heading', { name: 'New Test Group 0' }); - await newGroup.waitFor(); + const newGroup = page.getByRole('heading', { name: uniqueText }); await expect(newGroup).toBeVisible(); // Open new group and add an employee @@ -39,7 +43,7 @@ test('Validate group creation and an employee addition', async ({ page }) => { await expect(employeeTable).toHaveText(/Tester, Tester/); }); -test('Validate group import from another leaf site', async ({ page }) => { +test('Import a group from another leaf site and delete it', async ({ page }) => { await page.goto('https://host.docker.internal/Test_Request_Portal/admin/?a=mod_groups'); const importGroupButton = page.getByRole('button', { name: 'Import group' }); @@ -54,7 +58,6 @@ test('Validate group import from another leaf site', async ({ page }) => { await searchLabel.fill('Concrete Shoes'); const group = page.getByRole('cell', { name: 'Concrete Shoes & kids' }); - await group.waitFor(); await group.click(); const importButton = page.getByRole('button', { name: 'Import', exact: true }); @@ -63,4 +66,16 @@ test('Validate group import from another leaf site', async ({ page }) => { // Verify that the group has been successfully imported const importedGroup = page.getByRole('heading', { name: 'Concrete Shoes & Kids' }); await expect(importedGroup).toBeVisible(); + + await importedGroup.click(); + + // Delete group + const deleteGroupButton = page.getByRole('button', { name: 'Delete Group' }); + + await deleteGroupButton.click(); + const yesButton = page.locator('#confirm_button_save'); + await yesButton.click(); + + await page.reload(); + await expect(importedGroup).not.toBeVisible(); }); \ No newline at end of file