]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/cypress/integration/rgw/users.po.ts
import 15.2.5
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / cypress / integration / rgw / users.po.ts
CommitLineData
e306af50
TL
1import { PageHelper } from '../page-helper.po';
2
3const pages = {
4 index: { url: '#/rgw/user', id: 'cd-rgw-user-list' },
5 create: { url: '#/rgw/user/create', id: 'cd-rgw-user-form' }
6};
7
8export class UsersPageHelper extends PageHelper {
9 pages = pages;
10
11 @PageHelper.restrictTo(pages.create.url)
12 create(username: string, fullname: string, email: string, maxbuckets: string) {
13 // Enter in username
14 cy.get('#uid').type(username);
15
16 // Enter in full name
17 cy.get('#display_name').click().type(fullname);
18
19 // Enter in email
20 cy.get('#email').click().type(email);
21
22 // Enter max buckets
23 this.selectOption('max_buckets_mode', 'Custom');
f6b5b4d7 24 cy.get('#max_buckets').should('exist').should('have.value', '1000');
e306af50
TL
25 cy.get('#max_buckets').click().clear().type(maxbuckets);
26
27 // Click the create button and wait for user to be made
28 cy.contains('button', 'Create User').click();
29 this.getFirstTableCell(username).should('exist');
30 }
31
32 @PageHelper.restrictTo(pages.index.url)
33 edit(name: string, new_fullname: string, new_email: string, new_maxbuckets: string) {
34 this.navigateEdit(name);
35
36 // Change the full name field
37 cy.get('#display_name').click().clear().type(new_fullname);
38
39 // Change the email field
40 cy.get('#email').click().clear().type(new_email);
41
42 // Change the max buckets field
43 this.selectOption('max_buckets_mode', 'Custom');
44 cy.get('#max_buckets').click().clear().type(new_maxbuckets);
45
46 cy.contains('button', 'Edit User').click();
47
48 // Click the user and check its details table for updated content
49 this.getExpandCollapseElement(name).click();
50 cy.get('.active.tab-pane')
51 .should('contain.text', new_fullname)
52 .and('contain.text', new_email)
53 .and('contain.text', new_maxbuckets);
54 }
55
56 invalidCreate() {
57 const uname = '000invalid_create_user';
58 // creating this user in order to check that you can't give two users the same name
59 this.navigateTo('create');
60 this.create(uname, 'xxx', 'xxx@xxx', '1');
61
62 this.navigateTo('create');
63
64 // Username
65 cy.get('#uid')
66 // No username had been entered. Field should be invalid
67 .should('have.class', 'ng-invalid')
68 // Try to give user already taken name. Should make field invalid.
69 .type(uname)
70 .blur()
71 .should('have.class', 'ng-invalid');
72 cy.contains('#uid + .invalid-feedback', 'The chosen user ID is already in use.');
73
74 // check that username field is marked invalid if username has been cleared off
75 cy.get('#uid').clear().blur().should('have.class', 'ng-invalid');
76 cy.contains('#uid + .invalid-feedback', 'This field is required.');
77
78 // Full name
79 cy.get('#display_name')
80 // No display name has been given so field should be invalid
81 .should('have.class', 'ng-invalid')
82 // display name field should also be marked invalid if given input then emptied
83 .type('a')
84 .clear()
85 .blur()
86 .should('have.class', 'ng-invalid');
87 cy.contains('#display_name + .invalid-feedback', 'This field is required.');
88
89 // put invalid email to make field invalid
90 cy.get('#email').type('a').blur().should('have.class', 'ng-invalid');
91 cy.contains('#email + .invalid-feedback', 'This is not a valid email address.');
92
93 // put negative max buckets to make field invalid
94 this.expectSelectOption('max_buckets_mode', 'Custom');
95 cy.get('#max_buckets').clear().type('-5').blur().should('have.class', 'ng-invalid');
96 cy.contains('#max_buckets + .invalid-feedback', 'The entered value must be >= 1.');
97
98 this.navigateTo();
99 this.delete(uname);
100 }
101
102 invalidEdit() {
103 const uname = '000invalid_edit_user';
104 // creating this user to edit for the test
105 this.navigateTo('create');
f6b5b4d7 106 this.create(uname, 'xxx', 'xxx@xxx', '50');
e306af50
TL
107
108 this.navigateEdit(name);
109
110 // put invalid email to make field invalid
111 cy.get('#email')
112 .clear()
113 .type('a')
114 .blur()
115 .should('not.have.class', 'ng-pending')
116 .should('have.class', 'ng-invalid');
117 cy.contains('#email + .invalid-feedback', 'This is not a valid email address.');
118
119 // empty the display name field making it invalid
120 cy.get('#display_name').clear().blur().should('have.class', 'ng-invalid');
121 cy.contains('#display_name + .invalid-feedback', 'This field is required.');
122
123 // put negative max buckets to make field invalid
f6b5b4d7
TL
124 this.selectOption('max_buckets_mode', 'Disabled');
125 cy.get('#max_buckets').should('not.exist');
126 this.selectOption('max_buckets_mode', 'Custom');
127 cy.get('#max_buckets').should('exist').should('have.value', '50');
e306af50
TL
128 cy.get('#max_buckets').clear().type('-5').blur().should('have.class', 'ng-invalid');
129 cy.contains('#max_buckets + .invalid-feedback', 'The entered value must be >= 1.');
130
131 this.navigateTo();
132 this.delete(uname);
133 }
134}