mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Error dropdown in resource locator disappears when search filter is required (#9681)
This commit is contained in:
parent
7c358e5baa
commit
1a3f72b751
|
@ -1,5 +1,5 @@
|
||||||
import { WorkflowPage, NDV, CredentialsModal } from '../pages';
|
import { WorkflowPage, NDV, CredentialsModal } from '../pages';
|
||||||
import { getVisiblePopper, getVisibleSelect } from '../utils';
|
import { getVisiblePopper } from '../utils';
|
||||||
|
|
||||||
const workflowPage = new WorkflowPage();
|
const workflowPage = new WorkflowPage();
|
||||||
const ndv = new NDV();
|
const ndv = new NDV();
|
||||||
|
@ -40,18 +40,36 @@ describe('Resource Locator', () => {
|
||||||
it('should show appropriate error when credentials are not valid', () => {
|
it('should show appropriate error when credentials are not valid', () => {
|
||||||
workflowPage.actions.addInitialNodeToCanvas('Manual');
|
workflowPage.actions.addInitialNodeToCanvas('Manual');
|
||||||
workflowPage.actions.addNodeToCanvas('Google Sheets', true, true, 'Update row in sheet');
|
workflowPage.actions.addNodeToCanvas('Google Sheets', true, true, 'Update row in sheet');
|
||||||
workflowPage.getters.nodeCredentialsSelect().click();
|
|
||||||
// Add oAuth credentials
|
// Add oAuth credentials
|
||||||
getVisibleSelect().find('li').last().click();
|
workflowPage.getters.nodeCredentialsSelect().click();
|
||||||
|
workflowPage.getters.nodeCredentialsCreateOption().click();
|
||||||
credentialsModal.getters.credentialsEditModal().should('be.visible');
|
credentialsModal.getters.credentialsEditModal().should('be.visible');
|
||||||
credentialsModal.getters.credentialAuthTypeRadioButtons().should('have.length', 2);
|
credentialsModal.getters.credentialAuthTypeRadioButtons().should('have.length', 2);
|
||||||
credentialsModal.getters.credentialAuthTypeRadioButtons().first().click();
|
credentialsModal.getters.credentialAuthTypeRadioButtons().first().click();
|
||||||
credentialsModal.actions.fillCredentialsForm();
|
credentialsModal.actions.fillCredentialsForm();
|
||||||
cy.get('.el-message-box').find('button').contains('Close').click();
|
cy.get('.el-message-box').find('button').contains('Close').click();
|
||||||
|
|
||||||
ndv.getters.resourceLocatorInput('documentId').click();
|
ndv.getters.resourceLocatorInput('documentId').click();
|
||||||
ndv.getters.resourceLocatorErrorMessage().should('contain', INVALID_CREDENTIALS_MESSAGE);
|
ndv.getters.resourceLocatorErrorMessage().should('contain', INVALID_CREDENTIALS_MESSAGE);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
it('should reset resource locator when dependent field is changed', () => {
|
it('should reset resource locator when dependent field is changed', () => {
|
||||||
workflowPage.actions.addInitialNodeToCanvas('Manual');
|
workflowPage.actions.addInitialNodeToCanvas('Manual');
|
||||||
workflowPage.actions.addNodeToCanvas('Google Sheets', true, true, 'Update row in sheet');
|
workflowPage.actions.addNodeToCanvas('Google Sheets', true, true, 'Update row in sheet');
|
||||||
|
|
|
@ -78,6 +78,8 @@ export class NDV extends BasePage {
|
||||||
resourceLocatorErrorMessage: () => cy.getByTestId('rlc-error-container'),
|
resourceLocatorErrorMessage: () => cy.getByTestId('rlc-error-container'),
|
||||||
resourceLocatorModeSelector: (paramName: string) =>
|
resourceLocatorModeSelector: (paramName: string) =>
|
||||||
this.getters.resourceLocator(paramName).find('[data-test-id="rlc-mode-selector"]'),
|
this.getters.resourceLocator(paramName).find('[data-test-id="rlc-mode-selector"]'),
|
||||||
|
resourceLocatorSearch: (paramName: string) =>
|
||||||
|
this.getters.resourceLocator(paramName).findChildByTestId('rlc-search'),
|
||||||
resourceMapperFieldsContainer: () => cy.getByTestId('mapping-fields-container'),
|
resourceMapperFieldsContainer: () => cy.getByTestId('mapping-fields-container'),
|
||||||
resourceMapperSelectColumn: () => cy.getByTestId('matching-column-select'),
|
resourceMapperSelectColumn: () => cy.getByTestId('matching-column-select'),
|
||||||
resourceMapperRemoveFieldButton: (fieldName: string) =>
|
resourceMapperRemoveFieldButton: (fieldName: string) =>
|
||||||
|
|
|
@ -410,7 +410,7 @@ export default defineComponent({
|
||||||
return this.cachedResponses[this.currentRequestKey] || null;
|
return this.cachedResponses[this.currentRequestKey] || null;
|
||||||
},
|
},
|
||||||
currentQueryResults(): IResourceLocatorResultExpanded[] {
|
currentQueryResults(): IResourceLocatorResultExpanded[] {
|
||||||
const results = this.currentResponse ? this.currentResponse.results : [];
|
const results = this.currentResponse?.results ?? [];
|
||||||
|
|
||||||
return results.map(
|
return results.map(
|
||||||
(result: INodeListSearchItems): IResourceLocatorResultExpanded => ({
|
(result: INodeListSearchItems): IResourceLocatorResultExpanded => ({
|
||||||
|
@ -648,6 +648,11 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loadResourcesDebounced() {
|
loadResourcesDebounced() {
|
||||||
|
if (this.currentResponse?.error) {
|
||||||
|
// Clear error response immediately when retrying to show loading state
|
||||||
|
delete this.cachedResponses[this.currentRequestKey];
|
||||||
|
}
|
||||||
|
|
||||||
void this.callDebounced(this.loadResources, {
|
void this.callDebounced(this.loadResources, {
|
||||||
debounceTime: 1000,
|
debounceTime: 1000,
|
||||||
trailing: true,
|
trailing: true,
|
||||||
|
@ -664,6 +669,11 @@ export default defineComponent({
|
||||||
const paramsKey = this.currentRequestKey;
|
const paramsKey = this.currentRequestKey;
|
||||||
const cachedResponse = this.cachedResponses[paramsKey];
|
const cachedResponse = this.cachedResponses[paramsKey];
|
||||||
|
|
||||||
|
if (this.credentialsNotSet) {
|
||||||
|
this.setResponse(paramsKey, { error: true });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.requiresSearchFilter && !params.filter) {
|
if (this.requiresSearchFilter && !params.filter) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
:width="width"
|
:width="width"
|
||||||
:popper-class="$style.popover"
|
:popper-class="$style.popover"
|
||||||
:visible="show"
|
:visible="show"
|
||||||
trigger="manual"
|
:teleported="false"
|
||||||
data-test-id="resource-locator-dropdown"
|
data-test-id="resource-locator-dropdown"
|
||||||
>
|
>
|
||||||
<div v-if="errorView" :class="$style.messageContainer">
|
<div v-if="errorView" :class="$style.messageContainer">
|
||||||
|
|
Loading…
Reference in a new issue