Files
threshold-ui/e2e-tests/admin/pages/aliases.js
T
Tony b99fce7d55 refactor: 💡 e2e admin tests - update locators (#2931)
* refactor: 💡 e2e tests - update locators

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-17174

* refactor: 💡 addressing comments

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-17174

* refactor: 💡 update test for session-recording-aws-ent

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-17174
2025-07-17 15:48:20 -04:00

61 lines
1.8 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 AliasesPage extends BaseResourcePage {
/**
* Creates an alias
* @param {string} alias Value of the alias
* @param {string} targetId ID of the target
* @returns Name of the alias
*/
async createAliasForTarget(alias, targetId, orgName) {
const aliasName = 'Alias ' + nanoid();
await this.page
.getByRole('link', { name: `Back to ${orgName}`, exact: true })
.click();
await this.page.getByRole('link', { name: 'Back to Global' }).click();
await this.page.getByRole('link', { name: 'Aliases' }).click();
await expect(
this.page
.getByRole('navigation', { name: 'breadcrumbs' })
.getByText('Aliases'),
).toBeVisible();
const newButtonIsVisible = await this.page
.getByRole('link', { name: 'Create a new alias', exact: true })
.isVisible();
if (newButtonIsVisible) {
await this.page
.getByRole('link', { name: 'Create a new alias', exact: true })
.click();
} else {
await this.page
.getByRole('link', { name: 'New Alias', exact: true })
.click();
}
await this.page.getByLabel('Name').fill(aliasName);
await this.page.getByLabel('Description').fill('This is an automated test');
await this.page.getByLabel('Alias Value').fill(alias);
await this.page.getByLabel('Target ID').fill(targetId);
await this.page.getByRole('button', { name: 'Save' }).click();
await this.dismissSuccessAlert();
await expect(
this.page
.getByRole('navigation', { name: 'breadcrumbs' })
.getByText(aliasName),
).toBeVisible();
return aliasName;
}
}