Catalog alignment
[sdc.git] / catalog-ui / cypress / integration / collapsing_roles-certified_life_cycle_buttons.js
1 import { initCommonFixtures } from "../common/init";
2
3 describe('Collapsing Roles', () => {
4   beforeEach(() => {
5     cy.server();
6     initCommonFixtures(cy);
7
8     cy.fixture('common/service-metadata').as('serviceMetaData');
9     cy.fixture('common/vf-metadata').as('vfMetaData');
10     cy.fixture('common/service-certifyResponse').as('serviceCertifyResponse');
11     cy.fixture('common/dependencies').as('dependenciesResponse');
12     cy.fixture('common/packages').as('packagesResponse');
13   });
14
15   it('Service - Verify UpdateServices, CheckOut, Distribute and Archive exist for a Certified Service that was not Distributed', function () {
16     cy.route('GET', '**/services/*/filteredDataByParams?include=metadata', '@serviceMetaData');
17     cy.route('GET', '**/services/*/dependencies',[]);
18
19     this.serviceMetaData.metadata.distributionStatus = 'DISTRIBUTION_NOT_APPROVED';
20
21     const generalPageUrl = '#!/dashboard/workspace/' + this.serviceMetaData.metadata.uniqueId + '/service/general';
22     cy.visit(generalPageUrl);
23
24     console.log('Verify life cycle is Distribution Approved');
25     cy.get('[data-tests-id="formlifecyclestate"]').should('be.visible');
26     cy.get('[data-tests-id="formlifecyclestate"]').should('have.text','Waiting For Distribution');
27
28     console.log('Verify Upgrade Services Button');
29     cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('be.visible');
30     cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('have.text','Update Services');
31
32     console.log('Verify Distribute Services Button');
33     cy.get('[data-tests-id="distribute"]').should('be.visible');
34     cy.get('[data-tests-id="distribute"]').should('contain.text','Distribute');
35
36     console.log('Verify Check Out Button');
37     cy.get('[data-tests-id="check_out"]').should('be.visible');
38     cy.get('[data-tests-id="check_out"]').should('contain.text','Check Out');
39
40     console.log('Verify Archive Button');
41     cy.get('[data-tests-id="archive-component-button"]').should('be.visible');
42     cy.get('[data-tests-id="archive-component-button"]').should('have.text','Archive');
43
44     console.log('Verify Redistribute Button Not Exist');
45     cy.get('[data-tests-id="redistribute"]').should('not.be.visible');
46     cy.get('[data-tests-id="redistribute"]').should('not.exist');
47
48     console.log("Verify that Certify button does not exist")
49     cy.get('[data-tests-id="certify"]').should('not.be.visible');
50   });
51
52   it('Service - Verify UpdateServices, CheckOut, Redistribute and Archive exist for a Certified Service that was Distributed', function () {
53     cy.route('GET', '**/services/*/filteredDataByParams?include=metadata', '@serviceMetaData');
54     cy.route('GET', '**/services/*/dependencies',[]);
55
56     this.serviceMetaData.metadata.distributionStatus = 'DISTRIBUTED';
57
58     const generalPageUrl = '#!/dashboard/workspace/' + this.serviceMetaData.metadata.uniqueId + '/service/general';
59     cy.visit(generalPageUrl);
60
61     console.log('Verify life cycle is Distribution Approved');
62     cy.get('[data-tests-id="formlifecyclestate"]').should('be.visible');
63     cy.get('[data-tests-id="formlifecyclestate"]').should('have.text','Distributed');
64
65     console.log('Verify Upgrade Services Button');
66     cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('be.visible');
67     cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('have.text','Update Services');
68
69     console.log('Verify Distribute Services Button');
70     cy.get('[data-tests-id="redistribute"]').should('be.visible');
71     cy.get('[data-tests-id="redistribute"]').should('contain.text','Redistribute');
72
73     console.log('Verify Check Out Button');
74     cy.get('[data-tests-id="check_out"]').should('be.visible');
75     cy.get('[data-tests-id="check_out"]').should('contain.text','Check Out');
76
77     console.log('Verify Archive Button');
78     cy.get('[data-tests-id="archive-component-button"]').should('be.visible');
79     cy.get('[data-tests-id="archive-component-button"]').should('have.text','Archive');
80
81     console.log('Verify Distribute Button Not Exist');
82     cy.get('[data-tests-id="distribute"]').should('not.be.visible');
83     cy.get('[data-tests-id="distribute"]').should('not.exist');
84
85     console.log("Verify that Certify button does not exist")
86     cy.get('[data-tests-id="certify"]').should('not.be.visible');
87   });
88
89   it('Service - Verify UpdateServices button is disabled in case there are no Dependencies for a Certified Service', function () {
90     cy.route('GET', '**/services/*/filteredDataByParams?include=metadata', '@serviceMetaData');
91     cy.route('GET', '**/services/*/dependencies',[{dependencies: null}]);
92
93     this.serviceMetaData.metadata.distributionStatus = 'DISTRIBUTED';
94
95     const generalPageUrl = '#!/dashboard/workspace/' + this.serviceMetaData.metadata.uniqueId + '/service/general';
96     cy.visit(generalPageUrl);
97
98     console.log('Verify life cycle is Distribution Approved');
99     cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('be.visible');
100     cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('be.disabled');
101     cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('have.text','Update Services');
102
103     console.log("Verify that Certify button does not exist")
104     cy.get('[data-tests-id="certify"]').should('not.be.visible');
105   });
106
107   it('Service - Verify UpdateServices button is enabled in case there are Dependencies for a Certified Service', function () {
108     cy.route('GET', '**/services/*/filteredDataByParams?include=metadata', '@serviceMetaData');
109     cy.route('GET', '**/services/*/dependencies',[{dependencies: {}}]);
110
111     this.serviceMetaData.metadata.distributionStatus = 'DISTRIBUTED';
112
113     const generalPageUrl = '#!/dashboard/workspace/' + this.serviceMetaData.metadata.uniqueId + '/service/general';
114     cy.visit(generalPageUrl);
115
116     console.log('Verify life cycle is Distribution Approved');
117     cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('be.visible');
118     cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('be.enabled');
119     cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('have.text','Update Services');
120
121     console.log("Verify that Certify button does not exist")
122     cy.get('[data-tests-id="certify"]').should('not.be.visible');
123   });
124
125   it('Service - Verify UpdateServices Not exist and Certify Exist in case Service is in state NOT_CERTIFIED_CHECKOUT', function () {
126     cy.route('GET', '**/services/*/filteredDataByParams?include=metadata', '@serviceMetaData');
127     cy.route('GET', '**/services/*/dependencies',[{dependencies: {}}]);
128
129     this.serviceMetaData.metadata.lifecycleState = 'NOT_CERTIFIED_CHECKOUT';
130
131     const generalPageUrl = '#!/dashboard/workspace/' + this.serviceMetaData.metadata.uniqueId + '/service/general';
132     cy.visit(generalPageUrl);
133
134     console.log('Verify life cycle is Distribution Approved');
135     cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('not.be.visible');
136
137     cy.get('[data-tests-id="certify"]').should('be.visible').click();
138     cy.get('[data-tests-id="checkindialog"]').should('be.visible');
139   });
140
141   it('Service - Verify UpdateServices Not exist and Certify Exist in case Service is in state NOT_CERTIFIED_CHECKIN', function () {
142     cy.route('GET', '**/services/*/filteredDataByParams?include=metadata', '@serviceMetaData');
143     cy.route('GET', '**/services/*/dependencies',[{dependencies: {}}]);
144
145     this.serviceMetaData.metadata.lifecycleState = 'NOT_CERTIFIED_CHECKIN';
146
147     const generalPageUrl = '#!/dashboard/workspace/' + this.serviceMetaData.metadata.uniqueId + '/service/general';
148     cy.visit(generalPageUrl);
149
150     cy.get('[data-tests-id="certify"]').should('be.visible').click();
151     cy.get('[data-tests-id="checkindialog"]').should('be.visible');
152   });
153
154
155   it('Service - When Service is being Certified, and has Dependencies, Update Service modal will be opened automatically', function () {
156       cy.route('GET', '**/services/*/filteredDataByParams?include=metadata', '@serviceMetaData');
157       cy.route('GET', '**/services/*/dependencies','@dependenciesResponse');
158       cy.route('POST', '**/services/*/lifecycleState/certify','@serviceCertifyResponse');
159       cy.route('GET', '**/catalog/services/validate-name/*', { isValid: true})
160       this.serviceMetaData.metadata.lifecycleState = 'NOT_CERTIFIED_CHECKOUT';
161
162       const generalPageUrl = '#!/dashboard/workspace/' + this.serviceMetaData.metadata.uniqueId + '/service/general';
163       cy.visit(generalPageUrl);
164
165       console.log('Verify life cycle is Distribution Approved');
166       cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('not.be.visible');
167
168       console.log('Click Certify');
169       cy.get('[data-tests-id="certify"]').should('be.visible').click();
170
171       console.log('Insert confirm text');
172       cy.get('[data-tests-id="checkindialog"]').should('be.visible').type('Test_1234');
173
174       console.log('Click OK');
175       cy.get('[data-tests-id="confirm-modal-button-ok"]').should('be.visible').click();
176
177       console.log('Close the Modal');
178       cy.get('[data-tests-id="upgradeVspModal-button-close"]').should('be.visible').click();
179   });
180
181   it('VF - Verify Certify and Check in exist for a NOT_CERTIFIED_CHECKOUT VF', function () {
182     cy.route('GET', '**/resources/*/filteredDataByParams?include=metadata', '@vfMetaData');
183     cy.route('GET', '**/onboarding-api/*/vendor-software-products/packages', '@packagesResponse');
184
185     const generalPageUrl = '#!/dashboard/workspace/' + this.vfMetaData.metadata.uniqueId + '/resource/general';
186     cy.visit(generalPageUrl);
187
188     console.log('Verify life cycle is IN DESIGN CHECK OUT');
189     cy.get('[data-tests-id="formlifecyclestate"]').should('be.visible');
190     cy.get('[data-tests-id="formlifecyclestate"]').should('have.text','In Design Check Out');
191
192     console.log('Verify Certify button exist');
193     cy.get('[data-tests-id="certify"]').should('be.visible').click();
194     cy.get('[data-tests-id="checkindialog"]').should('be.visible');
195
196     console.log('Verify Check in button exist');
197     cy.get('[data-tests-id="check_in"]').should('be.visible');
198
199    });
200
201   it('VF - Verify Certify and Check out exist for a NOT_CERTIFIED_CHECKOUT VF', function () {
202     cy.route('GET', '**/resources/*/filteredDataByParams?include=metadata', '@vfMetaData');
203     cy.route('GET', '**/onboarding-api/*/vendor-software-products/packages', '@packagesResponse');
204
205     this.vfMetaData.metadata.lifecycleState = 'NOT_CERTIFIED_CHECKIN';
206
207     const generalPageUrl = '#!/dashboard/workspace/' + this.vfMetaData.metadata.uniqueId + '/resource/general';
208     cy.visit(generalPageUrl);
209
210     console.log('Verify life cycle is IN DESIGN CHECK IN');
211     cy.get('[data-tests-id="formlifecyclestate"]').should('be.visible');
212     cy.get('[data-tests-id="formlifecyclestate"]').should('have.text','In Design Check In');
213
214     console.log('Verify Certify button exist');
215     cy.get('[data-tests-id="certify"]').should('be.visible').click();
216     cy.get('[data-tests-id="checkindialog"]').should('be.visible');
217
218     console.log('Verify Check Out button exist');
219     cy.get('[data-tests-id="check_out"]').should('be.visible');
220
221    });
222
223   it('VF - Verify UpgradeServices is Disabled in case there are no Dependencies for a Certified VF', function () {
224       cy.route('GET', '**/resources/*/filteredDataByParams?include=metadata', '@vfMetaData');
225       cy.route('GET', '**/resources/*/dependencies',[{dependencies: null}]);
226
227         this.vfMetaData.metadata.lifecycleState = 'CERTIFIED';
228
229       const generalPageUrl = '#!/dashboard/workspace/' + this.vfMetaData.metadata.uniqueId + '/resource/general';
230       cy.visit(generalPageUrl);
231
232         console.log('Verify life cycle is Certified');
233         cy.get('[data-tests-id="formlifecyclestate"]').should('be.visible');
234         cy.get('[data-tests-id="formlifecyclestate"]').should('have.text','Certified');
235
236         console.log('Verify life cycle is Distribution Approved');
237         cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('be.visible');
238         cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('be.disabled');
239         cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('have.text','Upgrade Services');
240
241         console.log('Verify Check Out button exist');
242         cy.get('[data-tests-id="check_out"]').should('be.visible');
243
244         console.log('Verify Archive Button');
245         cy.get('[data-tests-id="archive-component-button"]').should('be.visible');
246         cy.get('[data-tests-id="archive-component-button"]').should('have.text','Archive');
247
248     });
249
250   it('VF - Verify UpgradeServices is Enabled and Modal is opened in case there are no Dependencies for a Certified VF', function () {
251     cy.route('GET', '**/resources/*/filteredDataByParams?include=metadata', '@vfMetaData');
252     cy.route('GET', '**/resources/*/dependencies',[{dependencies: {}}]);
253     cy.route('GET', '**/onboarding-api/*/vendor-software-products/packages', '@packagesResponse');
254
255     this.vfMetaData.metadata.lifecycleState = 'CERTIFIED';
256
257     const generalPageUrl = '#!/dashboard/workspace/' + this.vfMetaData.metadata.uniqueId + '/resource/general';
258     cy.visit(generalPageUrl);
259
260     console.log('Verify life cycle is Certified');
261     cy.get('[data-tests-id="formlifecyclestate"]').should('be.visible');
262     cy.get('[data-tests-id="formlifecyclestate"]').should('have.text','Certified');
263
264     console.log('Verify life cycle is Distribution Approved');
265     cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('be.visible');
266     cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('be.enabled');
267     cy.get('[data-tests-id="open-upgrade-vsp-popup"]').should('have.text','Upgrade Services').click();
268     cy.get('[class="sdc-modal__wrapper sdc-modal-type-custom"]').should('be.visible');
269     cy.get('[data-tests-id="upgradeVspModal-button-close"]').should('be.enabled').click();
270
271     console.log('Verify Check Out button exist');
272     cy.get('[data-tests-id="check_out"]').should('be.visible');
273
274     console.log('Verify Archive Button');
275     cy.get('[data-tests-id="archive-component-button"]').should('be.visible');
276     cy.get('[data-tests-id="archive-component-button"]').should('have.text','Archive');
277
278   });
279
280 });