|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +/* eslint-disable no-undef */ |
| 18 | + |
| 19 | +context('Create Route with advanced matching conditions', () => { |
| 20 | + const selector = { |
| 21 | + name: '#name', |
| 22 | + nodes_0_host: '#nodes_0_host', |
| 23 | + nodes_0_port: '#nodes_0_port', |
| 24 | + nodes_0_weight: '#nodes_0_weight', |
| 25 | + deleteAlert: '.ant-modal-body', |
| 26 | + notificationCloseIcon: '.ant-notification-close-icon', |
| 27 | + notification: '.ant-notification-notice-message', |
| 28 | + parameterPosition: '#position', |
| 29 | + ruleCard: '.ant-modal', |
| 30 | + operator: '#operator', |
| 31 | + value: '#value', |
| 32 | + advancedMatchingTable: '.ant-table-row.ant-table-row-level-0', |
| 33 | + advancedMatchingTableOperation: '.ant-space', |
| 34 | + advancedMatchingTableCell: '.ant-table-cell', |
| 35 | + }; |
| 36 | + |
| 37 | + const data = { |
| 38 | + routeName: `test_route_${new Date().valueOf()}`, |
| 39 | + submitSuccess: 'Submit Successfully', |
| 40 | + ip1: '127.0.0.1', |
| 41 | + port: '80', |
| 42 | + weight: 1, |
| 43 | + matchingParamName: 'server_port', |
| 44 | + deleteRouteSuccess: 'Delete Route Successfully', |
| 45 | + }; |
| 46 | + |
| 47 | + const opreatorList = [ |
| 48 | + // 'Equal(==)' : '1234', |
| 49 | + 'Unequal(~=)', |
| 50 | + 'Greater Than(>)', |
| 51 | + 'Less Than(<)', |
| 52 | + // 'Regex Match(~~)', |
| 53 | + 'IN', |
| 54 | + ]; |
| 55 | + |
| 56 | + const matchingValueList1 = ['1000', '800', '2000', '["1800","1888"]']; |
| 57 | + |
| 58 | + const matchingValueList2 = ['2000', '1800', '3000', '["2800","2888"]']; |
| 59 | + |
| 60 | + beforeEach(() => { |
| 61 | + cy.login(); |
| 62 | + }); |
| 63 | + |
| 64 | + it('should create route with advanced matching conditions', function () { |
| 65 | + cy.visit('/routes/list'); |
| 66 | + cy.contains('Create').click(); |
| 67 | + cy.contains('Next').click().click(); |
| 68 | + cy.get(selector.name).type(data.routeName); |
| 69 | + |
| 70 | + // All Of Operational Character Should Exist And Can be Created |
| 71 | + cy.wrap(opreatorList).each((opreator, index) => { |
| 72 | + cy.contains('Advanced Routing Matching Conditions') |
| 73 | + .parent() |
| 74 | + .siblings() |
| 75 | + .contains('Add') |
| 76 | + .click() |
| 77 | + .then(() => { |
| 78 | + cy.get(selector.parameterPosition) |
| 79 | + .click() |
| 80 | + .then(() => { |
| 81 | + cy.get('.ant-select-dropdown').within(() => { |
| 82 | + cy.contains('Build-in').should('be.visible').click(); |
| 83 | + }); |
| 84 | + }); |
| 85 | + cy.get(selector.ruleCard).within(() => { |
| 86 | + cy.get(selector.name).type(data.matchingParamName); |
| 87 | + }); |
| 88 | + cy.get(selector.operator).click(); |
| 89 | + cy.get(`[title="${opreator}"]`).should('be.visible').click(); |
| 90 | + cy.get(selector.value).type(matchingValueList1[index]); |
| 91 | + cy.contains('Confirm').click(); |
| 92 | + }); |
| 93 | + }); |
| 94 | + cy.get(selector.advancedMatchingTable).should('exist'); |
| 95 | + cy.wrap(opreatorList).each((operator, index) => { |
| 96 | + cy.get(selector.advancedMatchingTableCell).within(() => { |
| 97 | + cy.contains('td', 'Build-in Parameter').should('be.visible'); |
| 98 | + cy.contains('td', data.matchingParamName).should('be.visible'); |
| 99 | + cy.contains('td', matchingValueList1[index]).should('be.visible'); |
| 100 | + }); |
| 101 | + }); |
| 102 | + cy.contains('Next').click(); |
| 103 | + cy.get(selector.nodes_0_host).clear().type(data.ip1); |
| 104 | + cy.get(selector.nodes_0_port).type(data.port); |
| 105 | + cy.get(selector.nodes_0_weight).type(data.weight); |
| 106 | + cy.contains('Next').click(); |
| 107 | + cy.contains('Next').click(); |
| 108 | + cy.contains('Submit').click(); |
| 109 | + cy.contains(data.submitSuccess).should('be.visible'); |
| 110 | + cy.contains('Goto List').click(); |
| 111 | + cy.url().should('contains', 'routes/list'); |
| 112 | + }); |
| 113 | + |
| 114 | + it('should edit this route matching conditions', function () { |
| 115 | + cy.visit('/routes/list'); |
| 116 | + cy.get(selector.name).clear().type(data.routeName); |
| 117 | + cy.contains('Search').click(); |
| 118 | + cy.contains(data.routeName).siblings().contains('Configure').click(); |
| 119 | + cy.get(selector.advancedMatchingTable).should('exist'); |
| 120 | + cy.wrap(opreatorList).each((opreator, index) => { |
| 121 | + cy.get(selector.advancedMatchingTableCell).within(() => { |
| 122 | + cy.contains(`${opreator}`) |
| 123 | + .parent('tr') |
| 124 | + .within(() => { |
| 125 | + cy.get(selector.advancedMatchingTableOperation).within(() => { |
| 126 | + cy.contains('Configure').click(); |
| 127 | + }); |
| 128 | + }); |
| 129 | + }); |
| 130 | + cy.get(selector.ruleCard).within(() => { |
| 131 | + cy.get(`[title="Build-in Parameter"]`).should('have.class', 'ant-select-selection-item'); |
| 132 | + cy.get(selector.name).clear().type(data.matchingParamName); |
| 133 | + cy.get(`[title="${opreator}"]`).should('have.class', 'ant-select-selection-item'); |
| 134 | + cy.get(selector.value).clear().type(matchingValueList2[index]); |
| 135 | + cy.contains('Confirm').click(); |
| 136 | + }); |
| 137 | + cy.get(selector.advancedMatchingTableCell).within(() => { |
| 138 | + cy.contains('td', 'Build-in Parameter').should('be.visible'); |
| 139 | + cy.contains('td', data.matchingParamName).should('be.visible'); |
| 140 | + cy.contains('td', matchingValueList2[index]).should('be.visible'); |
| 141 | + }); |
| 142 | + }); |
| 143 | + cy.contains('Next').click(); |
| 144 | + cy.get(selector.nodes_0_port).focus(); |
| 145 | + cy.contains('Next').click(); |
| 146 | + cy.contains('Next').click(); |
| 147 | + cy.contains('Submit').click(); |
| 148 | + cy.contains(data.submitSuccess); |
| 149 | + cy.contains('Goto List').click(); |
| 150 | + cy.url().should('contains', 'routes/list'); |
| 151 | + }); |
| 152 | + |
| 153 | + it('should delete route matching conditions', function () { |
| 154 | + cy.visit('/routes/list'); |
| 155 | + cy.get(selector.name).clear().type(data.routeName); |
| 156 | + cy.contains('Search').click(); |
| 157 | + cy.contains(data.routeName).siblings().contains('Configure').click(); |
| 158 | + cy.get(selector.name).should('value', data.routeName); |
| 159 | + cy.get(selector.advancedMatchingTable).should('exist'); |
| 160 | + cy.wrap(opreatorList).each(() => { |
| 161 | + cy.get(selector.advancedMatchingTableOperation).within(() => { |
| 162 | + cy.contains('Delete').click().should('not.exist'); |
| 163 | + }); |
| 164 | + }); |
| 165 | + cy.get(selector.advancedMatchingTable).should('not.exist'); |
| 166 | + cy.contains('Next').click(); |
| 167 | + cy.get(selector.nodes_0_port).focus(); |
| 168 | + cy.contains('Next').click(); |
| 169 | + cy.contains('Next').click(); |
| 170 | + cy.contains('Submit').click(); |
| 171 | + cy.contains(data.submitSuccess); |
| 172 | + cy.contains('Goto List').click(); |
| 173 | + cy.url().should('contains', 'routes/list'); |
| 174 | + |
| 175 | + cy.visit('/routes/list'); |
| 176 | + cy.get(selector.name).clear().type(data.routeName); |
| 177 | + cy.contains('Search').click(); |
| 178 | + cy.contains(data.routeName).siblings().contains('More').click(); |
| 179 | + cy.contains('Delete').click(); |
| 180 | + cy.get(selector.deleteAlert) |
| 181 | + .should('be.visible') |
| 182 | + .within(() => { |
| 183 | + cy.contains('OK').click(); |
| 184 | + }); |
| 185 | + cy.get(selector.notification).should('contain', data.deleteRouteSuccess); |
| 186 | + cy.get(selector.notificationCloseIcon).click(); |
| 187 | + }); |
| 188 | +}); |
0 commit comments