blob: a71d9424efadda74572e0d7f73c1c1bf055213ff [file] [log] [blame]
Ittay Stern6f900cc2018-08-29 17:01:32 +03001///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
2/// <reference types="Cypress" />
3import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
4import {ServiceModel} from '../../support/jsonBuilders/models/service.model';
5
6describe('Browse SDC', function () {
Yoav Schneiderman51d97842020-01-01 10:23:16 +02007 const jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
Ittay Stern6f900cc2018-08-29 17:01:32 +03008
9
Yoav Schneiderman51d97842020-01-01 10:23:16 +020010 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 });
Ittay Stern6f900cc2018-08-29 17:01:32 +030019
Yoav Schneiderman51d97842020-01-01 10:23:16 +020020 afterEach(() => {
21 cy.screenshot();
22 });
Ittay Stern6f900cc2018-08-29 17:01:32 +030023
Yoav Schneiderman51d97842020-01-01 10:23:16 +020024 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';
Ittay Stern6f900cc2018-08-29 17:01:32 +030028 const CANCEL_BUTTON = "cancelButton";
29
Yoav Schneiderman51d97842020-01-01 10:23:16 +020030 cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/list-services.json').then((res) => {
Ittay Stern6f900cc2018-08-29 17:01:32 +030031 jsonBuilderAndMock.basicJson(res,
32 Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED',
33 200,
34 0,
35 'list_services');
36 });
37
Yoav Schneiderman51d97842020-01-01 10:23:16 +020038 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
Eylon Malin1b6489a2020-01-12 16:09:48 +020066 it(`browse sdc should open instantiation template modal if service isInstantiationTemplateExists is true`, function () {
Yoav Schneiderman51d97842020-01-01 10:23:16 +020067 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) => {
Eylon Malin1b6489a2020-01-12 16:09:48 +020070 res.services = res.services.map((service: { uuid: string, isInstantiationTemplateExists: boolean }) => {
Yoav Schneiderman51d97842020-01-01 10:23:16 +020071 if (service.uuid === SERVICE_MODEL_ID) {
Eylon Malin1b6489a2020-01-12 16:09:48 +020072 service.isInstantiationTemplateExists = true;
Yoav Schneiderman51d97842020-01-01 10:23:16 +020073 }
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 of service without instantiationType open aLaCarte popup`, function () {
102 const VERY_OLD_SERVICE_UUID: string = "09c476c7-91ae-44b8-a731-04d8d8fa3695";
103 const TEST_MOCKS_PATH = "cypress/support/jsonBuilders/mocks/jsons/bug_aLaCarteServiceWrongPopup/";
104
105 cy.readFile(TEST_MOCKS_PATH + 'list-services.json').then((res) => {
106 jsonBuilderAndMock.basicJson(res,
107 Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED',
108 200,
109 0,
110 'list_services');
111 });
112
113 cy.readFile(TEST_MOCKS_PATH + 'serviceWithoutInstantiationType.json').then((res) => {
Ittay Stern6f900cc2018-08-29 17:01:32 +0300114 jsonBuilderAndMock.basicJson(res,
115 Cypress.config('baseUrl') + '/rest/models/services/' + VERY_OLD_SERVICE_UUID,
116 200,
117 0,
118 'MACRO_WITH_CONFIGURATION');
119 });
120
Ittay Stern7befef82019-07-11 15:54:36 +0300121 cy.get('span').contains('Browse SDC Service Models').click({force: true});
Ittay Stern6f900cc2018-08-29 17:01:32 +0300122 cy.wait("@list_services").then(() => {
123 cy.getElementByDataTestsId('deploy-' + VERY_OLD_SERVICE_UUID).click({force: true})
124 .getElementByDataTestsId('create-modal-title').contains("Create Service Instance -- a la carte");
125 });
126
127 cy.visit("welcome.htm"); //relaod page to not break the following tests
128
129 });
130
131
Ittay Stern6f900cc2018-08-29 17:01:32 +0300132});