fix open modern ui from Create new service instance flow
[vid.git] / vid-webpack-master / cypress / integration / iFrames / browse-sdc.e2e.ts
1 ///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
2 /// <reference types="Cypress" />
3 import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
4 import {ServiceModel} from '../../support/jsonBuilders/models/service.model';
5
6 describe('Browse SDC', function () {
7   const jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
8
9
10   beforeEach(() => {
11     cy.clearSessionStorage();
12     cy.preventErrorsOnLoading();
13     cy.initAAIMock();
14     cy.initVidMock();
15     cy.initZones();
16     cy.login();
17     cy.visit("welcome.htm")
18   });
19
20   afterEach(() => {
21     cy.screenshot();
22   });
23
24   it(`browse sdc open macro with network and then macro for new flow`, function () {
25     // const MACRO_WITH_CONFIGURATION_ID: string = 'ee6d61be-4841-4f98-8f23-5de9da846ca7';
26     const MACRO_WITH_NETWORK_ID: string = "bd8ffd14-da36-4f62-813c-6716ba9f4354";
27     const MACRO_FOR_NEW_FLOW_ID: string = '74fa72dd-012b-49c3-800d-06b12bcaf1a0';
28     const CANCEL_BUTTON = "cancelButton";
29
30     cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/list-services.json').then((res) => {
31       jsonBuilderAndMock.basicJson(res,
32         Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED',
33         200,
34         0,
35         'list_services');
36     });
37
38     cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/service-with-configuration.json').then((res) => {
39       jsonBuilderAndMock.basicJson(res,
40         Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_WITH_NETWORK_ID,
41         200,
42         0,
43         'MACRO_WITH_CONFIGURATION');
44     });
45
46     cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/Dror_service1806_Macro1.json').then((res) => {
47       jsonBuilderAndMock.basicJson(res,
48         Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_FOR_NEW_FLOW_ID,
49         200,
50         0,
51         'MACRO_FOR_NEW_FLOW');
52     });
53
54     cy.get('span').contains('Browse SDC Service Models').click({force: true});
55     cy.wait("@list_services").then(() => {
56       cy.getElementByDataTestsId('deploy-' + MACRO_WITH_NETWORK_ID).click({force: true})
57         .getElementByDataTestsId(CANCEL_BUTTON).click({force: true});
58       cy.getElementByDataTestsId('deploy-' + MACRO_FOR_NEW_FLOW_ID).click({force: true});
59       cy.get("iframe");
60     });
61
62     cy.visit("welcome.htm"); //relaod page to not break the following tests
63
64   });
65
66   it(`browse sdc should open instantiation template modal if service isInstantiationTemplateExists is true`, function () {
67     const SERVICE_MODEL_ID: string = '74fa72dd-012b-49c3-800d-06b12bcaf1a0';
68
69     cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/list-services.json').then((res) => {
70       res.services = res.services.map((service: { uuid: string, isInstantiationTemplateExists: boolean }) => {
71         if (service.uuid === SERVICE_MODEL_ID) {
72           service.isInstantiationTemplateExists = true;
73         }
74         return service;
75       });
76       jsonBuilderAndMock.basicJson(res,
77         Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED',
78         200,
79         0,
80         'list_services');
81     });
82
83     cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/Dror_service1806_Macro1.json').then((res) => {
84       jsonBuilderAndMock.basicJson(res,
85         Cypress.config('baseUrl') + '/rest/models/services/' + SERVICE_MODEL_ID,
86         200,
87         0,
88         'MACRO_FOR_NEW_FLOW');
89     });
90
91
92     cy.get('span').contains('Browse SDC Service Models').click({force: true});
93     cy.wait("@list_services").then(() => {
94       cy.getElementByDataTestsId('deploy-' + SERVICE_MODEL_ID).click({force: true});
95       cy.get('iframe').then(function ($iframe) {
96         expect($iframe.attr('src')).to.contain(`app/ui/#/instantiationTemplatesPopup?serviceModelId=${SERVICE_MODEL_ID}`);
97       });
98     });
99   });
100
101   it(`browse sdc open create new service instance flow`, function () {
102     const MACRO_FOR_NEW_FLOW_ID: string = '745d1bf1-9ed1-413f-8111-f1e984ad63fb';
103
104     cy.initGetAAISubDetails();
105
106     cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiGetModelsByServiceType.json').then((res) => {
107       jsonBuilderAndMock.basicJson(res,
108         Cypress.config('baseUrl') + '/aai_get_models_by_service_type/**',
109         200,
110         0,
111         'aaiGetModelByServiceType');
112     });
113
114     cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/Dror_service1806_Macro1.json').then((res) => {
115       jsonBuilderAndMock.basicJson(res,
116         Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_FOR_NEW_FLOW_ID,
117         200,
118         0,
119         'MACRO_FOR_NEW_FLOW');
120     });
121
122     cy.get('span').contains('Create New Service Instance').click({force: true})
123       .selectDropdownOptionByText('subscriberName', 'SILVIA ROBBINS');
124     cy.get('button').contains('Submit').click({force: true});
125     cy.selectDropdownOptionByText('serviceType', 'TYLER SILVIA');
126     cy.get('button').contains('Submit').click({force: true});
127     cy.wait("@aaiGetModelByServiceType").then(() => {
128       cy.getElementByDataTestsId('deploy-' + MACRO_FOR_NEW_FLOW_ID).click({force: true});
129       cy.get('button').contains('Deploy').eq(0).click({force: true});
130       cy.get('iframe').then(function ($iframe) {
131           expect($iframe.attr('src')).to.contain(`app/ui/#/servicePopup?serviceModelId=74fa72dd-012b-49c3-800d-06b12bcaf1a0`);
132       });
133     });
134
135     cy.visit("welcome.htm"); //relaod page to not break the following tests
136
137   });
138
139
140   it(`browse sdc of service without instantiationType open aLaCarte popup`, function () {
141     const VERY_OLD_SERVICE_UUID: string = "09c476c7-91ae-44b8-a731-04d8d8fa3695";
142     const TEST_MOCKS_PATH = "cypress/support/jsonBuilders/mocks/jsons/bug_aLaCarteServiceWrongPopup/";
143
144     cy.readFile(TEST_MOCKS_PATH + 'list-services.json').then((res) => {
145       jsonBuilderAndMock.basicJson(res,
146         Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED',
147         200,
148         0,
149         'list_services');
150     });
151
152     cy.readFile(TEST_MOCKS_PATH + 'serviceWithoutInstantiationType.json').then((res) => {
153       jsonBuilderAndMock.basicJson(res,
154         Cypress.config('baseUrl') + '/rest/models/services/' + VERY_OLD_SERVICE_UUID,
155         200,
156         0,
157         'MACRO_WITH_CONFIGURATION');
158     });
159
160     cy.get('span').contains('Browse SDC Service Models').click({force: true});
161     cy.wait("@list_services").then(() => {
162       cy.getElementByDataTestsId('deploy-' + VERY_OLD_SERVICE_UUID).click({force: true})
163         .getElementByDataTestsId('create-modal-title').contains("Create Service Instance -- a la carte");
164     });
165
166     cy.visit("welcome.htm"); //relaod page to not break the following tests
167
168   });
169
170
171 });