Skip to content

Commit 1bafbe1

Browse files
authored
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
1 parent a26074a commit 1bafbe1

File tree

8 files changed

+65
-53
lines changed

8 files changed

+65
-53
lines changed

e2e-tests/admin/pages/aliases.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,9 @@ export class AliasesPage extends BaseResourcePage {
1515
* @param {string} targetId ID of the target
1616
* @returns Name of the alias
1717
*/
18-
async createAliasForTarget(alias, targetId, orgName) {
18+
async createAliasForTarget(alias, targetId) {
1919
const aliasName = 'Alias ' + nanoid();
2020

21-
await this.page
22-
.getByRole('link', { name: `Back to ${orgName}`, exact: true })
23-
.click();
24-
await this.page.getByRole('link', { name: 'Back to Global' }).click();
25-
await this.page.getByRole('link', { name: 'Aliases' }).click();
26-
await expect(
27-
this.page
28-
.getByRole('navigation', { name: 'breadcrumbs' })
29-
.getByText('Aliases'),
30-
).toBeVisible();
31-
3221
const newButtonIsVisible = await this.page
3322
.getByRole('link', { name: 'Create a new alias', exact: true })
3423
.isVisible();

e2e-tests/admin/tests/alias-ent.spec.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,27 @@ test.describe('Aliases (Enterprise)', () => {
268268
targetName,
269269
);
270270

271+
await page
272+
.getByRole('link', { name: `Back to ${orgName}`, exact: true })
273+
.click();
274+
await page.getByRole('link', { name: 'Back to Global' }).click();
275+
await page.getByRole('link', { name: 'Aliases' }).click();
276+
await expect(
277+
page
278+
.getByRole('navigation', { name: 'breadcrumbs' })
279+
.getByText('Aliases'),
280+
).toBeVisible();
271281
alias = 'example.alias.' + nanoid();
272282
const aliasesPage = new AliasesPage(page);
273-
await aliasesPage.createAliasForTarget(alias, targetId, orgName);
274-
connect = await boundaryCli.connectSshToAlias(alias);
283+
await aliasesPage.createAliasForTarget(alias, targetId);
275284
await page
276285
.getByRole('navigation', { name: 'Application local navigation' })
277286
.getByRole('link', { name: 'Orgs' })
278287
.click();
279288
await page.getByRole('link', { name: orgName }).click();
280289
await page.getByRole('link', { name: projectName }).click();
290+
291+
connect = await boundaryCli.connectSshToAlias(alias);
281292
const sessionsPage = new SessionsPage(page);
282293
await sessionsPage.waitForSessionToBeVisible(targetName);
283294
} finally {

e2e-tests/admin/tests/alias.spec.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,19 @@ test.describe('Aliases', () => {
228228
targetName,
229229
);
230230

231+
await page
232+
.getByRole('link', { name: `Back to ${orgName}`, exact: true })
233+
.click();
234+
await page.getByRole('link', { name: 'Back to Global' }).click();
235+
await page.getByRole('link', { name: 'Aliases' }).click();
236+
await expect(
237+
page
238+
.getByRole('navigation', { name: 'breadcrumbs' })
239+
.getByText('Aliases'),
240+
).toBeVisible();
231241
alias = 'example.alias.' + nanoid();
232242
const aliasesPage = new AliasesPage(page);
233-
await aliasesPage.createAliasForTarget(alias, targetId, orgName);
243+
await aliasesPage.createAliasForTarget(alias, targetId);
234244
await page.getByRole('link', { name: 'Orgs', exact: true }).click();
235245
await expect(page.getByRole('heading', { name: 'Orgs' })).toBeVisible();
236246
await page.getByRole('link', { name: orgName }).click();

e2e-tests/admin/tests/auth-method-oidc-vault.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ test(
8484
// Set auth method as primary
8585
await page.getByText('Manage', { exact: true }).click();
8686
await page.getByRole('button', { name: 'Make Primary' }).click();
87-
await page.getByRole('button', { name: 'OK' }).click();
87+
await page.getByRole('button', { name: 'OK', exact: true }).click();
8888
await expect(
8989
page.getByRole('alert').getByText('Success', { exact: true }),
9090
).toBeVisible();

e2e-tests/admin/tests/change-password.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ test(
7373
await expect(
7474
page.getByRole('alert').getByText('Success', { exact: true }),
7575
).toBeVisible();
76+
await expect(
77+
page.getByRole('heading', { name: 'Projects' }),
78+
).toBeVisible();
7679

7780
// Confirm user cannot log in with old password
7881
await loginPage.logout(username);

e2e-tests/admin/tests/delete-resources-ent.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ test(
6262
await boundaryCli.makeAuthMethodPrimary(orgId, authMethodId);
6363
let passwordAccountId =
6464
await boundaryCli.createPasswordAccount(authMethodId);
65-
let projectScopeRoleId = await boundaryCli.createRole(projectId);
66-
let orgScopeRoleId = await boundaryCli.createRole(orgId);
67-
let globalScopeRoleId = await boundaryCli.createRole('global');
65+
let projectScopeRoleId = await boundaryCli.createRole(projectId, {});
66+
let orgScopeRoleId = await boundaryCli.createRole(orgId, {});
67+
let globalScopeRoleId = await boundaryCli.createRole('global', {});
6868
let groupId = await boundaryCli.createGroup(orgId);
6969
let userId = await boundaryCli.createUser(orgId);
7070
let staticHostCatalogId =
@@ -155,7 +155,7 @@ test(
155155
await baseResourcePage.deleteResource(page);
156156

157157
// Delete project and org
158-
await page.goto(`/scopes/${projectId}`);
158+
await page.goto(`/scopes/${projectId}/edit`);
159159
await baseResourcePage.deleteResource(page);
160160
await page.goto(`/scopes/${orgId}/edit`);
161161
await baseResourcePage.deleteResource(page);

e2e-tests/admin/tests/delete-resources.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ test(
6161
await boundaryCli.makeAuthMethodPrimary(orgId, authMethodId);
6262
let passwordAccountId =
6363
await boundaryCli.createPasswordAccount(authMethodId);
64-
let projectScopeRoleId = await boundaryCli.createRole(projectId);
65-
let orgScopeRoleId = await boundaryCli.createRole(orgId);
66-
let globalScopeRoleId = await boundaryCli.createRole('global');
64+
let projectScopeRoleId = await boundaryCli.createRole(projectId, {});
65+
let orgScopeRoleId = await boundaryCli.createRole(orgId, {});
66+
let globalScopeRoleId = await boundaryCli.createRole('global', {});
6767
let groupId = await boundaryCli.createGroup(orgId);
6868
let userId = await boundaryCli.createUser(orgId);
6969
let staticHostCatalogId =
@@ -177,7 +177,7 @@ test(
177177
await workersPage.deleteResource(page);
178178

179179
// Delete project
180-
await page.goto(`/scopes/${projectId}`);
180+
await page.goto(`/scopes/${projectId}/edit`);
181181
await baseResourcePage.deleteResource(page);
182182

183183
// Delete org

e2e-tests/admin/tests/scope.spec.js

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,35 @@ import { OrgsPage } from '../pages/orgs.js';
1010
import * as boundaryHttp from '../../helpers/boundary-http.js';
1111

1212
test(
13-
'Session picker',
14-
{ tag: ['@ce', '@ent', '@aws', '@docker'] },
15-
async ({ page, request }) => {
16-
let org;
17-
try {
18-
//Create an org and project attached to the org
19-
org = await boundaryHttp.createOrg(request);
20-
const project = await boundaryHttp.createProject(request, org.id);
13+
'Session picker',
14+
{ tag: ['@ce', '@ent', '@aws', '@docker'] },
15+
async ({ page, request }) => {
16+
let org;
17+
try {
18+
// Create an org and project attached to the org
19+
org = await boundaryHttp.createOrg(request);
20+
const project = await boundaryHttp.createProject(request, org.id);
2121

22-
//Choose the org from the scope picker
23-
await page.goto('/');
24-
const orgsPage = new OrgsPage(page);
25-
await orgsPage.chooseScopeFromDropdown('Global', org.name);
22+
// Choose the org from the scope picker
23+
await page.goto('/');
24+
await expect(page.getByRole('heading', { name: 'Orgs' })).toBeVisible();
25+
const orgsPage = new OrgsPage(page);
26+
await orgsPage.chooseScopeFromDropdown('Global', org.name);
2627

27-
//Expect the project to be displayed on the projects page
28-
await expect(
29-
page.getByRole('link', { name: project.name })
30-
).toBeVisible()
28+
// Expect the project to be displayed on the projects page
29+
await expect(
30+
page.getByRole('link', { name: project.name }),
31+
).toBeVisible();
3132

32-
//Switch back to global scope
33-
await orgsPage.chooseScopeFromDropdown(org.name, 'Global');
33+
// Switch back to global scope
34+
await orgsPage.chooseScopeFromDropdown(org.name, 'Global');
3435

35-
//Expect to be back on the orgs page
36-
await expect(
37-
page.getByRole('heading', { name: 'Orgs' })
38-
).toBeVisible()
39-
} finally {
40-
if (org.id) {
41-
org = await request.delete(`/v1/scopes/${org.id}`);
42-
}
43-
}
44-
},
45-
);
36+
// Expect to be back on the orgs page
37+
await expect(page.getByRole('heading', { name: 'Orgs' })).toBeVisible();
38+
} finally {
39+
if (org.id) {
40+
org = await request.delete(`/v1/scopes/${org.id}`);
41+
}
42+
}
43+
},
44+
);

0 commit comments

Comments
 (0)