2
0

create-with-referer-restriction-form.cy.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 referer-restriction 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. whitelist: '#whitelist_0',
  29. bypass_missing: '#bypass_missing',
  30. monacoViewZones: '.view-zones',
  31. };
  32. const data = {
  33. consumerName: 'test_consumer',
  34. description: 'desc_by_autotest',
  35. createConsumerSuccess: 'Create Consumer Successfully',
  36. deleteConsumerSuccess: 'Delete Consumer Successfully',
  37. whitelist: 'yy.com',
  38. };
  39. beforeEach(() => {
  40. cy.login();
  41. });
  42. it('creates consumer with referer-restriction form', function () {
  43. cy.visit('/');
  44. cy.contains('Consumer').click();
  45. cy.get(selector.empty).should('be.visible');
  46. cy.contains('Create').click();
  47. // basic information
  48. cy.get(selector.username).type(data.consumerName);
  49. cy.get(selector.description).type(data.description);
  50. cy.contains('Next').click();
  51. // config auth plugin
  52. cy.contains(selector.pluginCard, 'key-auth').within(() => {
  53. cy.contains('Enable').click({
  54. force: true,
  55. });
  56. });
  57. cy.focused(selector.drawer).should('exist');
  58. cy.get(selector.monacoViewZones).should('exist');
  59. cy.get(selector.disabledSwitcher).click();
  60. // edit monaco
  61. cy.window().then((window) => {
  62. window.monacoEditor.setValue(JSON.stringify({ key: 'test' }));
  63. cy.contains('button', 'Submit').click();
  64. });
  65. cy.contains(selector.pluginCard, 'referer-restriction').within(() => {
  66. cy.contains('Enable').click({
  67. force: true,
  68. });
  69. });
  70. cy.focused(selector.drawer).should('exist');
  71. // config referer-restriction form
  72. cy.get(selector.whitelist).type(data.whitelist);
  73. cy.get(selector.bypass_missing).click();
  74. cy.get(selector.drawer).within(() => {
  75. cy.contains('Submit').click({
  76. force: true,
  77. });
  78. });
  79. cy.get(selector.drawer).should('not.exist');
  80. cy.contains('button', 'Next').click();
  81. cy.contains('button', 'Submit').click();
  82. cy.get(selector.notification).should('contain', data.createConsumerSuccess);
  83. });
  84. it('delete the consumer', function () {
  85. cy.visit('/consumer/list');
  86. cy.contains(data.consumerName).should('be.visible').siblings().contains('Delete').click();
  87. cy.contains('button', 'Confirm').click();
  88. cy.get(selector.notification).should('contain', data.deleteConsumerSuccess);
  89. });
  90. });