Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 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 () { |
Yoav Schneiderman | 51d9784 | 2020-01-01 10:23:16 +0200 | [diff] [blame] | 7 | const jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>(); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 8 | |
| 9 | |
Yoav Schneiderman | 51d9784 | 2020-01-01 10:23:16 +0200 | [diff] [blame] | 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 | }); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 19 | |
Yoav Schneiderman | 51d9784 | 2020-01-01 10:23:16 +0200 | [diff] [blame] | 20 | afterEach(() => { |
| 21 | cy.screenshot(); |
| 22 | }); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 23 | |
Yoav Schneiderman | 51d9784 | 2020-01-01 10:23:16 +0200 | [diff] [blame] | 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'; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 28 | const CANCEL_BUTTON = "cancelButton"; |
| 29 | |
Yoav Schneiderman | 51d9784 | 2020-01-01 10:23:16 +0200 | [diff] [blame] | 30 | cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/list-services.json').then((res) => { |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 31 | jsonBuilderAndMock.basicJson(res, |
| 32 | Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED', |
| 33 | 200, |
| 34 | 0, |
| 35 | 'list_services'); |
| 36 | }); |
| 37 | |
Yoav Schneiderman | 51d9784 | 2020-01-01 10:23:16 +0200 | [diff] [blame] | 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 | |
Eylon Malin | 1b6489a | 2020-01-12 16:09:48 +0200 | [diff] [blame] | 66 | it(`browse sdc should open instantiation template modal if service isInstantiationTemplateExists is true`, function () { |
Yoav Schneiderman | 51d9784 | 2020-01-01 10:23:16 +0200 | [diff] [blame] | 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) => { |
Eylon Malin | 1b6489a | 2020-01-12 16:09:48 +0200 | [diff] [blame] | 70 | res.services = res.services.map((service: { uuid: string, isInstantiationTemplateExists: boolean }) => { |
Yoav Schneiderman | 51d9784 | 2020-01-01 10:23:16 +0200 | [diff] [blame] | 71 | if (service.uuid === SERVICE_MODEL_ID) { |
Eylon Malin | 1b6489a | 2020-01-12 16:09:48 +0200 | [diff] [blame] | 72 | service.isInstantiationTemplateExists = true; |
Yoav Schneiderman | 51d9784 | 2020-01-01 10:23:16 +0200 | [diff] [blame] | 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 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 Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 114 | 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 Stern | 7befef8 | 2019-07-11 15:54:36 +0300 | [diff] [blame] | 121 | cy.get('span').contains('Browse SDC Service Models').click({force: true}); |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 122 | 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 Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 132 | }); |