From b17d5f9aa086bf408e8450244460ada57de0d7c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milorad=20FIlipovi=C4=87?= Date: Fri, 28 Apr 2023 12:14:31 +0200 Subject: [PATCH] feat(editor): Add support for `loadOptionsDependsOn` to RLC (#6101) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(editor): Add support for `loadOptionsDependsOn` to the Resource Locator component * 🔥 Removing leftover log * ✅ Added e2e tests for ResourceLocator component --- cypress/e2e/26-resource-locator.cy.ts | 58 +++++++++++++++++++ cypress/pages/ndv.ts | 10 ++++ .../src/components/ParameterInput.vue | 1 + .../ResourceLocator/ResourceLocator.vue | 27 ++++++++- .../ResourceLocatorDropdown.vue | 1 + .../Sheet/v2/actions/sheet/Sheet.resource.ts | 3 + 6 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 cypress/e2e/26-resource-locator.cy.ts diff --git a/cypress/e2e/26-resource-locator.cy.ts b/cypress/e2e/26-resource-locator.cy.ts new file mode 100644 index 0000000000..e0ba34d70a --- /dev/null +++ b/cypress/e2e/26-resource-locator.cy.ts @@ -0,0 +1,58 @@ +import { WorkflowPage, NDV, CredentialsModal } from '../pages'; + +const workflowPage = new WorkflowPage(); +const ndv = new NDV(); +const credentialsModal = new CredentialsModal(); + +const NO_CREDENTIALS_MESSAGE = 'Please add your credential'; +const INVALID_CREDENTIALS_MESSAGE = 'Please check your credential'; + +describe('Resource Locator', () => { + before(() => { + cy.resetAll(); + cy.skipSetup(); + }); + + beforeEach(() => { + workflowPage.actions.visit(); + }); + + it('should render both RLC components in google sheets', () => { + workflowPage.actions.addInitialNodeToCanvas('Manual'); + workflowPage.actions.addNodeToCanvas('Google Sheets', true, true); + ndv.getters.resourceLocator('documentId').should('be.visible'); + ndv.getters.resourceLocator('sheetName').should('be.visible'); + }); + + it('should show appropriate error when credentials are not set', () => { + workflowPage.actions.addInitialNodeToCanvas('Manual'); + workflowPage.actions.addNodeToCanvas('Google Sheets', true, true); + ndv.getters.resourceLocator('documentId').should('be.visible'); + ndv.getters.resourceLocatorInput('documentId').click(); + ndv.getters.resourceLocatorErrorMessage().should('contain', NO_CREDENTIALS_MESSAGE); + }); + + it('should show appropriate error when credentials are not valid', () => { + workflowPage.actions.addInitialNodeToCanvas('Manual'); + workflowPage.actions.addNodeToCanvas('Google Sheets', true, true); + workflowPage.getters.nodeCredentialsSelect().click(); + // Add oAuth credentials + workflowPage.getters.nodeCredentialsSelect().find('li').last().click(); + credentialsModal.getters.credentialsEditModal().should('be.visible'); + credentialsModal.getters.credentialAuthTypeRadioButtons().should('have.length', 2); + credentialsModal.getters.credentialAuthTypeRadioButtons().first().click(); + credentialsModal.actions.fillCredentialsForm(); + cy.get('.el-message-box').find('button').contains('Close').click(); + ndv.getters.resourceLocatorInput('documentId').click(); + ndv.getters.resourceLocatorErrorMessage().should('contain', INVALID_CREDENTIALS_MESSAGE); + }); + + it('should reset resource locator when dependent field is changed', () => { + workflowPage.actions.addInitialNodeToCanvas('Manual'); + workflowPage.actions.addNodeToCanvas('Google Sheets', true, true); + ndv.actions.setRLCValue('documentId', '123'); + ndv.actions.setRLCValue('sheetName', '123'); + ndv.actions.setRLCValue('documentId', '321'); + ndv.getters.resourceLocatorInput('sheetName').should('have.value', ''); + }); +}); diff --git a/cypress/pages/ndv.ts b/cypress/pages/ndv.ts index cf787a4a3f..f23f9a0548 100644 --- a/cypress/pages/ndv.ts +++ b/cypress/pages/ndv.ts @@ -51,6 +51,11 @@ export class NDV extends BasePage { inputHoveringItem: () => this.getters.inputPanel().findChildByTestId('hovering-item'), outputBranches: () => this.getters.outputPanel().findChildByTestId('branches'), inputBranches: () => this.getters.inputPanel().findChildByTestId('branches'), + resourceLocator: (paramName: string) => cy.getByTestId(`resource-locator-${paramName}`), + resourceLocatorInput: (paramName: string) => this.getters.resourceLocator(paramName).find('[data-test-id="rlc-input-container"]'), + resourceLocatorDropdown: (paramName: string) => this.getters.resourceLocator(paramName).find('[data-test-id="resource-locator-dropdown"]'), + resourceLocatorErrorMessage: () => cy.getByTestId('rlc-error-container'), + resourceLocatorModeSelector: (paramName: string) => this.getters.resourceLocator(paramName).find('[data-test-id="rlc-mode-selector"]'), }; actions = { @@ -148,5 +153,10 @@ export class NDV extends BasePage { switchIntputBranch: (name: string) => { this.getters.inputBranches().get('span').contains(name).click(); }, + setRLCValue: (paramName: string, value: string) => { + this.getters.resourceLocatorModeSelector(paramName).click(); + this.getters.resourceLocatorModeSelector(paramName).find('li').last().click(); + this.getters.resourceLocatorInput(paramName).type(value); + } }; } diff --git a/packages/editor-ui/src/components/ParameterInput.vue b/packages/editor-ui/src/components/ParameterInput.vue index 6f71269433..24d127c551 100644 --- a/packages/editor-ui/src/components/ParameterInput.vue +++ b/packages/editor-ui/src/components/ParameterInput.vue @@ -18,6 +18,7 @@ ref="resourceLocator" :parameter="parameter" :value="value" + :dependentParametersValues="dependentParametersValues" :displayTitle="displayTitle" :expressionDisplayValue="expressionDisplayValue" :expressionComputedValue="expressionEvaluated" diff --git a/packages/editor-ui/src/components/ResourceLocator/ResourceLocator.vue b/packages/editor-ui/src/components/ResourceLocator/ResourceLocator.vue index b11d7a2eca..998fe9c3e3 100644 --- a/packages/editor-ui/src/components/ResourceLocator/ResourceLocator.vue +++ b/packages/editor-ui/src/components/ResourceLocator/ResourceLocator.vue @@ -1,5 +1,9 @@