create-with-limit-conn-form.cy.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. context('Create and delete consumer with limit-conn plugin form', () => {
  19. const selector = {
  20. empty: '.ant-empty-normal',
  21. username: '#username',
  22. description: '#desc',
  23. pluginCard: '.ant-card',
  24. drawer: '.ant-drawer-content',
  25. dropdown: '.rc-virtual-list',
  26. disabledSwitcher: '#disable',
  27. notification: '.ant-notification-notice-message',
  28. selectDropdown: '.ant-select-dropdown',
  29. conn: '#conn',
  30. burst: '#burst',
  31. default_conn_delay: '#default_conn_delay',
  32. only_use_default_delay: '#only_use_default_delay',
  33. key: '#key',
  34. rejected_code: '#rejected_code',
  35. monacoViewZones: '.view-zones',
  36. };
  37. const data = {
  38. consumerName: 'test_consumer',
  39. description: 'desc_by_autotest',
  40. createConsumerSuccess: 'Create Consumer Successfully',
  41. deleteConsumerSuccess: 'Delete Consumer Successfully',
  42. conn: 1,
  43. burst: 0,
  44. default_conn_delay: 1,
  45. key: 'remote_addr',
  46. };
  47. beforeEach(() => {
  48. cy.login();
  49. });
  50. it('creates consumer with limit-conn form', function () {
  51. cy.visit('/');
  52. cy.contains('Consumer').click();
  53. cy.get(selector.empty).should('be.visible');
  54. cy.contains('Create').click();
  55. // basic information
  56. cy.get(selector.username).type(data.consumerName);
  57. cy.get(selector.description).type(data.description);
  58. cy.contains('Next').click();
  59. // config auth plugin
  60. cy.contains(selector.pluginCard, 'key-auth').within(() => {
  61. cy.contains('Enable').click({
  62. force: true,
  63. });
  64. });
  65. cy.focused(selector.drawer).should('exist');
  66. cy.get(selector.monacoViewZones).should('exist');
  67. cy.get(selector.disabledSwitcher).click();
  68. // edit monaco
  69. cy.window().then((window) => {
  70. window.monacoEditor.setValue(JSON.stringify({ key: 'test' }));
  71. cy.contains('button', 'Submit').click();
  72. });
  73. cy.contains(selector.pluginCard, 'limit-conn').within(() => {
  74. cy.contains('Enable').click({
  75. force: true,
  76. });
  77. });
  78. cy.focused(selector.drawer).should('exist');
  79. // config limit-conn form
  80. cy.get(selector.conn).type(data.conn);
  81. cy.get(selector.burst).type(data.burst);
  82. cy.get(selector.default_conn_delay).type(data.default_conn_delay);
  83. cy.get(selector.only_use_default_delay).click();
  84. cy.get(selector.key).type(data.key);
  85. cy.get(selector.disabledSwitcher).click();
  86. cy.get(selector.drawer).within(() => {
  87. cy.contains('Submit').click({
  88. force: true,
  89. });
  90. });
  91. cy.get(selector.drawer).should('not.exist');
  92. cy.contains('button', 'Next').click();
  93. cy.contains('button', 'Submit').click();
  94. cy.get(selector.notification).should('contain', data.createConsumerSuccess);
  95. });
  96. it('delete the consumer', function () {
  97. cy.visit('/consumer/list');
  98. cy.contains(data.consumerName).should('be.visible').siblings().contains('Delete').click();
  99. cy.contains('button', 'Confirm').click();
  100. cy.get(selector.notification).should('contain', data.deleteConsumerSuccess);
  101. });
  102. });