blob: a13f4f6e068f7706f987f50068188354833f5b31 [file] [log] [blame]
ys969316a9fce2020-01-19 13:50:02 +02001import { initCommonFixtures } from "../common/init";
2
3
4describe('Test add property to self in service at property assignment page', () => {
5 beforeEach(() => {
6 cy.server();
7 initCommonFixtures(cy);
8 cy.fixture('properties-assignment/onap-user-data').as('onapUserData');
9
10 cy.fixture('service-proxy-tabs/metadata-service-with-service').as('metadata');
11 cy.fixture('service-proxy-tabs/full-data-service-with-service').as('fullData');
12 cy.fixture('properties-assignment/service-include-policies').as('serviceIncludePolicies');
13 cy.fixture('properties-assignment/service-properties').as('serviceProperty');
14 cy.fixture('properties-assignment/service-update-properties').as('serviceUpdateProperty');
Satoshi Fujii407bbef2020-02-26 15:39:38 +090015 cy.fixture('properties-assignment/service-update-inputs').as('serviceUpdateInputs');
ys969316a9fce2020-01-19 13:50:02 +020016 cy.fixture('properties-assignment/service-proxy-properties').as('serviceProxyProperties');
17 cy.fixture('properties-assignment/create-policies').as('createPolicy');
18 cy.fixture('properties-assignment/undeclare-policy').as('undeclarePolicy');
19 //vl
20 cy.fixture('properties-assignment/vl-properties').as('vlProperties');
21 cy.fixture('properties-assignment/vl-list-input').as('vlListInput');
22 cy.fixture('properties-assignment/vl-properties-update').as('vlPropertiesUpdate');
23 });
24
25 it('add property to self, declare policy, create inputs list', function () {
26 cy.route('GET', '**/authorize', '@onapUserData');
27 cy.route('GET', '**/services/*/filteredDataByParams?include=metadata', '@metadata');
28 cy.route('GET', '**/services/*/filteredDataByParams?include=componentInstancesRelations&include=componentInstances&include=nonExcludedPolicies&include=nonExcludedGroups&include=forwardingPaths', '@fullData');
29 cy.route('GET', '**/services/*/filteredDataByParams?include=inputs&include=componentInstances&include=componentInstancesProperties&include=properties','fixture:service-proxy-tabs/full-properties');
30 cy.route('GET','**/services/*/filteredDataByParams?include=componentInstances&include=policies&include=nonExcludedGroups', '@serviceIncludePolicies');
31 cy.route('GET', '**/services/*/properties', '@serviceProperty');
32 cy.route('POST', '**/services/*/properties', '@serviceUpdateProperty');
33 cy.route('GET','**/services/*/componentInstances/*/properties','@serviceProxyProperties');
34 cy.route('POST', '**/services/*/create/policies', '@createPolicy');
35 cy.route('PUT', '**/services/*/policies/*/undeclare','@undeclarePolicy');
36
37 const compositionPageUrl = '#!/dashboard/workspace/' + this.metadata.metadata.uniqueId + '/service/properties_assignment';
38 cy.visit(compositionPageUrl);
39 // Add property to service
40 cy.get('.table-row').should('have.length', 2);
41 cy.get('.add-btn').click();
42 cy.get('[data-tests-id="property-name"]').type('new_property');
43 cy.get('[data-tests-id="value-property-type"]').select('string');
44 cy.get('[data-tests-id="property-description"]').type('new service property');
45 cy.get('[data-tests-id="Save"]').trigger('click', {force: true});
46 cy.get('.table-row').should('have.length', 3);
47 //declare policy for service proxy
48 cy.get('[data-tests-id="childservice_proxy 0"]').trigger('click', {force: true});
49 cy.get('.table-body > :nth-child(2) > .col1').find('[type="checkbox"]').check({force: true});
50 cy.get('[data-tests-id="declare-button declare-policy"]').trigger('click', {force: true});
51 cy.get('[data-tests-id="Policies"]').trigger('click', {force: true});
52 cy.get('.properties-table').contains('contrailv2virtualnetwork0_segmentation_id');
53 cy.get(':nth-child(3) > .valueCol > .delete-button-container > .sprite-new').trigger('click', {force: true});
54 cy.get('[data-tests-id="Delete"]').trigger('click', {force: true});
55 cy.get('.properties-table').contains('contrailv2virtualnetwork0_segmentation_id');
56 cy.wait(100);
57 //create list inputs for vl 0
58 cy.route('GET','**/services/*/componentInstances/*/properties','@vlProperties');
59 cy.route('POST', '**/services/*/create/listInput', '@vlListInput');
60 cy.get('[data-tests-id="Composition"]').trigger('click', {force: true});
61 cy.get('[data-tests-id="Properties"]').trigger('click', {force: true});
62 cy.get('[data-tests-id="VL 0"]').trigger('click', {force: true});
63
64 cy.get('.table-body > :nth-child(5) > .col1').find('[type="checkbox"]').check({force: true});
65 cy.get('.table-body > :nth-child(6) > .col1').find('[type="checkbox"]').check({force: true});
66
67 cy.get('[data-tests-id="declare-button declare-list-input"]').trigger('click', {force: true});
68 cy.get('[data-tests-id="property-name"]').type('vl 0 list');
69 cy.get('input[name="typeName"]').type('new schema');
70 cy.get('[data-tests-id="property-description"]').type('new list for vl 0 properties');
71 cy.get('[data-tests-id="Save"]').trigger('click', {force: true});
72 cy.get('[data-tests-id="Inputs"]').trigger('click', {force: true});
73 cy.get('.properties-table').contains('vl 0 list');
74 });
75
Satoshi Fujii407bbef2020-02-26 15:39:38 +090076 it('update input default value and required in runtime check', function () {
77 const new_value = 'new value';
78 const another_value = 'another';
79 cy.route('GET', '**/authorize', '@onapUserData');
80 cy.route('GET', '**/services/*/filteredDataByParams?include=metadata', '@metadata');
81 cy.route('GET', '**/services/*/filteredDataByParams?include=componentInstancesRelations&include=componentInstances&include=nonExcludedPolicies&include=nonExcludedGroups&include=forwardingPaths', '@fullData');
82 cy.route('GET', '**/services/*/filteredDataByParams?include=inputs&include=componentInstances&include=componentInstancesProperties&include=properties','fixture:service-proxy-tabs/full-properties');
83 cy.route('GET','**/services/*/filteredDataByParams?include=componentInstances&include=policies&include=nonExcludedGroups', '@serviceIncludePolicies');
84 cy.route('GET', '**/services/*/properties', '@serviceProperty');
85 cy.route('POST', '**/services/*/properties', '@serviceUpdateProperty');
86 cy.route('GET','**/services/*/componentInstances/*/properties','@serviceProxyProperties');
87 cy.route('POST', '**/services/*/create/policies', '@createPolicy');
88 cy.route('PUT', '**/services/*/policies/*/undeclare','@undeclarePolicy');
89 cy.route('POST', '**/services/*/update/inputs', '@serviceUpdateInputs');
90
91 const compositionPageUrl = '#!/dashboard/workspace/' + this.metadata.metadata.uniqueId + '/service/properties_assignment';
92 cy.visit(compositionPageUrl);
93
94 // Go to Inputs tab
95 cy.get('[data-tests-id="Inputs"]').trigger('click', {force: true});
96 cy.get('.table-row').should('have.length', 2);
97 cy.get('.properties-table').contains('mac_requirements');
98 cy.get('.table-body .col4 .sdc-checkbox').first().should('have.attr', 'ng-reflect-checked', 'false');
99 cy.get('[data-tests-id="properties-reverse-button"]').should('have.attr', 'disabled');
100 // Change default value
101 cy.get('.table-body .valueCol').first().find('input').type(new_value);
102 cy.get('.table-body .valueCol').first().find('input').should('have.value', new_value);
103 cy.get('[data-tests-id="properties-reverse-button"]').should('not.have.attr', 'disabled');
104 // Check a required-in-runtime checkbox
105 cy.get('.table-body .col4 .sdc-checkbox').first().find('input').click({force: true})
106 cy.get('.table-body .col4 .sdc-checkbox').first().should('have.attr', 'ng-reflect-checked', 'true');
107 cy.get('[data-tests-id="properties-reverse-button"]').should('not.have.attr', 'disabled');
108 // Click Discard button
109 cy.get('[data-tests-id="properties-reverse-button"]').click({force: true});
110 cy.get('.table-body .col4 .sdc-checkbox').first().should('have.attr', 'ng-reflect-checked', 'false');
111 cy.get('.table-body .valueCol').first().find('input').should('have.value', '');
112 // Make changes again and click Save button
113 cy.get('.table-body .valueCol').first().find('input').type(new_value);
114 cy.get('.table-body .col4 .sdc-checkbox').first().find('input').click({force: true})
115 cy.get('[data-tests-id="properties-save-button"]').click({force: true});
116 cy.get('.table-body .valueCol').first().find('input').should('have.value', new_value);
117 cy.get('.table-body .col4 .sdc-checkbox').first().should('have.attr', 'ng-reflect-checked', 'true');
118 // Make changes and try to leave the tab without saving
119 cy.get('.table-body .valueCol').first().find('input').type(another_value);
120 cy.get('.table-body .col4 .sdc-checkbox').first().find('input').click({force: true})
121 cy.get('[data-tests-id="Properties"]').trigger('click', {force: true});
122 cy.get('.sdc-modal .title').should('be.visible');
123 cy.get('.sdc-modal .title').contains('Unsaved inputs');
124 cy.get('.sdc-modal [data-tests-id="navigate-modal-button-discard"]').click({force: true});
125 cy.get('[data-tests-id="Inputs"]').trigger('click', {force: true});
126 cy.get('.table-body .valueCol').first().find('input').should('have.value', new_value);
127 cy.get('.table-body .col4 .sdc-checkbox').first().should('have.attr', 'ng-reflect-checked', 'true');
128 });
ys969316a9fce2020-01-19 13:50:02 +0200129});