Skip to content

Commit

Permalink
Added jsdoc for user->roles helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavgoel29 committed Nov 14, 2024
1 parent 4477fb1 commit 88ba89c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/helpers/users_roles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import { Page, expect } from '@playwright/test';

/**
* Creates a new role in the application.
*
* @param page - The Playwright Page object representing the browser page.
* @param ROLE_NAME - The name of the role to be created.
* @param ACCESS - The access level to be assigned to the role.
*
* @returns A promise that resolves when the role creation process is complete.
*/
const createNewRole = async (page: Page, ROLE_NAME: string, ACCESS: string) => {
const createRoleButton = page.getByRole('button', { name: 'Create Role' });
await createRoleButton.click();
Expand All @@ -21,6 +30,17 @@ const createNewRole = async (page: Page, ROLE_NAME: string, ACCESS: string) => {
await createButton.click();
};

/**
* Deletes a role if it exists in the roles table on the given page.
*
* @param page - The Playwright Page object representing the browser page.
* @param ROLE_NAME - The name of the role to be deleted.
*
* @remarks
* This function locates the roles table on the page, checks if the specified role exists,
* and if it does, clicks the delete button, confirms the deletion, and verifies that the role
* is no longer visible in the table.
*/
const deleteIfRoleExists = async (page: Page, ROLE_NAME: string) => {
const rolesTable = page.locator('table').filter({
has: page
Expand Down

0 comments on commit 88ba89c

Please sign in to comment.