Skip to content

Commit

Permalink
use nanoid as random string generator in cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy committed Jun 19, 2024
1 parent cd89317 commit 5c51d36
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
10 changes: 5 additions & 5 deletions cypress/e2e/6-code-node.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { randomString } from 'n8n-workflow';
import { nanoid } from 'nanoid';
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
import { NDV } from '../pages/ndv';
import { successToast } from '../pages/notifications';
Expand Down Expand Up @@ -86,22 +86,22 @@ 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(randomString(14));
.type(nanoid(14));

cy.getByTestId('ask-ai-cta').realHover();
cy.getByTestId('ask-ai-cta-tooltip-prompt-too-short').should('exist');

cy.getByTestId('ask-ai-prompt-input')
.clear()
// Type random 15 character string
.type(randomString(15));
.type(nanoid(15));
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 = randomString(20);
const prompt = nanoid(20);
cy.get('#tab-ask-ai').click();
ndv.actions.executePrevious();

Expand Down Expand Up @@ -131,7 +131,7 @@ describe('Code node', () => {
});

it('should show error based on status code', () => {
const prompt = randomString(20);
const prompt = nanoid(20);
cy.get('#tab-ask-ai').click();
ndv.actions.executePrevious();

Expand Down
4 changes: 2 additions & 2 deletions cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
},
"devDependencies": {
"@types/lodash": "^4.14.195",
"eslint-plugin-cypress": "^3.3.0"
"eslint-plugin-cypress": "^3.3.0",
"n8n-workflow": "workspace:*"
},
"dependencies": {
"@ngneat/falso": "^7.2.0",
Expand All @@ -25,7 +26,6 @@
"cypress-real-events": "^1.12.0",
"lodash": "4.17.21",
"nanoid": "3.3.6",
"n8n-workflow": "workspace:*",
"start-server-and-test": "^2.0.3"
}
}
11 changes: 3 additions & 8 deletions cypress/utils/executions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import {
randomString,
type IDataObject,
type IPinData,
type ITaskData,
type ITaskDataConnections,
} from 'n8n-workflow';
import { nanoid } from 'nanoid';
import type { IDataObject, IPinData, ITaskData, ITaskDataConnections } from 'n8n-workflow';
import { clickExecuteWorkflowButton } from '../composables/workflow';

export function createMockNodeExecutionData(
Expand Down Expand Up @@ -91,7 +86,7 @@ export function runMockWorkflowExecution({
runData: Array<ReturnType<typeof createMockNodeExecutionData>>;
workflowExecutionData?: ReturnType<typeof createMockWorkflowExecutionData>;
}) {
const executionId = randomString(8);
const executionId = nanoid(8);

cy.intercept('POST', '/rest/workflows/**/run', {
statusCode: 201,
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5c51d36

Please sign in to comment.