From 17e27def4aac9085d3358cda73b02f0609d526ff Mon Sep 17 00:00:00 2001
From: nk2136 <156982976+nk2136@users.noreply.github.com>
Date: Thu, 14 Nov 2024 14:45:43 -0600
Subject: [PATCH] added new test scenarios

---
 end2end/tests/userAccessGroup.spec.ts | 51 ++++++++++++++++++++++-----
 1 file changed, 43 insertions(+), 8 deletions(-)

diff --git a/end2end/tests/userAccessGroup.spec.ts b/end2end/tests/userAccessGroup.spec.ts
index c4319275..537b8857 100644
--- a/end2end/tests/userAccessGroup.spec.ts
+++ b/end2end/tests/userAccessGroup.spec.ts
@@ -1,14 +1,17 @@
 import { test, expect } from '@playwright/test';
 
-test.beforeEach(async ({ page }) => {
-  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/?a=mod_groups#/');
-});
-
 test.afterAll(async ({ page }) => {
   await page.close();
 });
 
+test('Validate if the user is able to access user access groups from admin panel', async ({ page }) => {
+  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/');
+  await page.getByRole('button', { name: ' User Access Groups Modify' }).click();
+  await expect(page.locator('#bodyarea')).toContainText('AdminUser access');
+})
+
 test('Validate if the user is able to create a new group and add a user', async ({ page }) => {
+  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/?a=mod_groups#/');
   await page.getByRole('button', { name: '+ Create group' }).click();
   await page.getByLabel('Group Title').fill('New Test Group 0');
   await page.getByRole('button', { name: 'Save' }).click();
@@ -19,16 +22,19 @@ test('Validate if the user is able to create a new group and add a user', async
   const removeBtn = page.getByRole('button', { name: 'Remove' });
   await removeBtn.waitFor();
   await page.getByRole('button', { name: 'Save' }).click();
-  await page.reload();
+  const user = page.locator('#members208').getByText('Rhona Goodwin + 1 others');
+  await user.waitFor({ state: 'visible' });
 });
 
 test('Validate if the user is able to view the new group in the group history', async ({ page }) => {
+  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/?a=mod_groups#/');
   await page.getByRole('button', { name: 'Show group history' }).click();
   await expect(page.locator('tbody')).toContainText('Tester Tester added new group: New Test Group 0');
   await page.getByRole('button', { name: 'Close' }).click();
 });
 
 test('Validate if the user is able to search for the new group in User groups', async ({ page }) => {
+  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/?a=mod_groups#/');
   await page.getByRole('link', { name: 'User groups' }).click();
   await page.getByLabel('Filter by group or user name').fill('New Test Group 0');
   await page.keyboard.press('Enter');
@@ -36,6 +42,7 @@ test('Validate if the user is able to search for the new group in User groups',
 });
 
 test('Validate if the user is able to view the group history', async ({ page }) => {
+  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/?a=mod_groups#/');
   await page.getByLabel('Filter by group or user name').fill('New Test Group 0');
   await expect(page.locator('text=New Test Group 0')).toBeVisible();
   await page.getByRole('heading', { name: 'New Test Group' }).click();
@@ -47,6 +54,7 @@ test('Validate if the user is able to view the group history', async ({ page })
 });
 
 test('Validate if the user is able to add the user in Nexus', async ({ page }) => {
+  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/?a=mod_groups#/');
   await page.getByRole('heading', { name: 'New Test Group' }).click();
   await page.getByRole('button', { name: 'Add to Nexus' }).click();
   await page.getByRole('button', { name: 'Yes' }).click();
@@ -57,6 +65,7 @@ test('Validate if the user is able to add the user in Nexus', async ({ page }) =
 });
 
 test('Validate if the user is able to search for System Admin in the System administrators', async ({ page }) => {
+  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/?a=mod_groups#/');
   await page.getByRole('link', { name: 'System administrators (2)' }).click();
   await page.getByLabel('Filter by group or user name').fill('sysa');
   await page.keyboard.press('Enter');
@@ -64,6 +73,7 @@ test('Validate if the user is able to search for System Admin in the System admi
 })
 
 test('Validate if the user is able to add a new admin in System Admin', async ({ page }) => {
+  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/?a=mod_groups#/');
   const sysadmin = page.locator('#adminList');
   await sysadmin.click();
   const searchBox = page.getByLabel('Search for user to add as');
@@ -85,6 +95,7 @@ test('Validate if the user is able to add a new admin in System Admin', async ({
 });
 
 test('Validate if the user is able to find the new admin in the primary admin', async ({ page }) => {
+  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/?a=mod_groups#/');
   await page.getByRole('heading', { name: 'Primary Admin' }).click();
   await page.locator('#employeeSelectorDropdown').selectOption('vtrofbrebekah');
   await page.getByRole('button', { name: 'Save' }).click();
@@ -93,7 +104,8 @@ test('Validate if the user is able to find the new admin in the primary admin',
   await page.getByRole('button', { name: 'Close' }).click();
 });
 
-test('Validate if the user is able to see primary admin histroy', async ({ page }) => {
+test('Validate if the user is able to see primary admin history', async ({ page }) => {
+  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/?a=mod_groups#/');
   await page.getByRole('heading', { name: 'Primary Admin' }).click();
   await expect(page.getByRole('button', { name: 'View History' })).toBeVisible();
   await page.getByRole('button', { name: 'View History' }).click();
@@ -102,6 +114,7 @@ test('Validate if the user is able to see primary admin histroy', async ({ page
 });
 
 test('Validate if the user is able to remove an admin from System Admin', async ({ page }) => {
+  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/?a=mod_groups#/');
   const sysadmin = page.locator('#adminList');
   await sysadmin.click();
   await page.getByLabel('REMOVE Carroll, Zoila').click();
@@ -112,6 +125,7 @@ test('Validate if the user is able to remove an admin from System Admin', async
 });
 
 test('Validate if the user is able to import a group', async ({ page }) => {
+  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/?a=mod_groups#/');
   await page.getByRole('button', { name: 'Import group' }).click();
   await page.getByLabel('Search for user to add as').fill('copper');
   await page.getByRole('cell', { name: 'Copper Books' }).click();
@@ -119,11 +133,32 @@ test('Validate if the user is able to import a group', async ({ page }) => {
   await page.getByLabel('Filter by group or user name').fill('copper Books');
   await page.keyboard.press('Enter');
   await expect(page.locator('#groupTitle183')).toContainText('Copper Books');
-})
+});
+
+test('Validate if the user can add multiple users to the group', async ({ page }) => {
+  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/?a=mod_groups#/');
+  await page.getByRole('heading', { name: 'New Test Group 0' }).click();
+  await page.getByLabel('Search for user to add as').click();
+  await page.getByLabel('Search for user to add as').fill('car');
+  await page.getByRole('cell', { name: 'Nikolaus, Carlton Hills.' }).click();
+  await page.getByLabel('Search for user to add as').click();
+  await page.getByLabel('Search for user to add as').fill('ni');
+  await page.getByRole('cell', { name: 'Nicolas, Sherlyn Huels.' }).click();
+  await page.getByLabel('Search for user to add as').click();
+  await expect(page.getByRole('table')).toContainText('Nicolas, Sherlyn');
+  await page.getByRole('button', { name: 'Save' }).click();
+  const users = page.locator('#members208').getByText('Rhona Goodwin + 3 others');
+  await users.waitFor();
+  await page.getByRole('heading', { name: 'New Test Group 0' }).click();
+  await expect(page.getByRole('table')).toContainText('Nikolaus, Carlton');
+  await expect(page.getByRole('table')).toContainText('Nicolas, Sherlyn');
+  await page.getByRole('button', { name: 'Close' }).click();
+});
 
 test('Validate if the user is able to delete the group and remove the user', async ({ page }) => {
+  await page.goto('https://host.docker.internal/LEAF_Request_Portal/admin/?a=mod_groups#/');
   await page.getByRole('heading', { name: 'New Test Group 0' }).click();
-  await page.getByRole('button', { name: 'Remove' }).click();
+  await page.locator('#removeMember_0').click();
   await page.getByRole('button', { name: 'Yes' }).click();
   await expect(page.getByRole('cell', { name: 'users, testing' })).not.toBeVisible();
   await page.getByRole('heading', { name: 'New Test Group 0' }).click();