2023-04-28 03:14:31 -07:00
|
|
|
import { WorkflowPage, NDV, CredentialsModal } from '../pages';
|
2023-08-31 07:40:20 -07:00
|
|
|
import { getPopper, getVisiblePopper, getVisibleSelect } 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';
|
|
|
|
|
|
|
|
describe('Resource Locator', () => {
|
|
|
|
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
|
2023-07-28 00:51:07 -07:00
|
|
|
getVisibleSelect().find('li').last().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();
|
|
|
|
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', '');
|
|
|
|
});
|
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();
|
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
|
|
|
|
|
|
|
ndv.actions.setInvalidExpression('fieldId');
|
|
|
|
|
|
|
|
ndv.getters.container().click(); // remove focus from input, hide expression preview
|
|
|
|
|
|
|
|
ndv.getters.resourceLocatorInput('rlc').click();
|
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
|
|
|
});
|