From 9e65da5429baf5e6b078e6f618055efe149852d7 Mon Sep 17 00:00:00 2001 From: Varun Choudhary <68095256+Varun-Choudhary@users.noreply.github.com> Date: Wed, 3 May 2023 16:33:52 +0530 Subject: [PATCH] console: : e2e testing for one-off scheduled triggers This PR adds e2e testing for one-off scheduled triggers. PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8965 GitOrigin-RevId: e2416376d8d5b7c339e32b232d657a5611158069 --- .../scheduled-event.test.ts | 101 ++++++++++++++++++ .../Common/FilterQuery/FilterQuery.tsx | 2 +- .../components/Common/FilterQuery/state.ts | 9 +- 3 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 frontend/apps/console-ce-e2e/src/e2e/one-off-scheduled-triggers/scheduled-event.test.ts diff --git a/frontend/apps/console-ce-e2e/src/e2e/one-off-scheduled-triggers/scheduled-event.test.ts b/frontend/apps/console-ce-e2e/src/e2e/one-off-scheduled-triggers/scheduled-event.test.ts new file mode 100644 index 00000000000..ed9e17a3f0a --- /dev/null +++ b/frontend/apps/console-ce-e2e/src/e2e/one-off-scheduled-triggers/scheduled-event.test.ts @@ -0,0 +1,101 @@ +describe('Create Scheduled trigger', () => { + it('with longest path everything should work', () => { + cy.log('**------------------------------**'); + cy.log('**------------------------------**'); + cy.log('**------------------------------**'); + cy.log('**--- Step 1: Create an Scheduled trigger with longest path**'); + cy.log('**------------------------------**'); + cy.log('**------------------------------**'); + cy.log('**------------------------------**'); + + cy.visit('/events/one-off-scheduled-events/add', { + timeout: 10000, + }); + + // add webhook url + cy.log('**--- Add webhook url'); + cy.get('[name=webhook]').type('http://httpbin.org/post'); + + // add scheduled time + cy.log('**--- Add scheduled time'); + cy.get('.rdt').click(); + cy.get('.rdtNext').click(); + cy.get('.rdtDays').find('td').eq(1).click(); + + // add payload + cy.log('**--- Add request payload'); + cy.get('.ace_content').type('{{}"name":"json_payload"}'); + + // Add headers + cy.log('**--- Add headers'); + cy.findByText('Advance Settings').click(); + cy.findAllByRole('button', { name: 'Add request headers' }).click(); + cy.findByPlaceholderText('Key...').type('user_id'); + cy.findByPlaceholderText('Value...').type('1234'); + + // Add headers retry config + cy.log('**--- Add headers'); + cy.findByText('Retry Configuration').click(); + cy.get('[name=num_retries]').clear().type('3'); + cy.get('[name=retry_interval_seconds]').clear().type('20'); + cy.get('[name=timeout_seconds]').clear().type('80'); + + // click on create button to save scheduled trigger + cy.log('**--- Click on Create scheduled event'); + cy.findAllByRole('button', { name: 'Create scheduled event' }).click(); + + // expect success notification + cy.log('**--- Expect success notification'); + cy.expectSuccessNotificationWithMessage('Event scheduled successfully'); + + cy.visit('/events/one-off-scheduled-events/pending', { + timeout: 10000, + }); + + // expect scheduled event in pending events table + cy.get('[data-test=event-filter-table').should('exist'); + cy.get('[data-test=event-filter-table') + .find('.rt-tbody') + .within(() => { + cy.get('div').should('have.length', 13); + }); + }); + it('with shortest path everything should work', () => { + cy.log('**------------------------------**'); + cy.log('**------------------------------**'); + cy.log('**------------------------------**'); + cy.log('**--- Step 1: Create an Scheduled trigger with shortest path**'); + cy.log('**------------------------------**'); + cy.log('**------------------------------**'); + cy.log('**------------------------------**'); + + cy.visit('/events/one-off-scheduled-events/add', { + timeout: 10000, + }); + + // add webhook url + cy.log('**--- Add webhook url'); + cy.get('[name=webhook]').type('http://httpbin.org/post'); + + // add payload + cy.log('**--- Add request payload'); + cy.get('.ace_content').type('{{}"name":"json_payload"}'); + + // click on create button to save scheduled trigger + cy.log('**--- Click on Create scheduled event'); + cy.findAllByRole('button', { name: 'Create scheduled event' }).click(); + + // expect success notification + cy.log('**--- Expect success notification'); + cy.expectSuccessNotificationWithMessage('Event scheduled successfully'); + + // expect scheduled event in pending events table + cy.get('[data-test=event-filter-table').should('exist'); + + cy.get('[data-test=event-filter-table') + .find('.rt-tbody') + .within(() => { + cy.get('div').should('have.length', 26); + }); + }); +}); diff --git a/frontend/libs/console/legacy-ce/src/lib/components/Common/FilterQuery/FilterQuery.tsx b/frontend/libs/console/legacy-ce/src/lib/components/Common/FilterQuery/FilterQuery.tsx index 3ffa485eca4..f7b49a4dad1 100644 --- a/frontend/libs/console/legacy-ce/src/lib/components/Common/FilterQuery/FilterQuery.tsx +++ b/frontend/libs/console/legacy-ce/src/lib/components/Common/FilterQuery/FilterQuery.tsx @@ -57,7 +57,7 @@ const FilterQuery: React.FC = props => { return ( -
+
{render(rows, state, setState, runQuery)}
diff --git a/frontend/libs/console/legacy-ce/src/lib/components/Common/FilterQuery/state.ts b/frontend/libs/console/legacy-ce/src/lib/components/Common/FilterQuery/state.ts index 85f6f94e68a..55914e5a5b2 100644 --- a/frontend/libs/console/legacy-ce/src/lib/components/Common/FilterQuery/state.ts +++ b/frontend/libs/console/legacy-ce/src/lib/components/Common/FilterQuery/state.ts @@ -124,7 +124,14 @@ export const useFilterQuery = ( requestAction(endpoint, options, undefined, undefined, true, true) ).then( (data: any) => { - setRows(data ?? []); + if (triggerType === 'data') { + setRows(data ?? []); + } else if (triggerOp !== 'invocation') { + setRows(data?.events ?? []); + } else { + setRows(data?.invocations ?? []); + } + setLoading(false); if (offset !== undefined) { setState(s => ({ ...s, offset }));