Skip to content

Commit

Permalink
fix users table and modify role test
Browse files Browse the repository at this point in the history
  • Loading branch information
Anchel123 committed Feb 4, 2025
1 parent 34f246a commit fca6cb1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
2 changes: 2 additions & 0 deletions app/components/TableComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Cell = {
value: DataCell,
onChange?: (value: string) => Promise<boolean>,
type?: string
comboboxType?: string
}

export interface Row {
Expand Down Expand Up @@ -164,6 +165,7 @@ export default function TableComponent({ headers, rows, children, setRows, optio
cell.onChange!(value)
handleSetEditable("", "")
}}
type={cell.comboboxType}
/>
: <div className="w-full flex gap-2 items-center">
<Input
Expand Down
6 changes: 4 additions & 2 deletions app/settings/users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export default function Users() {
}, {
value: role,
onChange: username === "default" ? undefined : (value: string) => handleSetRole(username, value, role),
type: "combobox"
type: "combobox",
comboboxType: "Role",
}],
checked: false,
})))
Expand Down Expand Up @@ -90,7 +91,8 @@ export default function Users() {
}, {
value: role,
onChange: (value: string) => handleSetRole(username, value, role),
type: "combobox"
type: "combobox",
comboboxType: "Role"
}],
checked: false,
}] as Row[])
Expand Down
20 changes: 8 additions & 12 deletions e2e/logic/POM/settingsUsersPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ export default class SettingsUsersPage extends BasePage {
return this.page.locator("//div[@role='dialog']//button[span[text()='Select Role']]")
}

private get selectRoleBtn(): Locator {
return this.page.locator("//button[span[text()='Select Role']]")
private get userSelectRoleEditBtn(): (selectedUser: string) => Locator {
return (selectedUser: string) => this.page.locator(`//tbody/tr[@data-id='${selectedUser}']/td[3]/div/div/button`)
}

private get userSelectRoleBtn(): (selectedUser: string) => Locator {
return (selectedUser: string) => this.page.locator(`//tbody/tr[@data-id='${selectedUser}']/td[3]/button`)
}

private get selectUserRole(): (role: string) => Locator {
Expand Down Expand Up @@ -93,20 +97,12 @@ export default class SettingsUsersPage extends BasePage {

async modifyUserRole(selectedUser: string, role: string): Promise<void> {
await this.page.waitForLoadState('networkidle');
await this.userCheckboxBtn(selectedUser).click();
await this.selectRoleBtn.click();
await this.userSelectRoleEditBtn(selectedUser).click();
await this.userSelectRoleBtn(selectedUser).click();
await this.selectUserRole(role).click();
await waitForTimeOut(this.page, 1500)
}

async modifyTwoUsersRoles(selectedUser1: string, selectedUser2: string, role: string): Promise<void> {
await this.page.waitForLoadState('networkidle');
await this.userCheckboxBtn(selectedUser1).click();
await this.userCheckboxBtn(selectedUser2).click();
await this.selectRoleBtn.click();
await this.selectUserRole(role).click()
}

async deleteTwoUsers(selectedUser1: string, selectedUser2: string): Promise<void> {
await this.page.waitForLoadState('networkidle');
await this.userCheckboxBtn(selectedUser1).click()
Expand Down
5 changes: 3 additions & 2 deletions e2e/tests/settingsUsers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test.describe('Settings Tests', () => {

})

test("@admin Add two users -> change their roles via checkbox -> Validate that the users roles have been changed", async () => {
test("@admin Add two users -> change their roles -> Validate that the users roles have been changed", async () => {
// Adding two user
const settingsUsersPage = await browser.createNewPage(SettingsUsersPage, urls.settingsUrl)
await settingsUsersPage.navigateToUserTab();
Expand All @@ -67,7 +67,8 @@ test.describe('Settings Tests', () => {

// modify users roles
const userRole = user.ReadOnly;
await settingsUsersPage.modifyTwoUsersRoles(username1, username2, userRole)
await settingsUsersPage.modifyUserRole(username1, userRole)
await settingsUsersPage.modifyUserRole(username2, userRole)
await settingsUsersPage.refreshPage()
await settingsUsersPage.navigateToUserTab()
const userName1Role = await settingsUsersPage.getUserRole(username1)
Expand Down

0 comments on commit fca6cb1

Please sign in to comment.