Files
threshold-ui/ui/admin/tests/e2e/pages/groups.mjs
T
Michael Li 007f5d8b46 refact(e2e): Split up boundary-cli helper methods (#2430)
* refact(e2e): Split up boundary-cli helper methods

* CR: Use ESM import

* CR: Move authenticated state to a non-shared file

* CR: Use mjs

* CR: Modify playwright config to .mjs
2024-08-19 16:00:16 -04:00

55 lines
1.7 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { expect } from '@playwright/test';
import { nanoid } from 'nanoid';
import { BaseResourcePage } from './base-resource.mjs';
export class GroupsPage extends BaseResourcePage {
/**
* Creates a new group. Assumes you have selected the desired scope.
* @returns Name of the group
*/
async createGroup() {
const groupName = 'Group ' + nanoid();
await this.page
.getByRole('navigation', { name: 'IAM' })
.getByRole('link', { name: 'Groups' })
.click();
await this.page.getByRole('link', { name: 'New', exact: true }).click();
await this.page.getByLabel('Name').fill(groupName);
await this.page.getByRole('button', { name: 'Save' }).click();
await this.dismissSuccessAlert();
await expect(
this.page
.getByRole('navigation', { name: 'breadcrumbs' })
.getByText(groupName),
).toBeVisible();
return groupName;
}
/**
* Adds a user to the group. Assumes you have selected the desired group.
* @param {string} userName Name of the user that will be added to the group
*/
async addMemberToGroup(userName) {
await this.page.getByRole('link', { name: 'Members', exact: true }).click();
await this.page
.getByRole('article')
.getByRole('link', { name: 'Add Members', exact: true })
.click();
await this.page.getByRole('checkbox', { name: userName }).click();
await this.page
.getByRole('button', { name: 'Add Members', exact: true })
.click();
await this.dismissSuccessAlert();
await expect(
this.page.getByRole('table').getByText(userName),
).toBeVisible();
}
}