templates button - rename from hasTemplates to isInstantiationTemplateExists on the...
[vid.git] / vid-webpack-master / cypress / integration / iFrames / service.popup.e2e.ts
1 ///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
2 describe('Service popup', function () {
3   describe('basic UI tests', () => {
4
5     beforeEach(() => {
6         cy.clearSessionStorage();
7         cy.setReduxState();
8         cy.preventErrorsOnLoading();
9         cy.initAAIMock();
10         cy.initVidMock();
11         cy.login();
12     });
13
14     afterEach(() => {
15       cy.screenshot();
16     });
17
18     it('a-la-carte service instantiation popup has all required fields ', function () {
19       cy.readFile('cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((res1) => {
20         res1.service.serviceHierarchy["2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"].service.vidNotions.instantiationType = 'ALaCarte';
21         cy.setReduxState(<any>res1);
22         cy.openPopupIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true');
23         cy.isElementContainsAttr('form-set', 'disabled');
24         cy.get('label').contains('Instance name:').should('not.have.class', 'required')
25           .get('label').contains('Subscriber name:').should('have.class', 'required')
26           .get('label').contains('Service type:').should('have.class', 'required')
27           .get('label').contains('Owning entity:').should('have.class', 'required')
28           .get('label').contains('Project').should('not.have.class', 'required')
29           .get('label').contains('Rollback on failure').should('have.class', 'required');
30       });
31     });
32
33     it('a-la-carte service instantiation popup should show Template button ', function () {
34       cy.readFile('cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((res1) => {
35         res1.service.serviceHierarchy["2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"].service.vidNotions.instantiationType = 'ALaCarte';
36         res1.global.flags = {};
37         res1.global.flags["FLAG_2004_INSTANTIATION_TEMPLATES_POPUP"] = true;
38         cy.setReduxState(<any>res1);
39         cy.openPopupIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true&isInstantiationTemplateExists=true');
40         cy.getElementByDataTestsId('templateButton').should('be.visible')
41       });
42     });
43
44     it('a-la-carte service instantiation popup has Instance name as required', function () {
45       cy.readFile('cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((res1) => {
46         res1.service.serviceHierarchy["2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"].service.vidNotions.instantiationType = 'ALaCarte';
47         let isEcompNaming = false;
48         res1.service.serviceHierarchy["2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"].service.serviceEcompNaming = isEcompNaming.toString();
49         cy.setReduxState(<any>res1);
50         cy.openPopupIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true');
51         cy.isElementContainsAttr('form-set', 'disabled');
52         cy.get('label').contains('Instance name:').should('have.class', 'required');
53         cy.getElementByDataTestsId('templateButton').should('not.be.visible')
54       });
55     });
56
57     it('should contains basic selects with required astrix', function () {
58       cy.openPopupIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true');
59       cy.isElementContainsAttr('form-set', 'disabled');
60       cy.get('label').contains('Subscriber name:').should('have.class', 'required')
61         .get('label').contains('Service type:').should('have.class', 'required')
62         .get('label').contains('LCP region:').should('have.class', 'required')
63         .get('label').contains('Tenant:').should('have.class', 'required')
64         .get('label').contains('Owning entity:').should('have.class', 'required')
65         .get('label').contains('Product family:').should('have.class', 'required')
66         .get('label').contains('AIC zone:').should('not.have.class', 'required')
67         .get('label').contains('Project').should('not.have.class', 'required')
68         .get('label').contains('Rollback on failure').should('have.class', 'required');
69     });
70
71     it('should be able fill all selects', function () {
72       cy.openPopupIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true');
73
74       cy.selectDropdownOptionByText('subscriberName', 'SILVIA ROBBINS');
75       cy.selectDropdownOptionByText('serviceType', 'TYLER SILVIA');
76       cy.selectDropdownOptionByText('productFamily', 'TYLER SILVIA');
77       cy.selectDropdownOptionByText('lcpRegion', 'hvf6');
78       cy.selectDropdownOptionByText('tenant', 'AIN Web Tool-15-D-testalexandria');
79       cy.selectDropdownOptionByText('aic_zone', 'NFTJSSSS-NFT1');
80       cy.selectDropdownOptionByText('project', 'WATKINS');
81       cy.selectDropdownOptionByText('owningEntity', 'aaa1');
82       cy.selectDropdownOptionByText('rollback', 'Rollback');
83
84     });
85
86     it('should display error when api return empty data', function () {
87       cy.initCategoryParameter(<any>{});
88       cy.readFile('cypress/support/jsonBuilders/mocks/jsons/emptyServiceRedux.json').then((res1) => {
89         res1.service.categoryParameters.owningEntityList = [];
90         cy.setReduxState(<any>res1);
91         cy.openPopupIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true');
92
93         cy.get('.message').contains('No results for this request. Please change criteria.');
94         cy.get('form-general-error').contains('Page contains errors. Please see details next to the relevant fields.');
95       });
96     });
97
98     it('when open service popup should show showPrevious button', () => {
99       cy.openPopupIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true');
100       cy.getElementByDataTestsId('ShowPreviousInstancesButton').contains('Previous Instantiation').click();
101
102     })
103
104
105   });
106 });
107