liuxiran commented on a change in pull request #1710:
URL: https://github.com/apache/apisix-dashboard/pull/1710#discussion_r618901666
##########
File path:
web/cypress/integration/consumer/create-edit-duplicate-and-delete-consumer.spec.js
##########
@@ -58,6 +58,70 @@ context('Create and Delete Consumer', () => {
cy.get(this.domSelector.notification).should('contain',
this.data.createConsumerSuccess);
});
+ it('should edit the consumer', function () {
+ cy.visit('/consumer/list');
+
+ cy.contains('Search').click();
+ cy.get(this.domSelector.nameSelector).type(this.data.consumerName);
+
cy.contains(this.data.consumerName).siblings().contains('Configure').click();
+ cy.get(this.domSelector.description).clear().type(this.data.description2);
+ cy.contains('button', 'Next').click();
+ // plugin config
+ cy.contains(this.domSelector.pluginCard, 'key-auth').within(() => {
+ cy.contains('Enable').click({
+ force: true,
+ });
+ });
+ cy.focused(this.domSelector.drawer).should('exist');
+ // edit codemirror
+ cy.get(this.domSelector.codeMirror)
+ .first()
+ .then((editor) => {
+ editor[0].CodeMirror.setValue(
+ JSON.stringify({
+ key: 'test',
+ }),
+ );
+ cy.contains('button', 'Submit').click();
+ });
+ cy.contains('button', 'Next').click();
+ cy.contains('button', 'Submit').click();
+ cy.get(this.domSelector.notification).should('contain',
this.data.updateConsumerSuccess);
+
+ });
+
+ it('should duplicate the consumer', function () {
+ cy.visit('/consumer/list');
+
+ cy.contains('Search').click();
+ cy.get(this.domSelector.nameSelector).type(this.data.consumerName);
+
cy.contains(this.data.consumerName).siblings().contains('Duplicate').click();
+ cy.get(this.domSelector.username).type(this.data.consumerName2);
Review comment:
it would be better to add a assert about default username is empty when
duplicate a consumer.
##########
File path: web/src/pages/Upstream/locales/zh-CN.ts
##########
@@ -88,6 +88,7 @@ export default {
'page.upstream.list.edit.time': '更新时间',
'page.upstream.list.operation': '操作',
'page.upstream.list.edit': '配置',
+ 'page.upstream.list.duplicate': '复制',
Review comment:
we already have a global i18n key `component.global.duplicate` for
duplicate button, it would be better to reuse it
##########
File path:
web/cypress/integration/service/create-edit-duplicate-delete-service.spec.js
##########
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/* eslint-disable no-undef */
+
+context('Create and Delete Service ', () => {
+ const timeout = 5000;
+
+ beforeEach(() => {
+ cy.login();
+
+ cy.fixture('selector.json').as('domSelector');
+ cy.fixture('data.json').as('data');
+ });
+
+ it('should create service', function () {
+ cy.visit('/');
+ cy.contains('Service').click();
+ cy.contains('Create').click();
+
+ cy.get(this.domSelector.name).type(this.data.serviceName);
+ cy.get(this.domSelector.description).type(this.data.description);
+ cy.get(this.domSelector.nodes_0_host).click();
+ cy.get(this.domSelector.nodes_0_host).type(this.data.ip1);
+
+ cy.contains('Next').click();
+
+
cy.contains(this.data.basicAuthPlugin).parents(this.domSelector.pluginCardBordered).within(()
=> {
+ cy.get('button').click({ force: true });
+ });
+
+ cy.get(this.domSelector.drawer).should('be.visible').within(() => {
+ cy.get(this.domSelector.disabledSwitcher).click();
+ cy.get(this.domSelector.checkedSwitcher).should('exist');
+ });
+
+ cy.contains('button', 'Submit').click();
+ cy.get(this.domSelector.drawer, { timeout }).should('not.exist');
+
+
cy.contains(this.data.basicAuthPlugin).parents(this.domSelector.pluginCardBordered).within(()
=> {
+ cy.get('button').click({ force: true });
+ });
+
+ cy.get(this.domSelector.drawerFooter).contains('button', 'Delete').click({
force: true });
+ cy.contains('button', 'Confirm').click({ force: true });
+
+
cy.contains(this.data.basicAuthPlugin).parents(this.domSelector.pluginCardBordered).within(()
=> {
+ cy.get('button').click({ force: true });
+ });
+
+ cy.get(this.domSelector.drawerFooter).contains('button',
'Delete').should('not.exist');
+ cy.contains('button', 'Cancel').click({ force: true });
+
+ cy.contains('Next').click();
+ cy.contains('Submit').click();
+ cy.get(this.domSelector.notification).should('contain',
this.data.createServiceSuccess);
+ });
+
+ it('should view the service', function () {
+ cy.visit('/');
+ cy.contains('Service').click();
+
+ cy.get(this.domSelector.nameSelector).type(this.data.serviceName);
+ cy.contains('Search').click();
+ cy.contains(this.data.serviceName).siblings().contains('View').click();
+ cy.get(this.domSelector.drawer).should('be.visible');
+
+ cy.get(this.domSelector.codemirrorScroll).within(() => {
+ cy.contains('upstream').should('exist');
+ cy.contains(this.data.serviceName).should('exist');
+ });
+ });
+
+ it('should edit the service', function () {
+ cy.visit('/');
+ cy.contains('Service').click();
+
+ cy.get(this.domSelector.nameSelector).type(this.data.serviceName);
+ cy.contains('Search').click();
+
cy.contains(this.data.serviceName).siblings().contains('Configure').click();
+
+ // Confirm whether the created data is saved.
+ cy.get(this.domSelector.nodes_0_host).should('value', this.data.ip1);
+ cy.get(this.domSelector.description).should('value',
this.data.description);
+ cy.get(this.domSelector.name).clear().type(this.data.serviceName2);
+ cy.get(this.domSelector.description).clear().type(this.data.description2);
+ cy.get(this.domSelector.nodes_0_host).click();
+ cy.get(this.domSelector.nodes_0_host).clear().type(this.data.ip2);
+ cy.contains('Next').click();
+ cy.contains('Next').click();
+ cy.contains('Submit').click();
+ cy.get(this.domSelector.notification).should('contain',
this.data.editServiceSuccess);
+
+ // test view
+ cy.contains(this.data.serviceName2).siblings().contains('View').click();
+ cy.get(this.domSelector.drawer).should('be.visible');
+
+ cy.get(this.domSelector.codemirrorScroll).within(() => {
+ cy.contains('upstream').should('exist');
+ cy.contains(this.data.serviceName2).should('exist');
+ });
+ });
+
+ it('should duplicate the service', function () {
+ cy.visit('/');
+ cy.contains('Service').click();
+
+ cy.get(this.domSelector.nameSelector).type(this.data.serviceName2);
+ cy.contains('Search').click();
+
cy.contains(this.data.serviceName2).siblings().contains('Duplicate').click();
+ cy.get(this.domSelector.name).clear().type(this.data.serviceName3);
Review comment:
it would be better to assert about default service name is empty when
duplicate a service.
##########
File path:
web/cypress/integration/consumer/create-edit-duplicate-and-delete-consumer.spec.js
##########
@@ -58,6 +58,70 @@ context('Create and Delete Consumer', () => {
cy.get(this.domSelector.notification).should('contain',
this.data.createConsumerSuccess);
});
+ it('should edit the consumer', function () {
+ cy.visit('/consumer/list');
+
+ cy.contains('Search').click();
+ cy.get(this.domSelector.nameSelector).type(this.data.consumerName);
+
cy.contains(this.data.consumerName).siblings().contains('Configure').click();
+ cy.get(this.domSelector.description).clear().type(this.data.description2);
+ cy.contains('button', 'Next').click();
+ // plugin config
+ cy.contains(this.domSelector.pluginCard, 'key-auth').within(() => {
+ cy.contains('Enable').click({
+ force: true,
+ });
+ });
+ cy.focused(this.domSelector.drawer).should('exist');
+ // edit codemirror
+ cy.get(this.domSelector.codeMirror)
+ .first()
+ .then((editor) => {
+ editor[0].CodeMirror.setValue(
+ JSON.stringify({
+ key: 'test',
+ }),
+ );
+ cy.contains('button', 'Submit').click();
+ });
+ cy.contains('button', 'Next').click();
+ cy.contains('button', 'Submit').click();
+ cy.get(this.domSelector.notification).should('contain',
this.data.updateConsumerSuccess);
+
+ });
+
+ it('should duplicate the consumer', function () {
+ cy.visit('/consumer/list');
+
+ cy.contains('Search').click();
+ cy.get(this.domSelector.nameSelector).type(this.data.consumerName);
+
cy.contains(this.data.consumerName).siblings().contains('Duplicate').click();
+ cy.get(this.domSelector.username).type(this.data.consumerName2);
+ cy.contains('button', 'Next').click();
+ // plugin config
+ cy.contains(this.domSelector.pluginCard, 'key-auth').within(() => {
+ cy.contains('Enable').click({
+ force: true,
+ });
+ });
+ cy.focused(this.domSelector.drawer).should('exist');
+ // edit codemirror
+ cy.get(this.domSelector.codeMirror)
Review comment:
it would be better to add assert about the default `key-auth` setting is
the same with the original one when duplicate a consumer
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]