1 import { PageHelper } from '../page-helper.po';
4 index: { url: '#/rgw/user', id: 'cd-rgw-user-list' },
5 create: { url: '#/rgw/user/create', id: 'cd-rgw-user-form' }
8 export class UsersPageHelper extends PageHelper {
11 @PageHelper.restrictTo(pages.create.url)
12 create(username: string, fullname: string, email: string, maxbuckets: string) {
14 cy.get('#uid').type(username);
17 cy.get('#display_name').click().type(fullname);
20 cy.get('#email').click().type(email);
23 this.selectOption('max_buckets_mode', 'Custom');
24 cy.get('#max_buckets').click().clear().type(maxbuckets);
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');
31 @PageHelper.restrictTo(pages.index.url)
32 edit(name: string, new_fullname: string, new_email: string, new_maxbuckets: string) {
33 this.navigateEdit(name);
35 // Change the full name field
36 cy.get('#display_name').click().clear().type(new_fullname);
38 // Change the email field
39 cy.get('#email').click().clear().type(new_email);
41 // Change the max buckets field
42 this.selectOption('max_buckets_mode', 'Custom');
43 cy.get('#max_buckets').click().clear().type(new_maxbuckets);
45 cy.contains('button', 'Edit User').click();
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);
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');
61 this.navigateTo('create');
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.
70 .should('have.class', 'ng-invalid');
71 cy.contains('#uid + .invalid-feedback', 'The chosen user ID is already in use.');
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.');
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
85 .should('have.class', 'ng-invalid');
86 cy.contains('#display_name + .invalid-feedback', 'This field is required.');
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.');
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.');
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');
107 this.navigateEdit(name);
109 // put invalid email to make field invalid
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.');
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.');
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.');