test(e2e): Add additional assertions to UI tests (#2634)
* test(e2e): Address deprecation * test(e2e): Add additional connection assertions on tests * CR: Fix flake when waiting for sessions If no sessions are available and the page needs to reload, we should wait to ensure that the page has loaded before checking what the state of the sessions are * CR: Address flake in connect methods Noticed an issue where a session recording was not playable. The theory is that the session didn't last long enough before it was cancelled. This adds a 2 second wait after establishing a connection before continuing. * CR: Use authenticated state by default * CR: Update dynamic host catalog assertion * CR: Simplify host set checks - Use .all() when looping - Add check to see if we need to reload the page or not * CR: Be more specific with locator Ran into a conflict with the Static/Dynamic host catalog type and the Static/Dynamic credential type. * CR: Update connection methods to be more resilient Rather than using a hardcoded sleep, we will now run a command on the target and wait for a specific string to return before continuing. * CR
This commit is contained in:
1 parent
faf4ecfac6
commit
1cbf3b227e
29 files changed
+632
-169
No files matched your search
@@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import { test, authenticatedState } from '../../global-setup.js';
|
||||
import { test } from '../../global-setup.js';
|
||||
import { expect } from '@playwright/test';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
|
||||
@@ -11,10 +11,9 @@ import * as boundaryCli from '../../helpers/boundary-cli';
|
||||
import { AliasesPage } from '../pages/aliases.js';
|
||||
import { OrgsPage } from '../pages/orgs.js';
|
||||
import { ProjectsPage } from '../pages/projects.js';
|
||||
import { SessionsPage } from '../pages/sessions.js';
|
||||
import { TargetsPage } from '../pages/targets.js';
|
||||
|
||||
test.use({ storageState: authenticatedState });
|
||||
|
||||
test.beforeAll(async () => {
|
||||
await boundaryCli.checkBoundaryCli();
|
||||
});
|
||||
@@ -28,10 +27,13 @@ test.describe('Aliases', async () => {
|
||||
adminPassword,
|
||||
targetAddress,
|
||||
targetPort,
|
||||
sshUser,
|
||||
sshKeyPath,
|
||||
}) => {
|
||||
await page.goto('/');
|
||||
let orgName;
|
||||
let alias;
|
||||
let connect;
|
||||
const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz', 10);
|
||||
try {
|
||||
const orgsPage = new OrgsPage(page);
|
||||
@@ -39,7 +41,10 @@ test.describe('Aliases', async () => {
|
||||
const projectsPage = new ProjectsPage(page);
|
||||
await projectsPage.createProject();
|
||||
const targetsPage = new TargetsPage(page);
|
||||
await targetsPage.createTargetWithAddress(targetAddress, targetPort);
|
||||
const targetName = await targetsPage.createTargetWithAddress(
|
||||
targetAddress,
|
||||
targetPort,
|
||||
);
|
||||
|
||||
// Create alias for target
|
||||
const aliasName = 'Alias ' + nanoid();
|
||||
@@ -61,9 +66,16 @@ test.describe('Aliases', async () => {
|
||||
adminLoginName,
|
||||
adminPassword,
|
||||
);
|
||||
await boundaryCli.authorizeSessionByAlias(alias);
|
||||
connect = await boundaryCli.connectToAlias(alias, sshUser, sshKeyPath);
|
||||
const sessionsPage = new SessionsPage(page);
|
||||
await sessionsPage.waitForSessionToBeVisible(targetName);
|
||||
|
||||
// Clear destination from alias
|
||||
await page
|
||||
.getByRole('navigation', { name: 'Resources' })
|
||||
.getByRole('link', { name: 'Targets' })
|
||||
.click();
|
||||
await page.getByRole('link', { name: targetName }).click();
|
||||
await page.getByRole('link', { name: alias }).click();
|
||||
// Note: On the Target details page, there is a section with the header
|
||||
// "Aliases". The extra check here is to ensure that we are on the Alias
|
||||
@@ -79,6 +91,9 @@ test.describe('Aliases', async () => {
|
||||
).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Dismiss' }).click();
|
||||
} finally {
|
||||
if (connect) {
|
||||
connect.kill('SIGTERM');
|
||||
}
|
||||
await boundaryCli.authenticateBoundary(
|
||||
baseURL,
|
||||
adminAuthMethodId,
|
||||
@@ -105,10 +120,13 @@ test.describe('Aliases', async () => {
|
||||
adminPassword,
|
||||
targetAddress,
|
||||
targetPort,
|
||||
sshUser,
|
||||
sshKeyPath,
|
||||
}) => {
|
||||
await page.goto('/');
|
||||
let orgName;
|
||||
let alias;
|
||||
let connect;
|
||||
const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz', 10);
|
||||
try {
|
||||
const orgsPage = new OrgsPage(page);
|
||||
@@ -123,15 +141,20 @@ test.describe('Aliases', async () => {
|
||||
await projectsPage.createProject();
|
||||
alias = 'example.alias.' + nanoid();
|
||||
const targetsPage = new TargetsPage(page);
|
||||
await targetsPage.createTargetWithAddressAndAlias(
|
||||
const targetName = await targetsPage.createTargetWithAddressAndAlias(
|
||||
targetAddress,
|
||||
targetPort,
|
||||
alias,
|
||||
);
|
||||
|
||||
// Connect to target using alias
|
||||
await boundaryCli.authorizeSessionByAlias(alias);
|
||||
connect = await boundaryCli.connectToAlias(alias, sshUser, sshKeyPath);
|
||||
const sessionsPage = new SessionsPage(page);
|
||||
await sessionsPage.waitForSessionToBeVisible(targetName);
|
||||
} finally {
|
||||
if (connect) {
|
||||
connect.kill('SIGTERM');
|
||||
}
|
||||
await boundaryCli.authenticateBoundary(
|
||||
baseURL,
|
||||
adminAuthMethodId,
|
||||
@@ -158,11 +181,14 @@ test.describe('Aliases', async () => {
|
||||
adminPassword,
|
||||
targetAddress,
|
||||
targetPort,
|
||||
sshUser,
|
||||
sshKeyPath,
|
||||
}) => {
|
||||
await page.goto('/');
|
||||
const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz', 10);
|
||||
let orgId;
|
||||
let alias;
|
||||
let connect;
|
||||
try {
|
||||
const orgsPage = new OrgsPage(page);
|
||||
const orgName = await orgsPage.createOrg();
|
||||
@@ -194,8 +220,18 @@ test.describe('Aliases', async () => {
|
||||
alias = 'example.alias.' + nanoid();
|
||||
const aliasesPage = new AliasesPage(page);
|
||||
await aliasesPage.createAliasForTarget(alias, targetId);
|
||||
await boundaryCli.authorizeSessionByAlias(alias);
|
||||
await page.getByRole('link', { name: 'Orgs', exact: true }).click();
|
||||
await expect(page.getByRole('heading', { name: 'Orgs' })).toBeVisible();
|
||||
await page.getByRole('link', { name: orgName }).click();
|
||||
await page.getByRole('link', { name: projectName }).click();
|
||||
|
||||
connect = await boundaryCli.connectToAlias(alias, sshUser, sshKeyPath);
|
||||
const sessionsPage = new SessionsPage(page);
|
||||
await sessionsPage.waitForSessionToBeVisible(targetName);
|
||||
} finally {
|
||||
if (connect) {
|
||||
connect.kill('SIGTERM');
|
||||
}
|
||||
await boundaryCli.authenticateBoundary(
|
||||
baseURL,
|
||||
adminAuthMethodId,
|
||||
|
||||
Reference in new issue
Block a user