]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/e2e/ui/user-mgmt.po.ts
d/control: depend on python3-yaml for ceph-mgr
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / e2e / ui / user-mgmt.po.ts
CommitLineData
9f95a23c
TL
1import { by, element } from 'protractor';
2import { PageHelper } from '../page-helper.po';
3
4export class UserMgmtPageHelper extends PageHelper {
5 pages = {
6 index: '/#/user-management/users',
7 create: '/#/user-management/users/create'
8 };
9
10 async create(username: string, password: string, name: string, email: string): Promise<void> {
11 await this.navigateTo('create');
12
13 // fill in fields
14 await element(by.id('username')).sendKeys(username);
15 await element(by.id('password')).sendKeys(password);
16 await element(by.id('confirmpassword')).sendKeys(password);
17 await element(by.id('name')).sendKeys(name);
18 await element(by.id('email')).sendKeys(email);
19
20 // Click the create button and wait for user to be made
21 const createButton = element(by.cssContainingText('button', 'Create User'));
22 await createButton.click();
23 await this.waitPresence(this.getFirstTableCellWithText(username));
24 }
25
26 async edit(username: string, password: string, name: string, email: string): Promise<void> {
27 await this.navigateTo();
28
29 await this.getFirstTableCellWithText(username).click(); // select user from table
30 await element(by.cssContainingText('button', 'Edit')).click(); // click button to move to edit page
31
32 // fill in fields with new values
33 await element(by.id('password')).clear();
34 await element(by.id('password')).sendKeys(password);
35 await element(by.id('confirmpassword')).clear();
36 await element(by.id('confirmpassword')).sendKeys(password);
37 await element(by.id('name')).clear();
38 await element(by.id('name')).sendKeys(name);
39 await element(by.id('email')).clear();
40 await element(by.id('email')).sendKeys(email);
41
42 // Click the edit button and check new values are present in table
43 const editButton = element(by.cssContainingText('button', 'Edit User'));
44 await editButton.click();
45 await this.waitPresence(this.getFirstTableCellWithText(email));
46 await this.waitPresence(this.getFirstTableCellWithText(name));
47 }
48}