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