diff options
Diffstat (limited to 'vid-webpack-master')
7 files changed, 138 insertions, 64 deletions
diff --git a/vid-webpack-master/cypress/integration/iFrames/browse-sdc.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/browse-sdc.e2e.ts index b3ef7f032..427696561 100644 --- a/vid-webpack-master/cypress/integration/iFrames/browse-sdc.e2e.ts +++ b/vid-webpack-master/cypress/integration/iFrames/browse-sdc.e2e.ts @@ -4,72 +4,105 @@ import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder'; import {ServiceModel} from '../../support/jsonBuilders/models/service.model'; describe('Browse SDC', function () { - var jsonBuilderAndMock : JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>(); + const jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>(); - beforeEach(() => { - cy.clearSessionStorage(); - cy.preventErrorsOnLoading(); - cy.initAAIMock(); - cy.initVidMock(); - cy.initZones(); - cy.login(); - cy.visit("welcome.htm") + beforeEach(() => { + cy.clearSessionStorage(); + cy.preventErrorsOnLoading(); + cy.initAAIMock(); + cy.initVidMock(); + cy.initZones(); + cy.login(); + cy.visit("welcome.htm") + }); + + afterEach(() => { + cy.screenshot(); + }); + + it(`browse sdc open macro with network and then macro for new flow`, function () { + // const MACRO_WITH_CONFIGURATION_ID: string = 'ee6d61be-4841-4f98-8f23-5de9da846ca7'; + const MACRO_WITH_NETWORK_ID: string = "bd8ffd14-da36-4f62-813c-6716ba9f4354"; + const MACRO_FOR_NEW_FLOW_ID: string = '74fa72dd-012b-49c3-800d-06b12bcaf1a0'; + const CANCEL_BUTTON = "cancelButton"; + + cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/list-services.json').then((res) => { + jsonBuilderAndMock.basicJson(res, + Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED', + 200, + 0, + 'list_services'); }); - afterEach(() => { - cy.screenshot(); + cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/service-with-configuration.json').then((res) => { + jsonBuilderAndMock.basicJson(res, + Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_WITH_NETWORK_ID, + 200, + 0, + 'MACRO_WITH_CONFIGURATION'); }); - it(`browse sdc open macro with network and then macro for new flow`, function () { - // const MACRO_WITH_CONFIGURATION_ID: string = 'ee6d61be-4841-4f98-8f23-5de9da846ca7'; - const MACRO_WITH_NETWORK_ID: string = "bd8ffd14-da36-4f62-813c-6716ba9f4354"; - const MACRO_FOR_NEW_FLOW_ID: string = '74fa72dd-012b-49c3-800d-06b12bcaf1a0'; - const CANCEL_BUTTON = "cancelButton"; - - cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/list-services.json').then((res) => { - jsonBuilderAndMock.basicJson(res, - Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED', - 200, - 0, - 'list_services'); - }); + cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/Dror_service1806_Macro1.json').then((res) => { + jsonBuilderAndMock.basicJson(res, + Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_FOR_NEW_FLOW_ID, + 200, + 0, + 'MACRO_FOR_NEW_FLOW'); + }); - cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/service-with-configuration.json').then((res) => { - jsonBuilderAndMock.basicJson(res, - Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_WITH_NETWORK_ID, - 200, - 0, - 'MACRO_WITH_CONFIGURATION'); - }); + cy.get('span').contains('Browse SDC Service Models').click({force: true}); + cy.wait("@list_services").then(() => { + cy.getElementByDataTestsId('deploy-' + MACRO_WITH_NETWORK_ID).click({force: true}) + .getElementByDataTestsId(CANCEL_BUTTON).click({force: true}); + cy.getElementByDataTestsId('deploy-' + MACRO_FOR_NEW_FLOW_ID).click({force: true}); + cy.get("iframe"); + }); - cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/Dror_service1806_Macro1.json').then((res) => { - jsonBuilderAndMock.basicJson(res, - Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_FOR_NEW_FLOW_ID, - 200, - 0, - 'MACRO_FOR_NEW_FLOW'); - }); + cy.visit("welcome.htm"); //relaod page to not break the following tests + + }); + + it(`browse sdc should open instantiation template modal if service hasTemplate is true`, function () { + const SERVICE_MODEL_ID: string = '74fa72dd-012b-49c3-800d-06b12bcaf1a0'; - cy.get('span').contains('Browse SDC Service Models').click({force: true}); - cy.wait("@list_services").then(() => { - cy.getElementByDataTestsId('deploy-' + MACRO_WITH_NETWORK_ID).click({force: true}) - .getElementByDataTestsId(CANCEL_BUTTON).click({force: true}); - cy.getElementByDataTestsId('deploy-' + MACRO_FOR_NEW_FLOW_ID).click({force: true}); - cy.get("iframe"); + cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/list-services.json').then((res) => { + res.services = res.services.map((service: { uuid: string, hasTemplate: boolean }) => { + if (service.uuid === SERVICE_MODEL_ID) { + service.hasTemplate = true; + } + return service; }); + jsonBuilderAndMock.basicJson(res, + Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED', + 200, + 0, + 'list_services'); + }); - cy.visit("welcome.htm"); //relaod page to not break the following tests + cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/Dror_service1806_Macro1.json').then((res) => { + jsonBuilderAndMock.basicJson(res, + Cypress.config('baseUrl') + '/rest/models/services/' + SERVICE_MODEL_ID, + 200, + 0, + 'MACRO_FOR_NEW_FLOW'); + }); + + cy.get('span').contains('Browse SDC Service Models').click({force: true}); + cy.wait("@list_services").then(() => { + cy.getElementByDataTestsId('deploy-' + SERVICE_MODEL_ID).click({force: true}); + cy.get('iframe').then(function ($iframe) { + expect($iframe.attr('src')).to.contain(`app/ui/#/instantiationTemplatesPopup?serviceModelId=${SERVICE_MODEL_ID}`); + }); }); + }); it(`browse sdc of service without instantiationType open aLaCarte popup`, function () { const VERY_OLD_SERVICE_UUID: string = "09c476c7-91ae-44b8-a731-04d8d8fa3695"; - const TEST_MOCKS_PATH="cypress/support/jsonBuilders/mocks/jsons/bug_aLaCarteServiceWrongPopup/"; + const TEST_MOCKS_PATH = "cypress/support/jsonBuilders/mocks/jsons/bug_aLaCarteServiceWrongPopup/"; - const CANCEL_BUTTON = "cancelButton"; - - cy.readFile(TEST_MOCKS_PATH+'list-services.json').then((res) => { + cy.readFile(TEST_MOCKS_PATH + 'list-services.json').then((res) => { jsonBuilderAndMock.basicJson(res, Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED', 200, @@ -77,7 +110,7 @@ describe('Browse SDC', function () { 'list_services'); }); - cy.readFile(TEST_MOCKS_PATH+'serviceWithoutInstantiationType.json').then((res) => { + cy.readFile(TEST_MOCKS_PATH + 'serviceWithoutInstantiationType.json').then((res) => { jsonBuilderAndMock.basicJson(res, Cypress.config('baseUrl') + '/rest/models/services/' + VERY_OLD_SERVICE_UUID, 200, @@ -96,5 +129,4 @@ describe('Browse SDC', function () { }); - }); diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts index 3cd633de6..eb608652c 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts @@ -70,11 +70,7 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole } closeDialog(that): void { - this._iframeService.removeClassCloseModal(that.parentElementClassName); - this.dialogService.removeDialog(this); - setTimeout(() => { - window.parent.postMessage("closeIframe", "*"); - }, 15); + this._iframeService.closeIframe(this.dialogService, this); } shouldShowNotification(): boolean { diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html index 07fc7ab22..e2922b2a2 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html @@ -2,6 +2,7 @@ <div class="modal-content"> <div class="modal-header"> <button type="button" + [attr.data-tests-id]="'closeModal'" class="close" (click)="closeModal()">× </button> diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts index 6a734161f..20655d54a 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts @@ -68,6 +68,6 @@ export class InstantiationTemplatesModalComponent extends DialogComponent<string }; closeModal(): void { - this.dialogService.removeDialog(this); + this._iframeService.closeIframe(this.dialogService, this); } } diff --git a/vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts b/vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts index 211f59337..47f849059 100644 --- a/vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts +++ b/vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts @@ -60,11 +60,7 @@ export class SearchElementsModalComponent extends DialogComponent<{ modalInforma closeDialog(): void { this._iframeService.removeFullScreen(); - this._iframeService.removeClassCloseModal(this.parentElementClassName); - this.dialogService.removeDialog(this); - setTimeout(() => { - window.parent.postMessage("closeIframe", "*"); - }, 15); + this._iframeService.closeIframe(this.dialogService, this); } selectedMembersAmountChange(selectedMembersAmount: number): void { diff --git a/vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts b/vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts new file mode 100644 index 000000000..fd5fe0e65 --- /dev/null +++ b/vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts @@ -0,0 +1,40 @@ +import {getTestBed, TestBed} from "@angular/core/testing"; +import {IframeService} from "./iframe.service"; +import {DialogService} from "ng2-bootstrap-modal"; + +export class DialogServiceMock extends DialogService { + removeDialog: (that) => ({}) +} + +describe('Iframe service', () => { + let injector; + let service: IframeService; + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + providers : [ + IframeService + ] + }); + await TestBed.compileComponents(); + + injector = getTestBed(); + service = injector.get(IframeService); + + })().then(done).catch(done.fail)); + + + test('service should be defined', ()=>{ + expect(service).toBeDefined(); + }); + + test('closeIframe: should call removeClassCloseModal', ()=>{ + const dialogService = new DialogServiceMock(null, null, null, null); + spyOn(service, 'removeClassCloseModal'); + spyOn(dialogService, 'removeDialog'); + service.closeIframe(dialogService, {}) + + expect(service.removeClassCloseModal).toBeCalledWith('content'); + expect(dialogService.removeDialog).toBeCalledWith({}); + }); + +}); diff --git a/vid-webpack-master/src/app/shared/utils/iframe.service.ts b/vid-webpack-master/src/app/shared/utils/iframe.service.ts index 4c699825f..ab93d1ac8 100644 --- a/vid-webpack-master/src/app/shared/utils/iframe.service.ts +++ b/vid-webpack-master/src/app/shared/utils/iframe.service.ts @@ -1,22 +1,31 @@ import {Injectable} from "@angular/core"; +import {DialogService} from "ng2-bootstrap-modal"; @Injectable() export class IframeService { addClassOpenModal(elementClassName: string) { - var parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0]; + const parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0]; if (parentBodyElement) { parentBodyElement.classList.add("modal-open"); } } removeClassCloseModal(elementClassName: string) { - var parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0]; + const parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0]; if (parentBodyElement) { parentBodyElement.classList.remove("modal-open"); } } + closeIframe(dialogService : DialogService, that){ + this.removeClassCloseModal('content'); + dialogService.removeDialog(that); + setTimeout(() => { + window.parent.postMessage("closeIframe", "*"); + }, 15); + } + addFullScreen(){ let parentBodyElement = parent.document.getElementsByClassName('service-model-content')[0]; |