blob: 3caa4e81d149f1fdd137207b4586b92697455a3f [file] [log] [blame]
Yoav Schneiderman26034812019-12-03 12:55:39 +02001///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
2describe('Template', () => {
3
Sara Weissd6c85042019-12-12 13:45:32 +02004 const asyncInstantiation = [
5 {
6 "id": 8,
7 "created": 1525075968000,
8 "modified": 1525075971000,
9 "action": "INSTANTIATE",
10 "createdId": null,
11 "modifiedId": null,
12 "rowNum": null,
13 "auditUserId": null,
14 "auditTrail": null,
15 "jobId": "5c2cd8e5-27d0-42e3-85a1-85db5eaba459",
16 "templateId": "d42ba7c8-9e19-4e34-ae2c-d8af3f24498e",
17 "userId": "16807000",
18 "aLaCarte": false,
19 "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d9c",
20 "jobStatus": "FAILED",
21 "statusModifiedDate": 1525075968000,
22 "hidden": false,
23 "pause": false,
24 "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
25 "owningEntityName": "WayneHolland",
26 "project": "WATKINS",
27 "aicZoneId": "NFT1",
28 "aicZoneName": "NFTJSSSS-NFT1",
29 "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
30 "tenantName": "AIN Web Tool-15-D-testalexandria",
31 "regionId": "hvf6",
32 "regionName": null,
33 "serviceType": "TYLER SILVIA",
34 "subscriberName": "e433710f-9217-458d-a79d-1c7aff376d89",
35 "serviceInstanceId": null,
36 "serviceInstanceName": "nWUfl instance name_002",
37 "serviceModelId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
38 "serviceModelName": "action-data",
39 "serviceModelVersion": "1.0",
40 "createdBulkDate": 1525075968000,
41 "isRetryEnabled": true
42 }
43 ];
44
Yoav Schneiderman26034812019-12-03 12:55:39 +020045 beforeEach(() => {
46 cy.clearSessionStorage();
47 cy.setReduxState();
48 cy.preventErrorsOnLoading();
49 cy.initAAIMock();
50 cy.initVidMock();
51 cy.login();
Sara Weissd6c85042019-12-12 13:45:32 +020052
53 cy.readFile('cypress/support/jsonBuilders/mocks/jsons/flags.cypress.json').then((flags) => {
54 cy.server()
55 .route({
56 method: 'GET',
57 delay: 0,
58 status: 200,
59 url: Cypress.config('baseUrl') + "/flags**",
60 response: {
61 "FLAG_VF_MODULE_RESUME_STATUS_CREATE": false,
62 "FLAG_2004_INSTANTIATION_TEMPLATES_POPUP": true
63 }
64 }).as('initFlags');
65 });
66
67 cy.route(Cypress.config('baseUrl') + "/asyncInstantiation**", asyncInstantiation);
68
69 cy.openIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true');
70
71
72
73
Yoav Schneiderman26034812019-12-03 12:55:39 +020074 });
75
76 afterEach(() => {
77 cy.screenshot();
78 });
79
80 it('when open service popup should show template button', function () {
Yoav Schneiderman26034812019-12-03 12:55:39 +020081 cy.getElementByDataTestsId('templateButton').contains('Template')
82 .getElementByDataTestsId('templateButton').click({force: true}) // Open template Modal
83 .getElementByDataTestsId('template-modal-title').contains('Templates') // Check Modal header
84 .getElementByDataTestsId('description-part-1').contains('The following list presents previous instantiations done for this model in this version.')
85 .getElementByDataTestsId('description-part-2').contains('You may use one of them as a baseline for your instantiation or start from scratch.')
86 .getElementByDataTestsId('description-part-3').contains('Once you selecting one allows you to change the data before start instantiating.')
87
88
89 //check table headers
90 cy.get(`#header-userId`).contains('User ID');
91 cy.get(`#header-createDate`).contains('Date');
92 cy.get(`#header-instanceName`).contains('Instance Name');
93 cy.get(`#header-instantiationStatus`).contains('Instantiation Status');
94 cy.get(`#header-region`).contains('Region');
95 cy.get(`#header-tenant`).contains('Tenant');
96 cy.get(`#header-aicZone`).contains('AIC Zone');
97
98 // check table body row
99 cy.getElementByDataTestsId(`userId-${asyncInstantiation[0].jobId}`).contains('16807000');
100 cy.getElementByDataTestsId(`createDate-${asyncInstantiation[0].jobId}`).contains('2018-04-30 11:12:48');
101 cy.getElementByDataTestsId(`instanceName-${asyncInstantiation[0].jobId}`).contains('nWUfl instance name_002');
102 cy.getElementByDataTestsId(`instantiationStatus-${asyncInstantiation[0].jobId}`).contains('FAILED');
103 cy.getElementByDataTestsId(`region-${asyncInstantiation[0].jobId}`).contains('hvf6 (WAYNEHOLLAND)');
104 cy.getElementByDataTestsId(`tenant-${asyncInstantiation[0].jobId}`).contains('AIN Web Tool-15-D-testalexandria');
105 cy.getElementByDataTestsId(`aicZone-${asyncInstantiation[0].jobId}`).contains('NFTJSSSS-NFT1');
106
107
108 //check load button is disabled
109 cy.getElementByDataTestsId('LoadTemplateButton').should('be.disabled')
110 cy.getElementByDataTestsId('row-5c2cd8e5-27d0-42e3-85a1-85db5eaba459').click();
111 cy.getElementByDataTestsId('LoadTemplateButton').should('not.be.disabled')
112
113 });
Sara Weissd6c85042019-12-12 13:45:32 +0200114
115 it('clicking on load template button, go to expected url', function () {
116
117 cy.getElementByDataTestsId('templateButton').contains('Template')
118 .getElementByDataTestsId('templateButton').click({force: true}) // Open template Modal
119
120 const serviceModelId = 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0';
121 const jobId = '5c2cd8e5-27d0-42e3-85a1-85db5eaba459';
122 const vidBaseUrl = `http://localhost:8080/vid/serviceModels.htm`;
123
124 cy.getElementByDataTestsId('row-5c2cd8e5-27d0-42e3-85a1-85db5eaba459').click();
125 cy.getElementByDataTestsId('LoadTemplateButton').click()
126
127 cy.location().should((loc) => {
128 expect(loc.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/RECREATE?serviceModelId=${serviceModelId}&jobId=${jobId}`);
129 });
130 });
131
132
Yoav Schneiderman26034812019-12-03 12:55:39 +0200133});
134