|
| 1 | +import { testMode } from '../../../helpers/common'; |
| 2 | + |
| 3 | +import { logMetadataRequests } from './utils/requests/logMetadataRequests'; |
| 4 | +import { addNumbersActionMustNotExist } from './utils/testState/addNumbersActionMustNotExist'; |
| 5 | + |
| 6 | +// NOTE: This test suite does not include cases for relationships, headers and the codegen part |
| 7 | + |
| 8 | +if (testMode !== 'cli') { |
| 9 | + // Temporarily skipped because of its flakiness, see: https://github.com/hasura/graphql-engine-mono/issues/5433 |
| 10 | + // TODO: Fix and restore it |
| 11 | + describe.skip('Query Actions', () => { |
| 12 | + before(() => { |
| 13 | + addNumbersActionMustNotExist(); |
| 14 | + logMetadataRequests(); |
| 15 | + |
| 16 | + cy.visit('/actions/manage/actions'); |
| 17 | + }); |
| 18 | + |
| 19 | + after(() => { |
| 20 | + // Cleanup after the whole test file run |
| 21 | + |
| 22 | + // Ensure the application is not there when manually deleting the created action to avoid any |
| 23 | + // potential client-side error that makes the test fail |
| 24 | + cy.visitEmptyPage(); |
| 25 | + |
| 26 | + // Delete the created action, if any |
| 27 | + addNumbersActionMustNotExist(); |
| 28 | + }); |
| 29 | + |
| 30 | + it('When the users create, edit, and delete a Query Action, everything should work', () => { |
| 31 | + cy.log('**------------------------------**'); |
| 32 | + cy.log('**------------------------------**'); |
| 33 | + cy.log('**------------------------------**'); |
| 34 | + cy.log('**--- Step 1: Query Action creation**'); |
| 35 | + cy.log('**------------------------------**'); |
| 36 | + cy.log('**------------------------------**'); |
| 37 | + cy.log('**------------------------------**'); |
| 38 | + |
| 39 | + // -------------------- |
| 40 | + cy.log('**--- Click on the Create button of the Actions panel**'); |
| 41 | + cy.getBySel('data-create-actions').click(); |
| 42 | + |
| 43 | + // -------------------- |
| 44 | + // Assign an alias to the most unclear selectors for future references |
| 45 | + cy.get('textarea').eq(0).as('actionDefinitionTextarea'); |
| 46 | + cy.get('textarea').eq(1).as('typeConfigurationTextarea'); |
| 47 | + |
| 48 | + // -------------------- |
| 49 | + cy.log('**--- Type in the Action Definition textarea**'); |
| 50 | + cy.get('@actionDefinitionTextarea') |
| 51 | + .clearConsoleTextarea() |
| 52 | + .type( |
| 53 | + `type Query { |
| 54 | + addNumbers (numbers: [Int]): AddResult |
| 55 | + }`, |
| 56 | + { force: true, delay: 0 } |
| 57 | + ); |
| 58 | + |
| 59 | + // -------------------- |
| 60 | + cy.log('**--- Type in the Type Configuration textarea**'); |
| 61 | + cy.get('@typeConfigurationTextarea') |
| 62 | + .clearConsoleTextarea() |
| 63 | + .type( |
| 64 | + `type AddResult { |
| 65 | + sum: Int |
| 66 | + }`, |
| 67 | + { force: true, delay: 0 } |
| 68 | + ); |
| 69 | + |
| 70 | + // -------------------- |
| 71 | + cy.log('**--- Type in the Webhook Handler field**'); |
| 72 | + cy.getBySel('action-create-handler-input') |
| 73 | + .clearConsoleTextarea() |
| 74 | + .type('https://hasura-actions-demo.glitch.me/addNumbers', { |
| 75 | + delay: 0, |
| 76 | + parseSpecialCharSequences: false, |
| 77 | + }); |
| 78 | + |
| 79 | + // Due to the double server/cli mode behavior, we do not assert about the XHR request payload here |
| 80 | + |
| 81 | + // -------------------- |
| 82 | + cy.log('**--- Click the Create button**'); |
| 83 | + cy.getBySel('create-action-btn').click(); |
| 84 | + |
| 85 | + // Due to the double server/cli mode behavior, we do not assert about the XHR request payload here |
| 86 | + |
| 87 | + // -------------------- |
| 88 | + cy.log('**--- Check if the success notification is visible**'); |
| 89 | + cy.expectSuccessNotificationWithTitle('Created action successfully'); |
| 90 | + |
| 91 | + cy.log('**------------------------------**'); |
| 92 | + cy.log('**------------------------------**'); |
| 93 | + cy.log('**------------------------------**'); |
| 94 | + cy.log('**--- Step 2: Permission add and Handler change**'); |
| 95 | + cy.log('**------------------------------**'); |
| 96 | + cy.log('**------------------------------**'); |
| 97 | + cy.log('**------------------------------**'); |
| 98 | + |
| 99 | + // -------------------- |
| 100 | + |
| 101 | + cy.log('**--- Go the the action page**'); |
| 102 | + cy.getBySel('actions-table-links').within(() => { |
| 103 | + cy.getBySel('addNumbers').click(); |
| 104 | + }); |
| 105 | + |
| 106 | + // -------------------- |
| 107 | + cy.log('**--- Type in the Webhook Handler field**'); |
| 108 | + cy.getBySel('action-create-handler-input') |
| 109 | + .clearConsoleTextarea() |
| 110 | + .type('http://host.docker.internal:3000', { |
| 111 | + delay: 0, |
| 112 | + // parseSpecialCharSequences: false, |
| 113 | + }); |
| 114 | + |
| 115 | + // -------------------- |
| 116 | + cy.log('**--- Click on the Save button**'); |
| 117 | + cy.getBySel('save-modify-action-changes').click(); |
| 118 | + |
| 119 | + // -------------------- |
| 120 | + cy.log('**--- Click the Permissions tab**'); |
| 121 | + cy.getBySel('actions-permissions').click(); |
| 122 | + |
| 123 | + // -------------------- |
| 124 | + cy.log('**--- Enter a new role**'); |
| 125 | + cy.getBySel('role-textbox').type('manager'); |
| 126 | + cy.getBySel('manager-Permission').click(); |
| 127 | + |
| 128 | + // -------------------- |
| 129 | + cy.log('**--- Click Save Permissions**'); |
| 130 | + cy.getBySel('save-permissions-for-action').click(); |
| 131 | + |
| 132 | + // -------------------- |
| 133 | + cy.log('**--- Check if the success notification is visible**'); |
| 134 | + cy.expectSuccessNotificationWithTitle('Permission saved successfully'); |
| 135 | + |
| 136 | + cy.log('**------------------------------**'); |
| 137 | + cy.log('**------------------------------**'); |
| 138 | + cy.log('**------------------------------**'); |
| 139 | + cy.log('**--- Step 3: Query Action delete**'); |
| 140 | + cy.log('**------------------------------**'); |
| 141 | + cy.log('**------------------------------**'); |
| 142 | + cy.log('**------------------------------**'); |
| 143 | + |
| 144 | + // -------------------- |
| 145 | + cy.log('**--- Go the the action page**'); |
| 146 | + cy.getBySel('actions-table-links').within(() => { |
| 147 | + cy.getBySel('addNumbers').click(); |
| 148 | + }); |
| 149 | + |
| 150 | + // -------------------- |
| 151 | + cy.log('**--- Set the prompt value**'); |
| 152 | + cy.window().then(win => cy.stub(win, 'prompt').returns('addNumbers')); |
| 153 | + |
| 154 | + cy.log('**--- Click the Delete button**'); |
| 155 | + cy.getBySel('delete-action').click(); |
| 156 | + |
| 157 | + // Due to the double server/cli mode behavior, we do not assert about the XHR request payload here |
| 158 | + |
| 159 | + // -------------------- |
| 160 | + cy.log('**--- Check if the success notification is visible**'); |
| 161 | + cy.expectSuccessNotificationWithTitle('Action deleted successfully'); |
| 162 | + }); |
| 163 | + }); |
| 164 | +} |
0 commit comments