Files
threshold-ui/ui/admin/tests/e2e/pages/orgs.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 OrgsPage extends BaseResourcePage {
/**
* Creates a new organization
* @returns Name of the organization
*/
async createOrg() {
const orgName = 'Org ' + nanoid();
await this.page
.getByRole('navigation', { name: 'General' })
.getByRole('link', { name: 'Orgs' })
.click();
await this.page.getByRole('link', { name: 'New Org' }).click();
await this.page.getByLabel('Name').fill(orgName);
await this.page.getByLabel('Description').fill('This is an automated test');
await this.page.getByRole('button', { name: 'Save' }).click();
await this.dismissSuccessAlert();
await expect(
this.page
.getByRole('navigation', { name: 'breadcrumbs' })
.getByText(orgName),
).toBeVisible();
return orgName;
}
/**
* Attaches a Storage Policy to a scope. Assumes you have selected the desired scope.
* @param {string} policyName name of the Policy to be attached to the scope
*/
async attachStoragePolicy(policyName) {
await this.page
.getByRole('link', { name: new RegExp('/*Settings'), exact: true })
.click();
await this.page.getByText('Add Storage Policy').click();
await this.page
.getByLabel('Storage Policy')
.selectOption({ label: policyName });
await this.page.getByRole('button', { name: 'Save' }).click();
await this.dismissSuccessAlert();
await expect(
this.page.getByRole('listitem').getByText(policyName),
).toBeVisible();
}
}