* feat: 🎸 scope picker component (#2646) * feat: 🎸 scope picker component --------- Co-authored-by: lisbet-alvarez <lisbet-alvarez@users.noreply.github.com> Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> * refactor: 💡 use hds side nav w/ hds frame instead of rose (#2688) * refactor: 💡 use hds side nav w/ hds frame instead of rose * test: 💍 clean up selectors * fix: 🐛 specificity of style override * refactor: 💡 use hds side nav list instead of target and portal * refactor: 💡 revert to using portal component & update scss * docs: ✏️ update comment * refactor: 💡 use custom class names for containers * refactor: 💡 pr feedback (use @hasSidebar arg) * refactor: 💡 fix onboarding page & fix settings title * refactor: 💡 remove unneeded template file (pr feedback) * test: 💍 fix tests due to merge conflicts * test: 💍 add missing test selector due to merge conflict * test: 💍 fix more broken tests due to merge conflicts * chore: 🤖 update yarn.lock & update hds version to 4.18.1 * chore: 🤖 fix e2e test cases due to side nav refactor (#2751) * chore: 🤖 fix e2e test cases due to side nav refactor * test: 💍 fix e2e test for desktop --------- Co-authored-by: lisbet-alvarez <lisbet-alvarez@users.noreply.github.com> Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
71 lines
2.3 KiB
JavaScript
71 lines
2.3 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.js';
|
|
|
|
export class RolesPage extends BaseResourcePage {
|
|
/**
|
|
* Creates a new role. Assumes you have selected the desired scope.
|
|
*/
|
|
async createRole() {
|
|
const roleName = 'Role ' + nanoid();
|
|
|
|
await this.page
|
|
.getByRole('navigation', { name: 'Application local navigation' })
|
|
.getByRole('link', { name: 'Roles' })
|
|
.click();
|
|
await this.page.getByRole('link', { name: 'New Role' }).click();
|
|
await this.page.getByLabel('Name').fill(roleName);
|
|
await this.page.getByRole('button', { name: 'Save' }).click();
|
|
await this.dismissSuccessAlert();
|
|
await expect(
|
|
this.page
|
|
.getByRole('navigation', { name: 'breadcrumbs' })
|
|
.getByText(roleName),
|
|
).toBeVisible();
|
|
|
|
return roleName;
|
|
}
|
|
|
|
/**
|
|
* Adds a principal to a role. Assumes you have selected the desired role.
|
|
* @param {string} principalName Name of the principal that will be added to the role
|
|
*/
|
|
async addPrincipalToRole(principalName) {
|
|
await this.page
|
|
.getByRole('link', { name: 'Principals', exact: true })
|
|
.click();
|
|
await this.page
|
|
.getByRole('link', { name: 'Add Principals', exact: true })
|
|
.click();
|
|
await this.page.getByRole('checkbox', { name: principalName }).click();
|
|
await this.page
|
|
.getByRole('button', { name: 'Add Principals', exact: true })
|
|
.click();
|
|
await this.dismissSuccessAlert();
|
|
await expect(
|
|
this.page.getByRole('table').getByRole('link', { name: principalName }),
|
|
).toBeVisible();
|
|
}
|
|
|
|
/**
|
|
* Adds a grant to the role. Assumes you have selected the desired role.
|
|
* @param {string} grants grants that will be given to the role
|
|
*/
|
|
async addGrantsToRole(grants) {
|
|
await this.page.getByRole('link', { name: 'Grants', exact: true }).click();
|
|
await this.page.getByRole('textbox', { name: 'New Grant' }).fill(grants);
|
|
await this.page.getByRole('button', { name: 'Add', exact: true }).click();
|
|
await this.page.getByRole('button', { name: 'Save', exact: true }).click();
|
|
await this.dismissSuccessAlert();
|
|
await expect(
|
|
this.page.getByRole('textbox', { name: 'Grant', exact: true }),
|
|
).toHaveValue(grants);
|
|
}
|
|
}
|