fix: fix localizeNodeNames

This commit is contained in:
Alex Grozav 2023-07-24 15:10:17 +03:00
parent 971fb3949a
commit d975b34794
4 changed files with 24 additions and 16 deletions

View file

@ -1,6 +1,7 @@
import { NodeCreator } from '../pages/features/node-creator'; import { NodeCreator } from '../pages/features/node-creator';
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow'; import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
import { NDV } from '../pages/ndv'; import { NDV } from '../pages/ndv';
import { getVisibleSelect } from '../utils';
const nodeCreatorFeature = new NodeCreator(); const nodeCreatorFeature = new NodeCreator();
const WorkflowPage = new WorkflowPageClass(); const WorkflowPage = new WorkflowPageClass();
@ -88,14 +89,14 @@ describe('Node Creator', () => {
NDVModal.getters.parameterInput('operation').find('input').should('have.value', 'Crop'); NDVModal.getters.parameterInput('operation').find('input').should('have.value', 'Crop');
}); });
it.only('should search through actions and confirm added action', () => { it('should search through actions and confirm added action', () => {
nodeCreatorFeature.actions.openNodeCreator(); nodeCreatorFeature.actions.openNodeCreator();
nodeCreatorFeature.getters.searchBar().find('input').clear().type('ftp'); nodeCreatorFeature.getters.searchBar().find('input').clear().type('ftp');
nodeCreatorFeature.getters.searchBar().find('input').type('{rightarrow}'); nodeCreatorFeature.getters.searchBar().find('input').type('{rightarrow}');
nodeCreatorFeature.getters.activeSubcategory().should('have.text', 'FTP'); nodeCreatorFeature.getters.activeSubcategory().should('have.text', 'FTP');
nodeCreatorFeature.getters.searchBar().find('input').clear().type('file'); nodeCreatorFeature.getters.searchBar().find('input').clear().type('file');
// Navigate to rename action which should be the 4th item // Navigate to rename action which should be the 4th item
nodeCreatorFeature.getters.searchBar().find('input').type('{uparrow}{uparrow}{rightarrow}'); nodeCreatorFeature.getters.searchBar().find('input').type('{uparrow}{rightarrow}');
NDVModal.getters.parameterInput('operation').find('input').should('have.value', 'Rename'); NDVModal.getters.parameterInput('operation').find('input').should('have.value', 'Rename');
}); });
@ -137,7 +138,7 @@ describe('Node Creator', () => {
nodeCreatorFeature.getters nodeCreatorFeature.getters
.getCategoryItem('Triggers') .getCategoryItem('Triggers')
.parent() .parent()
.should('not.have.attr', 'data-category-collapsed'); .should('have.attr', 'data-category-collapsed', 'false');
nodeCreatorFeature.getters nodeCreatorFeature.getters
.getCategoryItem('Actions') .getCategoryItem('Actions')
.parent() .parent()
@ -146,7 +147,7 @@ describe('Node Creator', () => {
nodeCreatorFeature.getters nodeCreatorFeature.getters
.getCategoryItem('Actions') .getCategoryItem('Actions')
.parent() .parent()
.should('not.have.attr', 'data-category-collapsed'); .should('have.attr', 'data-category-collapsed', 'false');
}); });
it('should have "Triggers" section collapsed when opening actions view from Regular root view', () => { it('should have "Triggers" section collapsed when opening actions view from Regular root view', () => {
@ -160,21 +161,21 @@ describe('Node Creator', () => {
nodeCreatorFeature.getters nodeCreatorFeature.getters
.getCategoryItem('Actions') .getCategoryItem('Actions')
.parent() .parent()
.should('not.have.attr', 'data-category-collapsed'); .should('have.attr', 'data-category-collapsed', 'false');
nodeCreatorFeature.getters.getCategoryItem('Actions').click(); nodeCreatorFeature.getters.getCategoryItem('Actions').click();
nodeCreatorFeature.getters nodeCreatorFeature.getters
.getCategoryItem('Actions') .getCategoryItem('Actions')
.parent() .parent()
.should('have.attr', 'data-category-collapsed'); .should('have.attr', 'data-category-collapsed', 'true');
nodeCreatorFeature.getters nodeCreatorFeature.getters
.getCategoryItem('Triggers') .getCategoryItem('Triggers')
.parent() .parent()
.should('have.attr', 'data-category-collapsed'); .should('have.attr', 'data-category-collapsed', 'true');
nodeCreatorFeature.getters.getCategoryItem('Triggers').click(); nodeCreatorFeature.getters.getCategoryItem('Triggers').click();
nodeCreatorFeature.getters nodeCreatorFeature.getters
.getCategoryItem('Triggers') .getCategoryItem('Triggers')
.parent() .parent()
.should('not.have.attr', 'data-category-collapsed'); .should('have.attr', 'data-category-collapsed', 'false');
}); });
it('should show callout and two suggested nodes if node has no trigger actions', () => { it('should show callout and two suggested nodes if node has no trigger actions', () => {
@ -208,11 +209,7 @@ describe('Node Creator', () => {
// Setup 1s interval execution // Setup 1s interval execution
cy.getByTestId('parameter-input-field').click(); cy.getByTestId('parameter-input-field').click();
cy.getByTestId('parameter-input-field') getVisibleSelect().find('.option-headline').contains('Seconds').click();
.find('.el-select-dropdown')
.find('.option-headline')
.contains('Seconds')
.click();
cy.getByTestId('parameter-input-secondsInterval').clear().type('1'); cy.getByTestId('parameter-input-secondsInterval').clear().type('1');
NDVModal.actions.close(); NDVModal.actions.close();
@ -296,6 +293,7 @@ describe('Node Creator', () => {
}); });
}); });
// @TODO FIX ADDING 2 NODES IN ONE GO
it('should not append manual trigger when source is canvas related', () => { it('should not append manual trigger when source is canvas related', () => {
nodeCreatorFeature.getters.canvasAddButton().click(); nodeCreatorFeature.getters.canvasAddButton().click();
nodeCreatorFeature.getters.searchBar().find('input').clear().type('n8n'); nodeCreatorFeature.getters.searchBar().find('input').clear().type('n8n');

View file

@ -5,3 +5,7 @@ export function getVisiblePopper() {
export function getVisibleSelect() { export function getVisibleSelect() {
return getVisiblePopper().filter('.el-select__popper'); return getVisiblePopper().filter('.el-select__popper');
} }
export function getVisibleDropdown() {
return getVisiblePopper().filter('.el-select__dropdown');
}

View file

@ -14,7 +14,7 @@ export const GlobalComponentsPlugin: Plugin<{}> = {
const messageService = useMessage(); const messageService = useMessage();
app.component('enterprise-edition', EnterpriseEdition); app.component('enterprise-edition', EnterpriseEdition);
app.component('fragment', Fragment); app.component('Fragment', Fragment);
app.use(ElementPlus); app.use(ElementPlus);
app.use(N8nPlugin); app.use(N8nPlugin);

View file

@ -965,6 +965,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
}, },
removeNode(node: INodeUi): void { removeNode(node: INodeUi): void {
const uiStore = useUIStore();
const { [node.name]: removedNodeMetadata, ...remainingNodeMetadata } = this.nodeMetadata; const { [node.name]: removedNodeMetadata, ...remainingNodeMetadata } = this.nodeMetadata;
this.nodeMetadata = remainingNodeMetadata; this.nodeMetadata = remainingNodeMetadata;
@ -978,8 +979,13 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
for (let i = 0; i < this.workflow.nodes.length; i++) { for (let i = 0; i < this.workflow.nodes.length; i++) {
if (this.workflow.nodes[i].name === node.name) { if (this.workflow.nodes[i].name === node.name) {
this.workflow.nodes.splice(i, 1); this.workflow = {
const uiStore = useUIStore(); ...this.workflow,
nodes: [...this.workflow.nodes.slice(0, i), ...this.workflow.nodes.slice(i + 1)],
};
console.log(this.workflow);
uiStore.stateIsDirty = true; uiStore.stateIsDirty = true;
return; return;
} }