blob: 05910665b7d633ede1b648a0fdcf2e7a9de64d16 [file] [log] [blame]
ys969316a9fce2020-01-19 13:50:02 +02001import { initCommonFixtures } from "../common/init";
2
3describe('Update vsp', () => {
4 beforeEach(() => {
5 cy.server();
6 initCommonFixtures(cy);
7 // Followed Resources for the dashboard screen
8 cy.fixture('home/followed').as('followed');
9 cy.fixture('update-vsp/packages-first').as('packagesFirst');
10 cy.fixture('update-vsp/vsp-first').as('vspFirst');
11 cy.fixture('update-vsp/vf-metadata-first').as('vfMetadataFirst');
12
13 cy.fixture('update-vsp/checkout-vsp').as('checkoutVsp');
14 cy.fixture('update-vsp/metadata-after-checkout').as('metadataAfterCheckout');
15
16 cy.fixture('update-vsp/metadata-after-save-fails').as('metadataAfterSaveFails');
17
18 cy.fixture('update-vsp/packages-second').as('packagesSecond');
19 cy.fixture('update-vsp/metadata-second').as('metadataSecond');
20 cy.fixture('update-vsp/checkout-vsp-second').as('checkoutVspSecond');
21 cy.fixture('update-vsp/metadata-third').as('metadataThird');
22
23 cy.fixture('update-vsp/packages-browse').as('packagesBrowse');
24 cy.fixture('update-vsp/metadata-browse').as('metadatabrowse');
25
26 cy.route('GET', '**/followed', '@followed');
27
28 });
29
30 it('Test if checkout fail when update vsp we display the old version', function () {
31 const homePageUrl = '#!/dashboard';
32 cy.visit(homePageUrl);
33
34 cy.route('GET', '**/packages', '@packagesFirst');
35 cy.route('GET', '**/resources/csar/*', 'fixture:update-vsp/vsp-first');
36 cy.route('GET', '**/resources/*/filteredDataByParams?include=metadata', '@vfMetadataFirst');
37 cy.route({
38 method: 'POST',
39 url: '**/resources/*/lifecycleState/CHECKOUT',
40 status: 404,
41 response: {
42 "requestError": {
43 "serviceException": {
44 "messageId": "SVC4063",
45 "text": "Error: Requested \u0027%1\u0027 resource was not found.",
46 "ecompRequestId": "87c1efc1-9f8e-4953-9394-654d28e48bbd",
47 "variables": [
48 ""
49 ]
50 }
51 }
52 }
53 });
54
55 cy.get('[data-tests-id="repository-icon"]').should('be.visible');
56 cy.get('[data-tests-id="repository-icon"]').click({ force: true });
57 cy.get('[data-tests-id="csar-row"]').should('be.visible');
58 cy.get('[data-tests-id="csar-row"]').last().click({ force: true });
59 cy.get('[data-tests-id="update-csar"]').click({ force: true });
60 cy.get('[data-tests-id="error-modal-button-ok"]').click({ force: true });
61 cy.get('[data-tests-id="check_out"]').should('be.visible');
62 cy.get('[data-tests-id="filename"]').should('be.visible');
63 cy.get('[data-tests-id="browseButton"]').should('be.visible');
64 cy.get('[data-tests-id="filename"]').contains('test update vsp (1.0)');
65
66 });
67 it('Test if save fail when update vsp and the mode is check in. we did check out and see the unsave warning', function () {
68 const homePageUrl = '#!/dashboard';
69 cy.visit(homePageUrl);
70 cy.route('GET', '**/packages', '@packagesFirst');
71 cy.route('GET', '**/resources/csar/*', 'fixture:update-vsp/vsp-first');
72 cy.route('GET', '**/resources/*/filteredDataByParams?include=metadata', '@vfMetadataFirst');
73 cy.route('POST', '**/resources/*/lifecycleState/CHECKOUT', '@checkoutVsp');
74 cy.route('GET', '**/resources/*/filteredDataByParams?include=metadata', '@metadataAfterCheckout');
75 cy.route({
76 method: 'PUT',
77 url: '**/resources/*',
78 status: 404,
79 response: {
80 "requestError": {
81 "serviceException": {
82 "messageId": "SVC4063",
83 "text": "Error: Requested \u0027%1\u0027 resource was not found.",
84 "ecompRequestId": "591b0702-115d-4b6a-94c4-ed2bbbc452bc",
85 "variables": [
86 null
87 ]
88 }
89 }
90 }
91 });
92
93 cy.get('[data-tests-id="repository-icon"]').should('be.visible');
94 cy.get('[data-tests-id="repository-icon"]').click({ force: true });
95 cy.get('[data-tests-id="csar-row"]').should('be.visible');
96 cy.get('[data-tests-id="csar-row"]').last().click({ force: true });
97 cy.get('[data-tests-id="update-csar"]').click({ force: true });
98 cy.get('[data-tests-id="check_in"]').should('be.visible');
99 cy.get('[data-tests-id="error-modal-button-ok"]').click({ force: true });
100 cy.get('[data-tests-id="filename"]').should('be.visible');
101 cy.get('[data-tests-id="browseButton"]').should('be.visible');
102 cy.get('[data-tests-id="filename"]').contains('test update vsp (2.0)');
103 cy.get('[data-tests-id="save-warning"]').should('be.visible');
104
105 });
106 it('Test after save fails when refresh the page the new version did not update ', function () {
107 cy.route('GET', '**/packages', '@packagesFirst');
108 cy.route('GET', '**/resources/*/filteredDataByParams?include=metadata', '@metadataAfterSaveFails');
109 const vspUrl = '#!/dashboard/workspace/92582379-f0d5-4655-a0f1-f92b3038d853/resource/general';
110 cy.visit(vspUrl);
111 cy.get('[data-tests-id="filename"]').contains('test update vsp (1.0)');
112 });
113 it('Test when update vsp and the mode is check out. we save the new version', function () {
114 const homePageUrl = '#!/dashboard';
115 cy.visit(homePageUrl);
116
117 cy.route('GET', '**/packages', '@packagesFirst');
118 cy.route('GET', '**/resources/csar/*', 'fixture:update-vsp/vsp-first');
119 cy.route('GET', '**/resources/*/filteredDataByParams?include=metadata', '@metadataAfterCheckout');
120 cy.route('PUT', '**/resources/*', 'fixture:update-vsp/save-vsp');
121
122
123 cy.get('[data-tests-id="repository-icon"]').should('be.visible');
124 cy.get('[data-tests-id="repository-icon"]').click({ force: true });
125 cy.get('[data-tests-id="csar-row"]').should('be.visible');
126 cy.get('[data-tests-id="csar-row"]').last().click({ force: true });
127 cy.get('[data-tests-id="update-csar"]').click({ force: true });
128
129 cy.get('[data-tests-id="check_in"]').should('be.visible');
130 cy.get('[data-tests-id="filename"]').contains('test update vsp (2.0)');
131 cy.get('[data-tests-id="save-warning"]').should('not.be.visible');
132
133
134 });
135 it('Test after save succeeded when refresh the page the new version update', function () {
136 cy.route('GET', '**/packages', '@packagesSecond');
137 cy.route('GET', '**/resources/*/filteredDataByParams?include=metadata', '@metadataSecond');
138 const vspUrl = '#!/dashboard/workspace/09f56471-cb97-49f9-af25-44eaa1af1f05/resource/general';
139 cy.visit(vspUrl);
140 cy.get('[data-tests-id="filename"]').contains('test update vsp (2.0)');
141
142 });
143
144 it('Test when update vsp and the mode is check in. we do checkout and save the new version', function () {
145 const homePageUrl = '#!/dashboard';
146 cy.visit(homePageUrl);
147
148 cy.route('GET', '**/packages', '@packagesSecond');
149 cy.route('GET', '**/resources/csar/*', 'fixture:update-vsp/vsp-second');
150 cy.route('GET', '**/resources/*/filteredDataByParams?include=metadata', '@metadataSecond');
151 cy.route('POST', '**/resources/*/lifecycleState/CHECKOUT', '@checkoutVspSecond');
152 cy.route('GET', '**/resources/*/filteredDataByParams?include=metadata', '@metadataThird');
153 cy.route('PUT', '**/resources/*', 'fixture:update-vsp/save-vsp-second');
154
155 cy.get('[data-tests-id="repository-icon"]').should('be.visible');
156 cy.get('[data-tests-id="repository-icon"]').click({ force: true });
157 cy.get('[data-tests-id="csar-row"]').should('be.visible');
158 cy.get('[data-tests-id="csar-row"]').last().click({ force: true });
159 cy.get('[data-tests-id="update-csar"]').click({ force: true });
160 cy.get('[data-tests-id="check_in"]').should('be.visible');
161 cy.get('[data-tests-id="filename"]').contains('test update vsp (3.0)');
162 cy.get('[data-tests-id="save-warning"]').should('not.be.visible');
163 });
164
165 it('Test update vsp from browse button, and version in the vf is the same of vsp, check that check out and save finish succeessfully', function () {
166
167 cy.route('GET', '**/packages', '@packagesSecond');
168 cy.route('GET', '**/resources/csar/*', 'fixture:update-vsp/vsp-second');
169 cy.route('GET', '**/resources/*/filteredDataByParams?include=metadata', '@metadatabrowse');
170 cy.route('PUT', '**/resources/*', 'fixture:update-vsp/save-vsp-second');
171
172 const homePageUrl = '#!/dashboard/workspace/09f56471-cb97-49f9-af25-44eaa1af1f05/resource/general';
173 cy.visit(homePageUrl);
174
175 cy.get('[data-tests-id="filename"]').contains('test update vsp (3.0)');
176 cy.get('[data-tests-id="browseButton"]').click({ force: true });
177 cy.get('[data-tests-id="csar-row"]').should('be.visible');
178 cy.get('[data-tests-id="csar-row"]').last().click({ force: true });
179 cy.get('[data-tests-id="update-csar"]').click({ force: true });
180 cy.get('[data-tests-id="check_in"]').should('be.visible');
181 cy.get('[data-tests-id="filename"]').contains('test update vsp (3.0)');
182 cy.get('[data-tests-id="save-warning"]').should('not.be.visible');
183
184 });
185
186 it('Test update vsp from browse button check out and save succeessfully', function () {
187 const homePageUrl = '#!/dashboard/workspace/09f56471-cb97-49f9-af25-44eaa1af1f05/resource/general';
188 cy.visit(homePageUrl);
189
190 cy.route('GET', '**/packages', '@packagesBrowse');
191 cy.route('GET', '**/resources/csar/*', 'fixture:update-vsp/vsp-browse');
192 cy.route('GET', '**/resources/*/filteredDataByParams?include=metadata', '@metadatabrowse');
193 cy.route('PUT', '**/resources/*', 'fixture:update-vsp/save-vsp-browse');
194
195 cy.get('[data-tests-id="filename"]').contains('test update vsp (3.0)');
196 cy.get('[data-tests-id="browseButton"]').click({ force: true });
197 cy.get('[data-tests-id="csar-row"]').should('be.visible');
198 cy.get('[data-tests-id="csar-row"]').last().click({ force: true });
199 cy.get('[data-tests-id="update-csar"]').click({ force: true });
200 cy.get('[data-tests-id="check_in"]').should('be.visible');
201 cy.get('[data-tests-id="filename"]').contains('test update vsp (4.0)');
202 cy.get('[data-tests-id="save-warning"]').should('not.be.visible');
203
204 });
205})