]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/buckets.po.ts
add stop-gap to fix compat with CPUs not supporting SSE 4.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / cypress / e2e / rgw / buckets.po.ts
1 import { PageHelper } from '../page-helper.po';
2
3 const pages = {
4 index: { url: '#/rgw/bucket', id: 'cd-rgw-bucket-list' },
5 create: { url: '#/rgw/bucket/create', id: 'cd-rgw-bucket-form' }
6 };
7
8 export class BucketsPageHelper extends PageHelper {
9 static readonly USERS = ['dashboard', 'testid'];
10
11 pages = pages;
12
13 versioningStateEnabled = 'Enabled';
14 versioningStateSuspended = 'Suspended';
15
16 private selectOwner(owner: string) {
17 return this.selectOption('owner', owner);
18 }
19
20 private selectPlacementTarget(placementTarget: string) {
21 return this.selectOption('placement-target', placementTarget);
22 }
23
24 private selectLockMode(lockMode: string) {
25 return this.selectOption('lock_mode', lockMode);
26 }
27
28 @PageHelper.restrictTo(pages.create.url)
29 create(name: string, owner: string, placementTarget: string, isLocking = false) {
30 // Enter in bucket name
31 cy.get('#bid').type(name);
32
33 // Select bucket owner
34 this.selectOwner(owner);
35 cy.get('#owner').should('have.class', 'ng-valid');
36
37 // Select bucket placement target:
38 this.selectPlacementTarget(placementTarget);
39 cy.get('#placement-target').should('have.class', 'ng-valid');
40
41 if (isLocking) {
42 cy.get('#lock_enabled').click({ force: true });
43 // Select lock mode:
44 this.selectLockMode('Compliance');
45 cy.get('#lock_mode').should('have.class', 'ng-valid');
46 cy.get('#lock_retention_period_days').type('3');
47 }
48
49 // Click the create button and wait for bucket to be made
50 cy.contains('button', 'Create Bucket').click();
51
52 this.getFirstTableCell(name).should('exist');
53 }
54
55 @PageHelper.restrictTo(pages.create.url)
56 checkForDefaultEncryption() {
57 cy.get("cd-helper[aria-label='toggle encryption helper']").click();
58 cy.get("a[aria-label='click here']").click();
59 cy.get('cd-modal').within(() => {
60 cy.get('input[id=s3Enabled]').should('be.checked');
61 });
62 }
63
64 @PageHelper.restrictTo(pages.index.url)
65 edit(name: string, new_owner: string, isLocking = false) {
66 this.navigateEdit(name);
67
68 cy.get('input[name=placement-target]').should('have.value', 'default-placement');
69 this.selectOwner(new_owner);
70
71 // If object locking is enabled versioning shouldn't be visible
72 if (isLocking) {
73 cy.get('input[id=versioning]').should('be.disabled');
74 cy.contains('button', 'Edit Bucket').click();
75
76 // wait to be back on buckets page with table visible and click
77 this.getExpandCollapseElement(name).click();
78
79 // check its details table for edited owner field
80 cy.get('.table.table-striped.table-bordered')
81 .first()
82 .should('contains.text', new_owner)
83 .as('bucketDataTable');
84
85 // Check versioning enabled:
86 cy.get('@bucketDataTable').find('tr').its(2).find('td').last().should('have.text', new_owner);
87 cy.get('@bucketDataTable').find('tr').its(11).find('td').last().as('versioningValueCell');
88
89 return cy.get('@versioningValueCell').should('have.text', this.versioningStateEnabled);
90 }
91 // Enable versioning
92 cy.get('input[id=versioning]').should('not.be.checked');
93 cy.get('label[for=versioning]').click();
94 cy.get('input[id=versioning]').should('be.checked');
95
96 cy.contains('button', 'Edit Bucket').click();
97
98 // wait to be back on buckets page with table visible and click
99 this.getExpandCollapseElement(name).click();
100
101 // check its details table for edited owner field
102 cy.get('.table.table-striped.table-bordered')
103 .first()
104 .should('contains.text', new_owner)
105 .as('bucketDataTable');
106
107 // Check versioning enabled:
108 cy.get('@bucketDataTable').find('tr').its(2).find('td').last().should('have.text', new_owner);
109 cy.get('@bucketDataTable').find('tr').its(11).find('td').last().as('versioningValueCell');
110
111 cy.get('@versioningValueCell').should('have.text', this.versioningStateEnabled);
112
113 // Disable versioning:
114 this.navigateEdit(name);
115
116 cy.get('label[for=versioning]').click();
117 cy.get('input[id=versioning]').should('not.be.checked');
118 cy.contains('button', 'Edit Bucket').click();
119
120 // Check versioning suspended:
121 this.getExpandCollapseElement(name).click();
122
123 return cy.get('@versioningValueCell').should('have.text', this.versioningStateSuspended);
124 }
125
126 testInvalidCreate() {
127 this.navigateTo('create');
128 cy.get('#bid').as('nameInputField'); // Grabs name box field
129
130 // Gives an invalid name (too short), then waits for dashboard to determine validity
131 cy.get('@nameInputField').type('rq');
132
133 cy.contains('button', 'Create Bucket').click(); // To trigger a validation
134
135 // Waiting for website to decide if name is valid or not
136 // Check that name input field was marked invalid in the css
137 cy.get('@nameInputField')
138 .should('not.have.class', 'ng-pending')
139 .and('have.class', 'ng-invalid');
140
141 // Check that error message was printed under name input field
142 cy.get('#bid + .invalid-feedback').should(
143 'have.text',
144 'Bucket names must be 3 to 63 characters long.'
145 );
146
147 // Test invalid owner input
148 // select some valid option. The owner drop down error message will not appear unless a valid user was selected at
149 // one point before the invalid placeholder user is selected.
150 this.selectOwner(BucketsPageHelper.USERS[1]);
151
152 // select the first option, which is invalid because it is a placeholder
153 this.selectOwner('-- Select a user --');
154
155 cy.get('@nameInputField').click();
156
157 // Check that owner drop down field was marked invalid in the css
158 cy.get('#owner').should('have.class', 'ng-invalid');
159
160 // Check that error message was printed under owner drop down field
161 cy.get('#owner + .invalid-feedback').should('have.text', 'This field is required.');
162
163 // Check invalid placement target input
164 this.selectOwner(BucketsPageHelper.USERS[1]);
165 // The drop down error message will not appear unless a valid option is previsously selected.
166 this.selectPlacementTarget('default-placement');
167 this.selectPlacementTarget('-- Select a placement target --');
168 cy.get('@nameInputField').click(); // Trigger validation
169 cy.get('#placement-target').should('have.class', 'ng-invalid');
170 cy.get('#placement-target + .invalid-feedback').should('have.text', 'This field is required.');
171
172 // Clicks the Create Bucket button but the page doesn't move.
173 // Done by testing for the breadcrumb
174 cy.contains('button', 'Create Bucket').click(); // Clicks Create Bucket button
175 this.expectBreadcrumbText('Create');
176 // content in fields seems to subsist through tests if not cleared, so it is cleared
177 cy.get('@nameInputField').clear();
178 return cy.contains('button', 'Cancel').click();
179 }
180
181 testInvalidEdit(name: string) {
182 this.navigateEdit(name);
183
184 cy.get('input[id=versioning]').should('exist').and('not.be.checked');
185
186 // Chooses 'Select a user' rather than a valid owner on Edit Bucket page
187 // and checks if it's an invalid input
188
189 // select the first option, which is invalid because it is a placeholder
190 this.selectOwner('-- Select a user --');
191
192 cy.contains('button', 'Edit Bucket').click();
193
194 // Check that owner drop down field was marked invalid in the css
195 cy.get('#owner').should('have.class', 'ng-invalid');
196
197 // Check that error message was printed under owner drop down field
198 cy.get('#owner + .invalid-feedback').should('have.text', 'This field is required.');
199
200 this.expectBreadcrumbText('Edit');
201 }
202 }