be029a1fc6d7e86b145a305b4a3bc6d257137ce3
[vid.git] / vid-webpack-master / cypress / integration / iFrames / instantiation-templates.e2e.ts
1 describe('Drawing Board: Instantiation Templates', function () {
2
3   describe('Load Page and Deploy', () => {
4
5     beforeEach(() => {
6       cy.clearSessionStorage();
7       cy.setTestApiParamToVNF();
8       cy.initVidMock();
9       cy.initDrawingBoardUserPermission();
10       cy.login();
11
12       mockAsyncBulkResponse();
13     });
14
15     afterEach(() => {
16       cy.screenshot();
17     });
18
19     it(`Given a stored template - when click "deploy" - then a coherent request should be sent upon deploy`, function () {
20       const serviceModelId = '6cfeeb18-c2b0-49df-987a-da47493c8e38';
21       const templateUuid = "46390edd-7100-46b2-9f18-419bd24fb60b";
22
23       const drawingBoardAction = `RECREATE`;
24       const templateTopologyEndpoint = "bulkForRetry"; // will be: "templateTopology"
25
26       // Given...
27
28       cy.route(`**/rest/models/services/${serviceModelId}`,
29         'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__service_model.json')
30       .as('serviceModel');
31
32       cy.route(`**/asyncInstantiation/${templateTopologyEndpoint}/${templateUuid}`,
33         'fixture:../support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__instance_template.json')
34       .as('templateTopology');
35
36       // When...
37
38       cy.openIframe(`app/ui/#/servicePlanning/${drawingBoardAction}` +
39         `?jobId=${templateUuid}` +
40         `&serviceModelId=${serviceModelId}`);
41
42       cy.wait('@serviceModel');
43       cy.wait('@templateTopology');
44
45       cy.getDrawingBoardDeployBtn().click();
46
47       // Then...
48
49       cy.wait('@expectedPostAsyncInstantiation').then(xhr => {
50         // cy.readFile('cypress/support/jsonBuilders/mocks/jsons/instantiationTemplates/templates__instance_template.json').then((expectedResult) => {
51         //   cy.deepCompare(xhr.request.body, expectedResult);
52         // });
53       });
54
55     });
56
57   });
58
59
60   function mockAsyncBulkResponse() {
61     cy.server().route({
62       url: Cypress.config('baseUrl') + '/asyncInstantiation/bulk',
63       method: 'POST',
64       status: 200,
65       response: "[]",
66     }).as("expectedPostAsyncInstantiation");
67   }
68
69 });