Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User access group test #14

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
66 changes: 66 additions & 0 deletions end2end/tests/userAccessGroup.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { test, expect } from '@playwright/test';

test('Validate group creation and an employee addition', async ({ page }) => {
await page.goto('https://host.docker.internal/Test_Request_Portal/admin/?a=mod_groups');

// 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');

const saveButton = page.getByRole('button', { name: 'Save' });
await saveButton.click();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not error on repeat runs, but I'm concerned that the test does not reflect it only being possible to create a group of a specific name once (even if it's subsequently deleted).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elaborating on the concern: Tests that involve creating and validating entries must not use fixed values. Subsequent runs of this test fail to validate intended functionality: whether the user can create groups. In this test, the second run actually skips the group creation because the group already exists (which would normally trigger an error).

Instead of:

  await groupTitle.fill('New Test Group 0');

A more complete solution would be:

let randNum = Math.random();
let uniqueText = `New Test Group ${randNum}`;

await groupTitle.fill(uniqueText);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

// Validate that the new group is successfully created and visible
const newGroup = page.getByRole('heading', { name: 'New Test Group 0' });
await newGroup.waitFor();
await expect(newGroup).toBeVisible();

// Open new group and add an employee
await newGroup.click();

const searchInput = page.getByLabel('Search for user to add as');
await searchInput.fill('test');
const employeeToAdd = page.getByRole('cell', { name: 'Tester, Tester Product Liaison' });
await employeeToAdd.click();
const removeButton = page.getByRole('button', { name: 'Remove' });
await removeButton.waitFor();
await saveButton.click();

// Reload the page to ensure the changes are reflected
await page.reload();
await newGroup.click();

// Validate that the employee appears in the group’s employee table
const employeeTable = page.locator('#employee_table');
await employeeTable.waitFor();
await expect(employeeTable).toHaveText(/Tester, Tester/);
});

test('Validate group import from another leaf site', async ({ page }) => {
await page.goto('https://host.docker.internal/Test_Request_Portal/admin/?a=mod_groups');

const importGroupButton = page.getByRole('button', { name: 'Import group' });
await importGroupButton.click();

const importGroupDialog = page.locator('[aria-describedby="import_dialog"]');
await importGroupDialog.waitFor();

// Import the group
const searchLabel = page.getByLabel('Search for user to add as');
await searchLabel.waitFor();
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 });
await importButton.click();

// Verify that the group has been successfully imported
const importedGroup = page.getByRole('heading', { name: 'Concrete Shoes & Kids' });
await expect(importedGroup).toBeVisible();
});