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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
import { PageHelper } from '../page-helper.po';
const pages = {
index: { url: '#/rgw/user', id: 'cd-rgw-user-list' },
create: { url: '#/rgw/user/create', id: 'cd-rgw-user-form' }
};
export class UsersPageHelper extends PageHelper {
pages = pages;
@PageHelper.restrictTo(pages.create.url)
create(tenant: string, user_id: string, fullname: string, email: string, maxbuckets: string) {
// Enter in user_id
cy.get('#user_id').type(user_id);
// Show Tenanat
cy.get('#show_tenant').click({ force: true });
// Enter in tenant
cy.get('#tenant').type(tenant);
// Enter in full name
cy.get('#display_name').click().type(fullname);
// Enter in email
cy.get('#email').click().type(email);
// Enter max buckets
this.selectOption('max_buckets_mode', 'Custom');
cy.get('#max_buckets').should('exist').should('have.value', '1000');
cy.get('#max_buckets').click().clear().type(maxbuckets);
// Click the create button and wait for user to be made
cy.contains('button', 'Create User').click();
this.getFirstTableCell(tenant + '$' + user_id).should('exist');
}
@PageHelper.restrictTo(pages.index.url)
edit(name: string, new_fullname: string, new_email: string, new_maxbuckets: string) {
this.navigateEdit(name);
// Change the full name field
cy.get('#display_name').click().clear().type(new_fullname);
// Change the email field
cy.get('#email').click().clear().type(new_email);
// Change the max buckets field
this.selectOption('max_buckets_mode', 'Custom');
cy.get('#max_buckets').click().clear().type(new_maxbuckets);
cy.contains('button', 'Edit User').click();
// Click the user and check its details table for updated content
this.getExpandCollapseElement(name).click();
cy.get('.datatable-row-detail')
.should('contain.text', new_fullname)
.and('contain.text', new_email)
.and('contain.text', new_maxbuckets);
}
invalidCreate() {
const tenant = '000invalid_tenant';
const uname = '000invalid_create_user';
// creating this user in order to check that you can't give two users the same name
this.navigateTo('create');
this.create(tenant, uname, 'xxx', 'xxx@xxx', '1');
this.navigateTo('create');
// Username
cy.get('#user_id')
// No username had been entered. Field should be invalid
.should('have.class', 'ng-invalid')
// Try to give user already taken name. Should make field invalid.
.type(uname);
cy.get('#show_tenant').click({ force: true });
cy.get('#tenant').type(tenant).should('have.class', 'ng-invalid');
cy.contains('#tenant + .invalid-feedback', 'The chosen user ID exists in this tenant.');
// check that username field is marked invalid if username has been cleared off
cy.get('#user_id').clear().blur().should('have.class', 'ng-invalid');
cy.contains('#user_id + .invalid-feedback', 'This field is required.');
// Full name
cy.get('#display_name')
// No display name has been given so field should be invalid
.should('have.class', 'ng-invalid')
// display name field should also be marked invalid if given input then emptied
.type('a')
.clear()
.blur()
.should('have.class', 'ng-invalid');
cy.contains('#display_name + .invalid-feedback', 'This field is required.');
// put invalid email to make field invalid
cy.get('#email').type('a').blur().should('have.class', 'ng-invalid');
cy.contains('#email + .invalid-feedback', 'This is not a valid email address.');
// put negative max buckets to make field invalid
this.expectSelectOption('max_buckets_mode', 'Custom');
cy.get('#max_buckets').clear().type('-5').blur().should('have.class', 'ng-invalid');
cy.contains('#max_buckets + .invalid-feedback', 'The entered value must be >= 1.');
this.navigateTo();
this.delete(tenant + '$' + uname);
}
invalidEdit() {
const tenant = '000invalid_tenant';
const uname = '000invalid_edit_user';
// creating this user to edit for the test
this.navigateTo('create');
this.create(tenant, uname, 'xxx', 'xxx@xxx', '50');
const name = tenant + '$' + uname;
this.navigateEdit(name);
// put invalid email to make field invalid
cy.get('#email')
.clear()
.type('a')
.blur()
.should('not.have.class', 'ng-pending')
.should('have.class', 'ng-invalid');
cy.contains('#email + .invalid-feedback', 'This is not a valid email address.');
// empty the display name field making it invalid
cy.get('#display_name').clear().blur().should('have.class', 'ng-invalid');
cy.contains('#display_name + .invalid-feedback', 'This field is required.');
// put negative max buckets to make field invalid
this.selectOption('max_buckets_mode', 'Disabled');
cy.get('#max_buckets').should('not.exist');
this.selectOption('max_buckets_mode', 'Custom');
cy.get('#max_buckets').should('exist').should('have.value', '50');
cy.get('#max_buckets').clear().type('-5').blur().should('have.class', 'ng-invalid');
cy.contains('#max_buckets + .invalid-feedback', 'The entered value must be >= 1.');
this.navigateTo();
this.delete(tenant + '$' + uname);
}
}
|