Files
threshold-ui/e2e-tests/admin/pages/aliases.js
T
Michael Li 1bafbe1ad2 test(e2e): Address some Admin UI test flakiness (#2934)
* fix(e2e): Address flakiness during screen navigation

* fix(e2e): Fix function call

* fix(e2e): Address flakiness in connection

* fix(e2e): Make locator explicit to avoid conflict when an ID has `ok`

* fix(e2e): Fix URL now that project page defaults to showing targets
2025-09-03 11:28:33 -04:00

50 lines
1.4 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) {
const aliasName = 'Alias ' + nanoid();
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;
}
}