aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master')
-rw-r--r--vid-webpack-master/cypress/integration/iFrames/browse-sdc.e2e.ts134
-rw-r--r--vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts162
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts6
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html1
-rw-r--r--vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts2
-rw-r--r--vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts6
-rw-r--r--vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts40
-rw-r--r--vid-webpack-master/src/app/shared/utils/iframe.service.ts13
8 files changed, 198 insertions, 166 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/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts
index dd17e7db5..7fb7ea584 100644
--- a/vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts
+++ b/vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts
@@ -1,89 +1,45 @@
///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
describe('Template', () => {
-
- const instantiationTemplates = [
- {
- "id": 8,
- "created": 1525075968000,
- "modified": 1525075971000,
- "action": "INSTANTIATE",
- "createdId": null,
- "modifiedId": null,
- "rowNum": null,
- "auditUserId": null,
- "auditTrail": null,
- "jobId": "5c2cd8e5-27d0-42e3-85a1-85db5eaba459",
- "templateId": "d42ba7c8-9e19-4e34-ae2c-d8af3f24498e",
- "userId": "16807000",
- "aLaCarte": false,
- "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d9c",
- "jobStatus": "FAILED",
- "statusModifiedDate": 1525075968000,
- "hidden": false,
- "pause": false,
- "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
- "owningEntityName": "WayneHolland",
- "project": "WATKINS",
- "aicZoneId": "NFT1",
- "aicZoneName": "NFTJSSSS-NFT1",
- "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
- "tenantName": "AIN Web Tool-15-D-testalexandria",
- "regionId": "hvf6",
- "regionName": null,
- "serviceType": "TYLER SILVIA",
- "subscriberName": "e433710f-9217-458d-a79d-1c7aff376d89",
- "serviceInstanceId": null,
- "serviceInstanceName": "nWUfl instance name_002",
- "serviceModelId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
- "serviceModelName": "action-data",
- "serviceModelVersion": "1.0",
- "createdBulkDate": 1525075968000,
- "isRetryEnabled": true,
- "requestSummary": {
- "vnf": 1,
- "vfModule": 2,
- "volumeGroup": 1
- }
- },
- {
- "id": 7,
- "created": 1525075968000,
- "modified": 1525075971000,
- "action": "INSTANTIATE",
- "createdId": null,
- "modifiedId": null,
- "rowNum": null,
- "auditUserId": null,
- "auditTrail": null,
- "jobId": "13063a83-924e-4500-a3a1-e53d1b58450b",
- "templateId": "d42ba7c8-9e19-4e34-ae2c-d8af3f24498e",
- "userId": "17807000",
- "aLaCarte": false,
- "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d9d",
- "jobStatus": "IN_PROGRESS",
- "statusModifiedDate": 1525075968000,
- "hidden": false,
- "pause": false,
- "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
- "owningEntityName": "WayneHolland",
- "project": "WATKINS",
- "aicZoneId": "NFT1",
- "aicZoneName": "NFTJSSSS-NFT1",
- "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
- "tenantName": "AIN Web Tool-15-D-testalexandria",
- "regionId": "hvf6",
- "regionName": null,
- "serviceType": "TYLER SILVIA",
- "subscriberName": "e433710f-9217-458d-a79d-1c7aff376d89",
- "serviceInstanceId": null,
- "serviceInstanceName": "nWUfl instance name_001",
- "serviceModelId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
- "serviceModelName": "action-data",
- "serviceModelVersion": "1.0",
- "createdBulkDate": 1525075968000,
- "isRetryEnabled": false
- }
- ];
+ const templateJobIdFromE2EFile = 'ef3430f8-6350-454c-a7c2-89ba301522c1';
+
+ const aSecondTemplateInfo = {
+ id: 7,
+ created: 1525075968000,
+ modified: 1525075971000,
+ action: "INSTANTIATE",
+ createdId: null,
+ modifiedId: null,
+ rowNum: null,
+ auditUserId: null,
+ auditTrail: null,
+ jobId: "13063a83-924e-4500-a3a1-e53d1b58450b",
+ templateId: "d42ba7c8-9e19-4e34-ae2c-d8af3f24498e",
+ userId: "17807000",
+ aLaCarte: false,
+ msoRequestId: "c0011670-0e1a-4b74-945d-8bf5aede1d9d",
+ jobStatus: "IN_PROGRESS",
+ statusModifiedDate: 1525075968000,
+ hidden: false,
+ pause: false,
+ owningEntityId: "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
+ owningEntityName: "WayneHolland",
+ project: "WATKINS",
+ aicZoneId: "NFT1",
+ aicZoneName: "NFTJSSSS-NFT1",
+ tenantId: "bae71557c5bb4d5aac6743a4e5f1d054",
+ tenantName: "AIN Web Tool-15-D-testalexandria",
+ regionId: "hvf6",
+ regionName: null,
+ serviceType: "TYLER SILVIA",
+ subscriberName: "e433710f-9217-458d-a79d-1c7aff376d89",
+ serviceInstanceId: null,
+ serviceInstanceName: "nWUfl instance name_001",
+ serviceModelId: "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
+ serviceModelName: "action-data",
+ serviceModelVersion: "1.0",
+ createdBulkDate: 1525075968000,
+ isRetryEnabled: false
+ };
beforeEach(() => {
cy.clearSessionStorage();
@@ -107,8 +63,13 @@ describe('Template', () => {
}).as('initFlags');
});
- cy.route(Cypress.config('baseUrl') + "/instantiationTemplates**", instantiationTemplates);
- cy.route(Cypress.config('baseUrl') + "/getuserID", '16807000');
+ cy.readFile('fixture:../../../vid-automation/src/test/resources/asyncInstantiation/vidRequestCreateBulkOfMacro__template_info.json').then((templateInfoFromE2EFile)=>{
+ cy.route(Cypress.config('baseUrl') + "/instantiationTemplates?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd",
+ [ templateInfoFromE2EFile, aSecondTemplateInfo ]
+ )
+ });
+
+ cy.route(Cypress.config('baseUrl') + "/getuserID", 'us16807000');
cy.openPopupIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true');
@@ -124,8 +85,7 @@ describe('Template', () => {
.getElementByDataTestsId('template-modal-title').contains('Templates') // Check Modal header
.getElementByDataTestsId('description-part-1').contains('The following list presents previous instantiations done for this model in this version.')
.getElementByDataTestsId('description-part-2').contains('You may use one of them as a baseline for your instantiation or start from scratch.')
- .getElementByDataTestsId('description-part-3').contains('Once you selecting one allows you to change the data before start instantiating.')
-
+ .getElementByDataTestsId('description-part-3').contains('Once you selecting one allows you to change the data before start instantiating.');
//check table headers
cy.get(`#header-userId`).contains('User ID');
@@ -137,19 +97,19 @@ describe('Template', () => {
cy.get(`#header-aicZone`).contains('AIC Zone');
// check table body row
- cy.getElementByDataTestsId(`userId-${instantiationTemplates[0].jobId}`).contains('16807000');
- cy.getElementByDataTestsId(`createDate-${instantiationTemplates[0].jobId}`).contains('2018-04-30 11:12:48');
- cy.getElementByDataTestsId(`instanceName-${instantiationTemplates[0].jobId}`).contains('nWUfl instance name_002');
- cy.getElementByDataTestsId(`instantiationStatus-${instantiationTemplates[0].jobId}`).contains('FAILED');
- cy.getElementByDataTestsId(`summary-${instantiationTemplates[0].jobId}`).contains('vnf: 1, vfModule: 2, volumeGroup: 1');
- cy.getElementByDataTestsId(`region-${instantiationTemplates[0].jobId}`).contains('hvf6 (WAYNEHOLLAND)');
- cy.getElementByDataTestsId(`tenant-${instantiationTemplates[0].jobId}`).contains('AIN Web Tool-15-D-testalexandria');
- cy.getElementByDataTestsId(`aicZone-${instantiationTemplates[0].jobId}`).contains('NFTJSSSS-NFT1');
+ cy.getElementByDataTestsId(`userId-${templateJobIdFromE2EFile}`).contains('16807000');
+ cy.getElementByDataTestsId(`createDate-${templateJobIdFromE2EFile}`).contains('2019-12-26 11:57:05');
+ cy.getElementByDataTestsId(`instanceName-${templateJobIdFromE2EFile}`).contains('SERVICE_NAME');
+ cy.getElementByDataTestsId(`instantiationStatus-${templateJobIdFromE2EFile}`).contains('IN_PROGRESS');
+ cy.getElementByDataTestsId(`summary-${templateJobIdFromE2EFile}`).contains('vnf: 1, vfModule: 2, volumeGroup: 1');
+ cy.getElementByDataTestsId(`region-${templateJobIdFromE2EFile}`).contains('hvf3 (SOMENAME)');
+ cy.getElementByDataTestsId(`tenant-${templateJobIdFromE2EFile}`).contains('greatTenant');
+ cy.getElementByDataTestsId(`aicZone-${templateJobIdFromE2EFile}`).contains('NFTJSSSS-NFT1');
//check load button is disabled
cy.getElementByDataTestsId('LoadTemplateButton').should('be.disabled');
- cy.getElementByDataTestsId('row-5c2cd8e5-27d0-42e3-85a1-85db5eaba459').click();
+ cy.getElementByDataTestsId(`row-${templateJobIdFromE2EFile}`).click();
cy.getElementByDataTestsId('LoadTemplateButton').should('not.be.disabled');
//filter by userId
@@ -164,18 +124,16 @@ describe('Template', () => {
cy.getElementByDataTestsId('templateButton').contains('Template')
.getElementByDataTestsId('templateButton').click({force: true}) // Open template Modal
- const serviceModelId = 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0';
- const jobId = '5c2cd8e5-27d0-42e3-85a1-85db5eaba459';
+ const serviceModelId = '5c9e863f-2716-467b-8799-4a67f378dcaa';
const vidBaseUrl = `http://localhost:8080/vid/serviceModels.htm`;
- cy.getElementByDataTestsId('row-5c2cd8e5-27d0-42e3-85a1-85db5eaba459').click();
+ cy.getElementByDataTestsId(`row-${templateJobIdFromE2EFile}`).click();
cy.getElementByDataTestsId('LoadTemplateButton').click().setViewportToDefault();
cy.location().should((loc) => {
- expect(loc.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/RECREATE?serviceModelId=${serviceModelId}&jobId=${jobId}`);
+ expect(loc.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/RECREATE?serviceModelId=${serviceModelId}&jobId=${templateJobIdFromE2EFile}`);
});
});
-
});
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()">&times;
</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];