2023-04-28 03:14:31 -07:00
|
|
|
import { WorkflowPage, NDV, CredentialsModal } from '../pages';
|
2024-06-18 02:11:10 -07:00
|
|
|
import { getVisiblePopper } from '../utils';
|
2023-04-28 03:14:31 -07:00
|
|
|
|
|
|
|
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';
|
2023-10-04 07:01:44 -07:00
|
|
|
const MODE_SELECTOR_LIST = 'From list';
|
2023-04-28 03:14:31 -07:00
|
|
|
|
|
|
|
describe('Resource Locator', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
workflowPage.actions.visit();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render both RLC components in google sheets', () => {
|
|
|
|
workflowPage.actions.addInitialNodeToCanvas('Manual');
|
2023-12-08 02:40:05 -08:00
|
|
|
workflowPage.actions.addNodeToCanvas('Google Sheets', true, true, 'Update row in sheet');
|
2023-04-28 03:14:31 -07:00
|
|
|
ndv.getters.resourceLocator('documentId').should('be.visible');
|
|
|
|
ndv.getters.resourceLocator('sheetName').should('be.visible');
|
2023-10-04 07:01:44 -07:00
|
|
|
ndv.getters
|
|
|
|
.resourceLocatorModeSelector('documentId')
|
|
|
|
.find('input')
|
|
|
|
.should('have.value', MODE_SELECTOR_LIST);
|
|
|
|
ndv.getters
|
|
|
|
.resourceLocatorModeSelector('sheetName')
|
|
|
|
.find('input')
|
|
|
|
.should('have.value', MODE_SELECTOR_LIST);
|
2023-04-28 03:14:31 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should show appropriate error when credentials are not set', () => {
|
|
|
|
workflowPage.actions.addInitialNodeToCanvas('Manual');
|
2023-12-08 02:40:05 -08:00
|
|
|
workflowPage.actions.addNodeToCanvas('Google Sheets', true, true, 'Update row in sheet');
|
2023-04-28 03:14:31 -07:00
|
|
|
ndv.getters.resourceLocator('documentId').should('be.visible');
|
|
|
|
ndv.getters.resourceLocatorInput('documentId').click();
|
|
|
|
ndv.getters.resourceLocatorErrorMessage().should('contain', NO_CREDENTIALS_MESSAGE);
|
|
|
|
});
|
|
|
|
|
2024-07-01 04:48:39 -07:00
|
|
|
it('should show create credentials modal when clicking "add your credential"', () => {
|
|
|
|
workflowPage.actions.addInitialNodeToCanvas('Manual');
|
|
|
|
workflowPage.actions.addNodeToCanvas('Google Sheets', true, true, 'Update row in sheet');
|
|
|
|
ndv.getters.resourceLocator('documentId').should('be.visible');
|
|
|
|
ndv.getters.resourceLocatorInput('documentId').click();
|
|
|
|
ndv.getters.resourceLocatorErrorMessage().should('contain', NO_CREDENTIALS_MESSAGE);
|
|
|
|
ndv.getters.resourceLocatorAddCredentials().click();
|
|
|
|
credentialsModal.getters.credentialsEditModal().should('be.visible');
|
|
|
|
});
|
|
|
|
|
2023-04-28 03:14:31 -07:00
|
|
|
it('should show appropriate error when credentials are not valid', () => {
|
|
|
|
workflowPage.actions.addInitialNodeToCanvas('Manual');
|
2023-12-08 02:40:05 -08:00
|
|
|
workflowPage.actions.addNodeToCanvas('Google Sheets', true, true, 'Update row in sheet');
|
2024-06-18 02:11:10 -07:00
|
|
|
|
2023-04-28 03:14:31 -07:00
|
|
|
// Add oAuth credentials
|
2024-06-18 02:11:10 -07:00
|
|
|
workflowPage.getters.nodeCredentialsSelect().click();
|
|
|
|
workflowPage.getters.nodeCredentialsCreateOption().click();
|
2023-04-28 03:14:31 -07:00
|
|
|
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();
|
2024-06-18 02:11:10 -07:00
|
|
|
|
2023-04-28 03:14:31 -07:00
|
|
|
ndv.getters.resourceLocatorInput('documentId').click();
|
|
|
|
ndv.getters.resourceLocatorErrorMessage().should('contain', INVALID_CREDENTIALS_MESSAGE);
|
|
|
|
});
|
|
|
|
|
2024-06-18 02:11:10 -07:00
|
|
|
it('should show appropriate errors when search filter is required', () => {
|
|
|
|
workflowPage.actions.addNodeToCanvas('Github', true, true, 'On Pull Request');
|
|
|
|
ndv.getters.resourceLocator('owner').should('be.visible');
|
|
|
|
ndv.getters.resourceLocatorInput('owner').click();
|
|
|
|
ndv.getters.resourceLocatorErrorMessage().should('contain', NO_CREDENTIALS_MESSAGE);
|
|
|
|
|
|
|
|
workflowPage.getters.nodeCredentialsSelect().click();
|
|
|
|
workflowPage.getters.nodeCredentialsCreateOption().click();
|
|
|
|
credentialsModal.getters.credentialsEditModal().should('be.visible');
|
|
|
|
credentialsModal.actions.fillCredentialsForm();
|
|
|
|
|
|
|
|
ndv.getters.resourceLocatorInput('owner').click();
|
|
|
|
ndv.getters.resourceLocatorSearch('owner').type('owner');
|
|
|
|
ndv.getters.resourceLocatorErrorMessage().should('contain', INVALID_CREDENTIALS_MESSAGE);
|
|
|
|
});
|
|
|
|
|
2023-04-28 03:14:31 -07:00
|
|
|
it('should reset resource locator when dependent field is changed', () => {
|
|
|
|
workflowPage.actions.addInitialNodeToCanvas('Manual');
|
2023-12-08 02:40:05 -08:00
|
|
|
workflowPage.actions.addNodeToCanvas('Google Sheets', true, true, 'Update row in sheet');
|
2023-04-28 03:14:31 -07:00
|
|
|
ndv.actions.setRLCValue('documentId', '123');
|
|
|
|
ndv.actions.setRLCValue('sheetName', '123');
|
|
|
|
ndv.actions.setRLCValue('documentId', '321');
|
|
|
|
ndv.getters.resourceLocatorInput('sheetName').should('have.value', '');
|
|
|
|
});
|
2023-08-31 07:40:20 -07:00
|
|
|
|
|
|
|
// unlike RMC and remote options, RLC does not support loadOptionDependsOn
|
|
|
|
it('should retrieve list options when other params throw errors', () => {
|
2023-09-01 04:29:31 -07:00
|
|
|
workflowPage.actions.addInitialNodeToCanvas('E2e Test', { action: 'Resource Locator' });
|
2023-08-31 07:40:20 -07:00
|
|
|
|
|
|
|
ndv.getters.resourceLocatorInput('rlc').click();
|
2024-01-04 08:23:24 -08:00
|
|
|
|
|
|
|
cy.getByTestId('rlc-item').should('exist');
|
2023-09-01 04:29:31 -07:00
|
|
|
getVisiblePopper()
|
|
|
|
.should('have.length', 1)
|
|
|
|
.findChildByTestId('rlc-item')
|
|
|
|
.should('have.length', 5);
|
2023-08-31 07:40:20 -07:00
|
|
|
|
2023-10-12 05:18:35 -07:00
|
|
|
ndv.actions.setInvalidExpression({ fieldName: 'fieldId' });
|
2023-08-31 07:40:20 -07:00
|
|
|
|
2024-05-09 05:45:31 -07:00
|
|
|
ndv.getters.inputPanel().click(); // remove focus from input, hide expression preview
|
2023-08-31 07:40:20 -07:00
|
|
|
|
|
|
|
ndv.getters.resourceLocatorInput('rlc').click();
|
2024-01-04 08:23:24 -08:00
|
|
|
|
|
|
|
cy.getByTestId('rlc-item').should('exist');
|
2023-09-01 04:29:31 -07:00
|
|
|
getVisiblePopper()
|
|
|
|
.should('have.length', 1)
|
|
|
|
.findChildByTestId('rlc-item')
|
|
|
|
.should('have.length', 5);
|
2023-08-31 07:40:20 -07:00
|
|
|
});
|
2023-04-28 03:14:31 -07:00
|
|
|
});
|