-
Notifications
You must be signed in to change notification settings - Fork 0
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
nk2136
wants to merge
13
commits into
main
Choose a base branch
from
user-access-group-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
21a521b
test user access group
nk2136 aee9e5c
add test scenarios
nk2136 9774e69
add new test scenarios
nk2136 315ac78
Standardized test names to improve readability
nk2136 a19b080
resolve test issues
nk2136 17e27de
added new test scenarios
nk2136 81b39ca
code refactor
nk2136 f0b6c13
removed multiple tests
nk2136 368afdb
add validations
nk2136 f08fb96
update leaf request url
nk2136 0a9af25
code clean up removed only from test
nk2136 73acc32
fix test name and group name
nk2136 1c119c8
Test added for system admin search and view group history
nk2136 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
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(uniqueText); | ||
|
||
const saveButton = page.getByRole('button', { name: 'Save' }); | ||
await saveButton.click(); | ||
await page.reload(); | ||
|
||
const newGroup = page.getByRole('heading', { name: uniqueText }); | ||
await newGroup.waitFor({ state: 'visible' }); | ||
|
||
// 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('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' }); | ||
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.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(); | ||
|
||
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(); | ||
}); | ||
|
||
test('System admin search', async ({ page }) => { | ||
await page.goto('https://host.docker.internal/Test_Request_Portal/admin/?a=mod_groups'); | ||
|
||
const systemAdminsLink = page.getByRole('link', { name: 'System administrators' }); | ||
await systemAdminsLink.click(); | ||
|
||
const searchBox = page.getByLabel('Filter by group or user name'); | ||
await searchBox.fill('sysa'); | ||
await page.keyboard.press('Enter'); | ||
|
||
// Verify the system admin exists | ||
const sysAdminGroup = page.locator('#groupTitle1'); | ||
await expect(sysAdminGroup).toBeVisible(); | ||
await expect(sysAdminGroup).toContainText('sysadmin'); | ||
|
||
// Verify primary admin not found in search results | ||
const otherGroup = page.locator('#groupTitle2'); | ||
await expect(otherGroup).not.toBeVisible(); | ||
}); | ||
|
||
test('View user group history', async ({ page }) => { | ||
await page.goto('https://host.docker.internal/Test_Request_Portal/admin/?a=mod_groups'); | ||
|
||
// Open group | ||
const group = page.getByRole('heading', { name: 'Iron Games' }); | ||
await group.click(); | ||
|
||
const viewHistoryButton = page.getByRole('button', { name: 'View History' }); | ||
await viewHistoryButton.waitFor(); | ||
await viewHistoryButton.click(); | ||
|
||
// Verify the group name in the history | ||
const historyName = page.locator('#historyName'); | ||
await historyName.waitFor(); | ||
await expect(historyName).toContainText('Group Name: Iron Games'); | ||
|
||
const closeHistoryButton = page.getByLabel('Group history').getByRole('button', { name: 'Close' }); | ||
await closeHistoryButton.click(); | ||
|
||
const closeButton = page.getByRole('button', { name: 'Close' }); | ||
await closeButton.click(); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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:
A more complete solution would be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed