-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathusers.js
More file actions
59 lines (53 loc) · 1.66 KB
/
Copy pathusers.js
File metadata and controls
59 lines (53 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* 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 UsersPage extends BaseResourcePage {
/**
* Creates a new user.
* @returns Name of the user
*/
async createUser() {
const userName = 'User ' + nanoid();
await this.page
.getByRole('navigation', { name: 'Application local navigation' })
.getByRole('link', { name: 'Users' })
.click();
await this.page.getByRole('link', { name: 'New', exact: true }).click();
await this.page.getByLabel('Name').fill(userName);
await this.page.getByRole('button', { name: 'Save' }).click();
await this.dismissSuccessAlert();
await expect(
this.page
.getByRole('navigation', { name: 'breadcrumbs' })
.getByText(userName),
).toBeVisible();
return userName;
}
/**
* Adds an account to a user
* Assumes you have selected the desired user.
* Assumes you have created new account.
* @param {string} loginName Login name of the account
*/
async addAccountToUser(loginName) {
await this.page
.getByRole('link', { name: 'Accounts', exact: true })
.click();
await this.page
.getByRole('link', { name: 'Add Accounts', exact: true })
.click();
await this.page
.getByRole('row')
.filter({ has: this.page.getByRole('cell', { name: loginName }) })
.getByRole('checkbox')
.click({ force: true });
await this.page
.getByRole('button', { name: 'Add Accounts', exact: true })
.click();
await this.dismissSuccessAlert();
}
}