From d2b0a570648aba53f738d6bce4820ccb91d8e11f Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Tue, 8 Nov 2022 19:48:54 +0100 Subject: [PATCH 1/6] refactor: abstract exception capture out of is-still-verified --- .../src/apps/deepl/auth/is-still-verified.ts | 8 ++------ .../src/apps/discord/auth/is-still-verified.ts | 8 ++------ .../src/apps/flickr/auth/is-still-verified.ts | 18 +++++++----------- .../src/apps/github/auth/is-still-verified.ts | 8 ++------ .../apps/salesforce/auth/is-still-verified.ts | 8 ++------ .../src/apps/slack/auth/is-still-verified.ts | 8 ++------ .../src/apps/smtp/auth/is-still-verified.ts | 8 ++------ .../src/apps/twilio/auth/is-still-verified.ts | 8 ++------ .../src/apps/twitter/auth/is-still-verified.ts | 8 ++------ .../src/graphql/queries/test-connection.ts | 7 ++++++- 10 files changed, 29 insertions(+), 60 deletions(-) diff --git a/packages/backend/src/apps/deepl/auth/is-still-verified.ts b/packages/backend/src/apps/deepl/auth/is-still-verified.ts index 95a1ef29..66bb963e 100644 --- a/packages/backend/src/apps/deepl/auth/is-still-verified.ts +++ b/packages/backend/src/apps/deepl/auth/is-still-verified.ts @@ -2,12 +2,8 @@ import { IGlobalVariable } from '@automatisch/types'; import verifyCredentials from './verify-credentials'; const isStillVerified = async ($: IGlobalVariable) => { - try { - await verifyCredentials($); - return true; - } catch (error) { - return false; - } + await verifyCredentials($); + return true; }; export default isStillVerified; diff --git a/packages/backend/src/apps/discord/auth/is-still-verified.ts b/packages/backend/src/apps/discord/auth/is-still-verified.ts index b34d1517..fadd0880 100644 --- a/packages/backend/src/apps/discord/auth/is-still-verified.ts +++ b/packages/backend/src/apps/discord/auth/is-still-verified.ts @@ -2,13 +2,9 @@ import { IGlobalVariable } from '@automatisch/types'; import getCurrentUser from '../common/get-current-user'; const isStillVerified = async ($: IGlobalVariable) => { - try { - await getCurrentUser($); + await getCurrentUser($); - return true; - } catch (error) { - return false; - } + return true; }; export default isStillVerified; diff --git a/packages/backend/src/apps/flickr/auth/is-still-verified.ts b/packages/backend/src/apps/flickr/auth/is-still-verified.ts index 76547cc8..634776a9 100644 --- a/packages/backend/src/apps/flickr/auth/is-still-verified.ts +++ b/packages/backend/src/apps/flickr/auth/is-still-verified.ts @@ -1,17 +1,13 @@ import { IGlobalVariable } from '@automatisch/types'; const isStillVerified = async ($: IGlobalVariable) => { - try { - const params = { - method: 'flickr.test.login', - format: 'json', - nojsoncallback: 1, - }; - const response = await $.http.get('/rest', { params }); - return !!response.data.user.id; - } catch (error) { - return false; - } + const params = { + method: 'flickr.test.login', + format: 'json', + nojsoncallback: 1, + }; + const response = await $.http.get('/rest', { params }); + return !!response.data.user.id; }; export default isStillVerified; diff --git a/packages/backend/src/apps/github/auth/is-still-verified.ts b/packages/backend/src/apps/github/auth/is-still-verified.ts index 060ad5cd..befb7694 100644 --- a/packages/backend/src/apps/github/auth/is-still-verified.ts +++ b/packages/backend/src/apps/github/auth/is-still-verified.ts @@ -2,12 +2,8 @@ import { IGlobalVariable } from '@automatisch/types'; import getCurrentUser from '../common/get-current-user'; const isStillVerified = async ($: IGlobalVariable) => { - try { - const user = await getCurrentUser($); - return !!user.id; - } catch (error) { - return false; - } + const user = await getCurrentUser($); + return !!user.id; }; export default isStillVerified; diff --git a/packages/backend/src/apps/salesforce/auth/is-still-verified.ts b/packages/backend/src/apps/salesforce/auth/is-still-verified.ts index 8f578344..d36919f2 100644 --- a/packages/backend/src/apps/salesforce/auth/is-still-verified.ts +++ b/packages/backend/src/apps/salesforce/auth/is-still-verified.ts @@ -2,12 +2,8 @@ import { IGlobalVariable } from '@automatisch/types'; import getCurrentUser from '../common/get-current-user'; const isStillVerified = async ($: IGlobalVariable) => { - try { - const user = await getCurrentUser($); - return !!user; - } catch (error) { - return false; - } + const user = await getCurrentUser($); + return !!user; }; export default isStillVerified; diff --git a/packages/backend/src/apps/slack/auth/is-still-verified.ts b/packages/backend/src/apps/slack/auth/is-still-verified.ts index 060ad5cd..befb7694 100644 --- a/packages/backend/src/apps/slack/auth/is-still-verified.ts +++ b/packages/backend/src/apps/slack/auth/is-still-verified.ts @@ -2,12 +2,8 @@ import { IGlobalVariable } from '@automatisch/types'; import getCurrentUser from '../common/get-current-user'; const isStillVerified = async ($: IGlobalVariable) => { - try { - const user = await getCurrentUser($); - return !!user.id; - } catch (error) { - return false; - } + const user = await getCurrentUser($); + return !!user.id; }; export default isStillVerified; diff --git a/packages/backend/src/apps/smtp/auth/is-still-verified.ts b/packages/backend/src/apps/smtp/auth/is-still-verified.ts index 95a1ef29..66bb963e 100644 --- a/packages/backend/src/apps/smtp/auth/is-still-verified.ts +++ b/packages/backend/src/apps/smtp/auth/is-still-verified.ts @@ -2,12 +2,8 @@ import { IGlobalVariable } from '@automatisch/types'; import verifyCredentials from './verify-credentials'; const isStillVerified = async ($: IGlobalVariable) => { - try { - await verifyCredentials($); - return true; - } catch (error) { - return false; - } + await verifyCredentials($); + return true; }; export default isStillVerified; diff --git a/packages/backend/src/apps/twilio/auth/is-still-verified.ts b/packages/backend/src/apps/twilio/auth/is-still-verified.ts index 95a1ef29..66bb963e 100644 --- a/packages/backend/src/apps/twilio/auth/is-still-verified.ts +++ b/packages/backend/src/apps/twilio/auth/is-still-verified.ts @@ -2,12 +2,8 @@ import { IGlobalVariable } from '@automatisch/types'; import verifyCredentials from './verify-credentials'; const isStillVerified = async ($: IGlobalVariable) => { - try { - await verifyCredentials($); - return true; - } catch (error) { - return false; - } + await verifyCredentials($); + return true; }; export default isStillVerified; diff --git a/packages/backend/src/apps/twitter/auth/is-still-verified.ts b/packages/backend/src/apps/twitter/auth/is-still-verified.ts index 8f578344..d36919f2 100644 --- a/packages/backend/src/apps/twitter/auth/is-still-verified.ts +++ b/packages/backend/src/apps/twitter/auth/is-still-verified.ts @@ -2,12 +2,8 @@ import { IGlobalVariable } from '@automatisch/types'; import getCurrentUser from '../common/get-current-user'; const isStillVerified = async ($: IGlobalVariable) => { - try { - const user = await getCurrentUser($); - return !!user; - } catch (error) { - return false; - } + const user = await getCurrentUser($); + return !!user; }; export default isStillVerified; diff --git a/packages/backend/src/graphql/queries/test-connection.ts b/packages/backend/src/graphql/queries/test-connection.ts index 1fa4d036..3782b53e 100644 --- a/packages/backend/src/graphql/queries/test-connection.ts +++ b/packages/backend/src/graphql/queries/test-connection.ts @@ -22,7 +22,12 @@ const testConnection = async ( const app = await App.findOneByKey(connection.key, false); const $ = await globalVariable({ connection, app }); - const isStillVerified = await app.auth.isStillVerified($); + let isStillVerified; + try { + isStillVerified = !!(await app.auth.isStillVerified($)); + } catch { + isStillVerified = false; + } connection = await connection.$query().patchAndFetch({ formattedData: connection.formattedData, From bdb7a1b840beb99330d23d723edc8e79e3cd11c2 Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Tue, 8 Nov 2022 20:00:28 +0100 Subject: [PATCH 2/6] feat(web): hide empty error tab in execution step --- packages/web/src/components/ExecutionStep/index.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/web/src/components/ExecutionStep/index.tsx b/packages/web/src/components/ExecutionStep/index.tsx index 7d4c7fe2..106d03db 100644 --- a/packages/web/src/components/ExecutionStep/index.tsx +++ b/packages/web/src/components/ExecutionStep/index.tsx @@ -51,6 +51,7 @@ export default function ExecutionStep( const validationStatusIcon = executionStep.status === 'success' ? validIcon : errorIcon; + const hasError = !!executionStep.errorDetails; return ( @@ -86,7 +87,7 @@ export default function ExecutionStep( > - + {hasError && } @@ -98,9 +99,11 @@ export default function ExecutionStep( - - - + {hasError && ( + + + + )} ); From bf009ae13b08b5d50f4ea46c2ac9f465370a626b Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Tue, 8 Nov 2022 21:04:23 +0100 Subject: [PATCH 3/6] chore(types): add status in Execution --- packages/types/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/types/index.d.ts b/packages/types/index.d.ts index 0685adf4..6701a7c5 100644 --- a/packages/types/index.d.ts +++ b/packages/types/index.d.ts @@ -40,6 +40,7 @@ export interface IExecution { flowId: string; flow: IFlow; testRun: boolean; + status: 'success' | 'failure'; executionSteps: IExecutionStep[]; updatedAt: string; createdAt: string; From 608038cbcc6df1656be6376e489ffa6a31acc24b Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Tue, 8 Nov 2022 21:04:56 +0100 Subject: [PATCH 4/6] feat(web): add status in execution row --- packages/web/src/components/ExecutionRow/index.tsx | 10 ++++++++++ packages/web/src/graphql/queries/get-executions.ts | 1 + packages/web/src/locales/en.json | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/web/src/components/ExecutionRow/index.tsx b/packages/web/src/components/ExecutionRow/index.tsx index f56abcd1..114162cd 100644 --- a/packages/web/src/components/ExecutionRow/index.tsx +++ b/packages/web/src/components/ExecutionRow/index.tsx @@ -57,6 +57,16 @@ export default function ExecutionRow( /> )} + + theme.palette.primary.main }} /> diff --git a/packages/web/src/graphql/queries/get-executions.ts b/packages/web/src/graphql/queries/get-executions.ts index 1c015677..653426a9 100644 --- a/packages/web/src/graphql/queries/get-executions.ts +++ b/packages/web/src/graphql/queries/get-executions.ts @@ -13,6 +13,7 @@ export const GET_EXECUTIONS = gql` testRun createdAt updatedAt + status flow { id name diff --git a/packages/web/src/locales/en.json b/packages/web/src/locales/en.json index a18afad8..4d79ee2b 100644 --- a/packages/web/src/locales/en.json +++ b/packages/web/src/locales/en.json @@ -74,6 +74,8 @@ "executions.noExecutions": "There is no execution data point to show.", "execution.executedAt": "executed {datetime}", "execution.test": "Test run", + "execution.statusSuccess": "Success", + "execution.statusFailure": "Failure", "execution.noDataTitle": "No data", "execution.noDataMessage": "We successfully ran the execution, but there was no new data to process.", "profileSettings.title": "My Profile", @@ -86,4 +88,4 @@ "profileSettings.updatePassword": "Update password", "notifications.title": "Notifications", "notification.releasedAt": "Released {relativeDate}" -} +} \ No newline at end of file From 0a4877993dcb8af0bedfac4df00672840283f318 Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Tue, 8 Nov 2022 21:58:02 +0100 Subject: [PATCH 5/6] test: replace Slack with DeepL --- packages/e2e-tests/cypress.config.js | 2 +- .../e2e-tests/cypress/e2e/apps/list-apps.js | 10 ++++--- .../e2e/connections/create-connection.js | 25 ++++++++++-------- .../cypress/e2e/flow-editor/create-flow.js | 26 ++++++++++--------- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/packages/e2e-tests/cypress.config.js b/packages/e2e-tests/cypress.config.js index a9b1bc3e..dac0771b 100644 --- a/packages/e2e-tests/cypress.config.js +++ b/packages/e2e-tests/cypress.config.js @@ -8,7 +8,7 @@ module.exports = defineConfig({ env: { login_email: 'user@automatisch.io', login_password: 'sample', - slack_user_token: TO_BE_PROVIDED, + deepl_auth_key: TO_BE_PROVIDED, }, specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}', viewportWidth: 1280, diff --git a/packages/e2e-tests/cypress/e2e/apps/list-apps.js b/packages/e2e-tests/cypress/e2e/apps/list-apps.js index 908eafac..e36b7125 100644 --- a/packages/e2e-tests/cypress/e2e/apps/list-apps.js +++ b/packages/e2e-tests/cypress/e2e/apps/list-apps.js @@ -20,7 +20,9 @@ describe('Apps page', () => { context('can add connection', () => { before(() => { - cy.og('add-connection-button').click(); + cy + .og('add-connection-button') + .click({ force: true }); }); it('lists applications', () => { @@ -28,14 +30,14 @@ describe('Apps page', () => { }); it('searches an application', () => { - cy.og('search-for-app-text-field').type('Slack'); + cy.og('search-for-app-text-field').type('DeepL'); cy.og('app-list-item').should('have.length', 1); }); it('goes to app page to create a connection', () => { cy.og('app-list-item').first().click(); - cy.location('pathname').should('equal', '/app/slack/connections/add'); + cy.location('pathname').should('equal', '/app/deepl/connections/add'); cy.og('add-app-connection-dialog').should('be.visible'); }); @@ -43,7 +45,7 @@ describe('Apps page', () => { it('closes the dialog on backdrop click', () => { cy.clickOutside(); - cy.location('pathname').should('equal', '/app/slack/connections'); + cy.location('pathname').should('equal', '/app/deepl/connections'); cy.og('add-app-connection-dialog').should('not.exist'); }); }); diff --git a/packages/e2e-tests/cypress/e2e/connections/create-connection.js b/packages/e2e-tests/cypress/e2e/connections/create-connection.js index 7d01d0f7..8cff984e 100644 --- a/packages/e2e-tests/cypress/e2e/connections/create-connection.js +++ b/packages/e2e-tests/cypress/e2e/connections/create-connection.js @@ -5,41 +5,44 @@ describe('Connections page', () => { cy.login(); cy.og('apps-page-drawer-link').click(); + + cy.visit('/app/deepl/connections'); }); after(() => { cy.logout(); }); - it('opens via applications page', () => { + it('shows connections if any', () => { cy.og('apps-loader').should('not.exist'); - cy.og('app-row').contains('Slack').click(); - - cy.og('app-connection-row').should('be.visible'); - - cy.ss('Slack connections before creating a connection'); + cy.ss('DeepL connections before creating a connection'); }); context('can add connection', () => { it('has a button to open add connection dialog', () => { - cy.og('add-connection-button').scrollIntoView().should('be.visible'); + cy.scrollTo('top', { ensureScrollable: false }); + + cy + .og('add-connection-button') + .should('be.visible'); }); it('add connection button takes user to add connection page', () => { - cy.og('add-connection-button').click({ force: true }); + cy.og('add-connection-button').click(); - cy.location('pathname').should('equal', '/app/slack/connections/add'); + cy.location('pathname').should('equal', '/app/deepl/connections/add'); }); it('shows add connection dialog to create a new connection', () => { - cy.get('input[name="accessToken"]').type(Cypress.env('slack_user_token')); + cy.get('input[name="screenName"]').type('e2e-test connection!'); + cy.get('input[name="authenticationKey"]').type(Cypress.env('deepl_auth_key')); cy.og('create-connection-button').click(); cy.og('create-connection-button').should('not.exist'); - cy.ss('Slack connections after creating a connection'); + cy.ss('DeepL connections after creating a connection'); }); }); }); diff --git a/packages/e2e-tests/cypress/e2e/flow-editor/create-flow.js b/packages/e2e-tests/cypress/e2e/flow-editor/create-flow.js index 84efbd09..ad175e7b 100644 --- a/packages/e2e-tests/cypress/e2e/flow-editor/create-flow.js +++ b/packages/e2e-tests/cypress/e2e/flow-editor/create-flow.js @@ -77,19 +77,19 @@ describe('Flow editor page', () => { }); }); - context('arrange Slack action', () => { + context('arrange DeepL action', () => { context('choose app and event substep', () => { it('choose application', () => { cy.og('choose-app-autocomplete').click(); - cy.get('li[role="option"]:contains("Slack")').click(); + cy.get('li[role="option"]:contains("DeepL")').click(); }); it('choose an event', () => { cy.og('choose-event-autocomplete').should('be.visible').click(); cy.get( - 'li[role="option"]:contains("Send a message to channel")' + 'li[role="option"]:contains("Translate Text")' ).click(); }); @@ -120,13 +120,7 @@ describe('Flow editor page', () => { }); context('set up action', () => { - it('choose channel', () => { - cy.og('parameters.channel-autocomplete').click(); - - cy.get('li[role="option"]').last().click(); - }); - - it('arrange message text', () => { + it('arrange text', () => { cy.og('power-input', ' [contenteditable]') .click() .type( @@ -141,7 +135,15 @@ describe('Flow editor page', () => { cy.clickOutside(); - cy.ss('Slack action message text'); + cy.ss('DeepL action text'); + }); + + it('set target language', () => { + cy.og('parameters.targetLanguage-autocomplete').click(); + + cy.get( + 'li[role="option"]:contains("Turkish")' + ).first().click(); }); it('continue to next step', () => { @@ -161,7 +163,7 @@ describe('Flow editor page', () => { cy.og('flow-test-substep-output').should('be.visible'); - cy.ss('Slack action test output'); + cy.ss('DeepL action test output'); cy.og('flow-substep-continue-button').click(); }); From c9022f42080cc9102009b5c736159863548ae711 Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Tue, 8 Nov 2022 21:58:27 +0100 Subject: [PATCH 6/6] test: do not display empty error in execution step --- .../e2e-tests/cypress/e2e/executions/display-execution.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/e2e-tests/cypress/e2e/executions/display-execution.js b/packages/e2e-tests/cypress/e2e/executions/display-execution.js index 945b987e..62064fa6 100644 --- a/packages/e2e-tests/cypress/e2e/executions/display-execution.js +++ b/packages/e2e-tests/cypress/e2e/executions/display-execution.js @@ -26,9 +26,7 @@ describe('Execution page', () => { cy.ss('Execution - data out'); }); - it('displays error', () => { - cy.og('error-tab').click({ multiple: true, force: true }); - - cy.ss('Execution - error'); + it('does not display error', () => { + cy.og('error-tab').should('not.exist'); }); });