mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
ci: Fix prettier auto-formatting (no-changelog) (#7063)
This commit is contained in:
committed by
GitHub
parent
fa3d7070b0
commit
a693b29134
@@ -13,7 +13,7 @@ describe('Code node', () => {
|
||||
});
|
||||
|
||||
it('should show correct placeholders switching modes', () => {
|
||||
cy.contains("// Loop over input items and add a new field").should('be.visible');
|
||||
cy.contains('// Loop over input items and add a new field').should('be.visible');
|
||||
|
||||
ndv.getters.parameterInput('mode').click();
|
||||
ndv.actions.selectOptionInParameterDropdown('mode', 'Run Once for Each Item');
|
||||
@@ -22,8 +22,8 @@ describe('Code node', () => {
|
||||
|
||||
ndv.getters.parameterInput('mode').click();
|
||||
ndv.actions.selectOptionInParameterDropdown('mode', 'Run Once for All Items');
|
||||
cy.contains("// Loop over input items and add a new field").should('be.visible');
|
||||
})
|
||||
cy.contains('// Loop over input items and add a new field').should('be.visible');
|
||||
});
|
||||
|
||||
it('should execute the placeholder successfully in both modes', () => {
|
||||
ndv.actions.execute();
|
||||
@@ -36,7 +36,7 @@ describe('Code node', () => {
|
||||
|
||||
WorkflowPage.getters.successToast().contains('Node executed successfully');
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('Ask AI', () => {
|
||||
it('tab should display based on experiment', () => {
|
||||
@@ -53,8 +53,8 @@ describe('Code node', () => {
|
||||
win.featureFlags.override('011_ask_AI', undefined);
|
||||
WorkflowPage.actions.openNode('Code');
|
||||
cy.getByTestId('code-node-tab-ai').should('not.exist');
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('Enabled', () => {
|
||||
beforeEach(() => {
|
||||
@@ -63,20 +63,19 @@ describe('Code node', () => {
|
||||
win.featureFlags.override('011_ask_AI', 'gpt3');
|
||||
WorkflowPage.actions.addInitialNodeToCanvas('Manual');
|
||||
WorkflowPage.actions.addNodeToCanvas('Code', true, true);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
it('tab should exist if experiment selected and be selectable', () => {
|
||||
cy.getByTestId('code-node-tab-ai').should('exist');
|
||||
cy.get('#tab-ask-ai').click();
|
||||
cy.contains('Hey AI, generate JavaScript').should('exist');
|
||||
})
|
||||
cy.getByTestId('code-node-tab-ai').should('exist');
|
||||
cy.get('#tab-ask-ai').click();
|
||||
cy.contains('Hey AI, generate JavaScript').should('exist');
|
||||
});
|
||||
|
||||
it('generate code button should have correct state & tooltips', () => {
|
||||
cy.getByTestId('code-node-tab-ai').should('exist');
|
||||
cy.get('#tab-ask-ai').click();
|
||||
|
||||
|
||||
cy.getByTestId('ask-ai-cta').should('be.disabled');
|
||||
cy.getByTestId('ask-ai-cta').realHover();
|
||||
cy.getByTestId('ask-ai-cta-tooltip-no-input-data').should('exist');
|
||||
@@ -85,7 +84,7 @@ describe('Code node', () => {
|
||||
cy.getByTestId('ask-ai-cta-tooltip-no-prompt').should('exist');
|
||||
cy.getByTestId('ask-ai-prompt-input')
|
||||
// Type random 14 character string
|
||||
.type([...Array(14)].map(() => (Math.random() * 36 | 0).toString(36)).join(''))
|
||||
.type([...Array(14)].map(() => ((Math.random() * 36) | 0).toString(36)).join(''));
|
||||
|
||||
cy.getByTestId('ask-ai-cta').realHover();
|
||||
cy.getByTestId('ask-ai-cta-tooltip-prompt-too-short').should('exist');
|
||||
@@ -93,64 +92,66 @@ describe('Code node', () => {
|
||||
cy.getByTestId('ask-ai-prompt-input')
|
||||
.clear()
|
||||
// Type random 15 character string
|
||||
.type([...Array(15)].map(() => (Math.random() * 36 | 0).toString(36)).join(''))
|
||||
.type([...Array(15)].map(() => ((Math.random() * 36) | 0).toString(36)).join(''));
|
||||
cy.getByTestId('ask-ai-cta').should('be.enabled');
|
||||
|
||||
cy.getByTestId('ask-ai-prompt-counter').should('contain.text', '15 / 600');
|
||||
})
|
||||
});
|
||||
|
||||
it('should send correct schema and replace code', () => {
|
||||
const prompt = [...Array(20)].map(() => (Math.random() * 36 | 0).toString(36)).join('');
|
||||
const prompt = [...Array(20)].map(() => ((Math.random() * 36) | 0).toString(36)).join('');
|
||||
cy.get('#tab-ask-ai').click();
|
||||
ndv.actions.executePrevious();
|
||||
|
||||
cy.getByTestId('ask-ai-prompt-input').type(prompt)
|
||||
cy.getByTestId('ask-ai-prompt-input').type(prompt);
|
||||
|
||||
cy.intercept('POST', '/rest/ask-ai', {
|
||||
statusCode: 200,
|
||||
body: {
|
||||
data: {
|
||||
code: 'console.log("Hello World")'
|
||||
code: 'console.log("Hello World")',
|
||||
},
|
||||
}
|
||||
},
|
||||
}).as('ask-ai');
|
||||
|
||||
cy.getByTestId('ask-ai-cta').click();
|
||||
const askAiReq = cy.wait('@ask-ai')
|
||||
const askAiReq = cy.wait('@ask-ai');
|
||||
|
||||
askAiReq.its('request.body').should('have.keys', ['question', 'model', 'context', 'n8nVersion']);
|
||||
askAiReq
|
||||
.its('request.body')
|
||||
.should('have.keys', ['question', 'model', 'context', 'n8nVersion']);
|
||||
|
||||
askAiReq.its('context').should('have.keys', ['schema', 'ndvSessionId', 'sessionId']);
|
||||
|
||||
cy.contains('Code generation completed').should('be.visible')
|
||||
cy.contains('Code generation completed').should('be.visible');
|
||||
cy.getByTestId('code-node-tab-code').should('contain.text', 'console.log("Hello World")');
|
||||
cy.get('#tab-code').should('have.class', 'is-active');
|
||||
})
|
||||
});
|
||||
|
||||
it('should show error based on status code', () => {
|
||||
const prompt = [...Array(20)].map(() => (Math.random() * 36 | 0).toString(36)).join('');
|
||||
cy.get('#tab-ask-ai').click();
|
||||
ndv.actions.executePrevious();
|
||||
const prompt = [...Array(20)].map(() => ((Math.random() * 36) | 0).toString(36)).join('');
|
||||
cy.get('#tab-ask-ai').click();
|
||||
ndv.actions.executePrevious();
|
||||
|
||||
cy.getByTestId('ask-ai-prompt-input').type(prompt)
|
||||
cy.getByTestId('ask-ai-prompt-input').type(prompt);
|
||||
|
||||
const handledCodes = [
|
||||
{ code: 400, message: 'Code generation failed due to an unknown reason' },
|
||||
{ code: 413, message: 'Your workflow data is too large for AI to process' },
|
||||
{ code: 429, message: 'We\'ve hit our rate limit with our AI partner' },
|
||||
{ code: 500, message: 'Code generation failed due to an unknown reason' },
|
||||
]
|
||||
const handledCodes = [
|
||||
{ code: 400, message: 'Code generation failed due to an unknown reason' },
|
||||
{ code: 413, message: 'Your workflow data is too large for AI to process' },
|
||||
{ code: 429, message: "We've hit our rate limit with our AI partner" },
|
||||
{ code: 500, message: 'Code generation failed due to an unknown reason' },
|
||||
];
|
||||
|
||||
handledCodes.forEach(({ code, message }) => {
|
||||
cy.intercept('POST', '/rest/ask-ai', {
|
||||
statusCode: code,
|
||||
status: code,
|
||||
}).as('ask-ai');
|
||||
handledCodes.forEach(({ code, message }) => {
|
||||
cy.intercept('POST', '/rest/ask-ai', {
|
||||
statusCode: code,
|
||||
status: code,
|
||||
}).as('ask-ai');
|
||||
|
||||
cy.getByTestId('ask-ai-cta').click();
|
||||
cy.contains(message).should('be.visible')
|
||||
})
|
||||
})
|
||||
})
|
||||
cy.getByTestId('ask-ai-cta').click();
|
||||
cy.contains(message).should('be.visible');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user