mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
fix(editor): Adjust URL on lost change warning Cancel or failed save (#13683)
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
export function getSaveChangesModal() {
|
||||
return cy.get('.el-overlay').contains('Save changes before leaving?');
|
||||
}
|
||||
|
||||
// this is the button next to 'Save Changes'
|
||||
export function getCancelSaveChangesButton() {
|
||||
return cy.get('.btn--cancel');
|
||||
}
|
||||
|
||||
// This is the top right 'x'
|
||||
export function getCloseSaveChangesButton() {
|
||||
return cy.get('.el-message-box__headerbtn');
|
||||
}
|
||||
|
||||
@@ -6,6 +6,10 @@ export function getWorkflowsPageUrl() {
|
||||
return '/home/workflows';
|
||||
}
|
||||
|
||||
export const getCreateWorkflowButton = () => cy.getByTestId('add-resource-workflow');
|
||||
|
||||
export const getNewWorkflowCardButton = () => cy.getByTestId('new-workflow-card');
|
||||
|
||||
/**
|
||||
* Actions
|
||||
*/
|
||||
|
||||
@@ -1,26 +1,59 @@
|
||||
import { getSaveChangesModal } from '../composables/modals/save-changes-modal';
|
||||
import {
|
||||
getCancelSaveChangesButton,
|
||||
getCloseSaveChangesButton,
|
||||
getSaveChangesModal,
|
||||
} from '../composables/modals/save-changes-modal';
|
||||
import { getHomeButton } from '../composables/projects';
|
||||
import { addNodeToCanvas } from '../composables/workflow';
|
||||
import {
|
||||
getCreateWorkflowButton,
|
||||
getNewWorkflowCardButton,
|
||||
getWorkflowsPageUrl,
|
||||
visitWorkflowsPage,
|
||||
} from '../composables/workflowsPage';
|
||||
import { EDIT_FIELDS_SET_NODE_NAME } from '../constants';
|
||||
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
|
||||
import { WorkflowsPage as WorkflowsPageClass } from '../pages/workflows';
|
||||
|
||||
const WorkflowsPage = new WorkflowsPageClass();
|
||||
const WorkflowPage = new WorkflowPageClass();
|
||||
|
||||
describe('Workflows', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit(WorkflowsPage.url);
|
||||
visitWorkflowsPage();
|
||||
});
|
||||
|
||||
it('should ask to save unsaved changes before leaving route', () => {
|
||||
WorkflowsPage.getters.newWorkflowButtonCard().should('be.visible');
|
||||
WorkflowsPage.getters.newWorkflowButtonCard().click();
|
||||
getNewWorkflowCardButton().should('be.visible');
|
||||
getNewWorkflowCardButton().click();
|
||||
|
||||
cy.createFixtureWorkflow('Test_workflow_1.json', 'Empty State Card Workflow');
|
||||
|
||||
WorkflowPage.actions.addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME);
|
||||
addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME);
|
||||
|
||||
cy.getByTestId('project-home-menu-item').click();
|
||||
getHomeButton().click();
|
||||
|
||||
// We expect to still be on the workflow route here
|
||||
cy.url().should('include', '/workflow/');
|
||||
|
||||
getSaveChangesModal().should('be.visible');
|
||||
getCancelSaveChangesButton().click();
|
||||
|
||||
// Only now do we switch
|
||||
cy.url().should('include', getWorkflowsPageUrl());
|
||||
});
|
||||
|
||||
it('should correct route after cancelling saveChangesModal', () => {
|
||||
getCreateWorkflowButton().click();
|
||||
|
||||
cy.createFixtureWorkflow('Test_workflow_1.json', 'Empty State Card Workflow');
|
||||
addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME);
|
||||
|
||||
// Here we go back via browser rather than the home button
|
||||
// As this already updates the route
|
||||
cy.go(-1);
|
||||
|
||||
cy.url().should('include', getWorkflowsPageUrl());
|
||||
|
||||
getSaveChangesModal().should('be.visible');
|
||||
getCloseSaveChangesButton().click();
|
||||
|
||||
// Confirm the url is back to the workflow
|
||||
cy.url().should('include', '/workflow/');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user