fix: Add commands for tab interception and visiting (no-changelog) (#15866)

This commit is contained in:
shortstacked
2025-05-30 14:01:12 +01:00
committed by GitHub
parent b8ab4b6a5e
commit 90aac9691d
3 changed files with 22 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import {
clickCreateNewCredential,
getNdvContainer,
selectResourceLocatorAddResourceItem,
clickGetBackToCanvas,
} from '../composables/ndv';
import * as projects from '../composables/projects';
import {
@@ -294,14 +295,12 @@ describe('Projects', { disableAutoLogin: true }, () => {
workflowPage.actions.saveWorkflowOnButtonClick();
workflowPage.actions.addNodeToCanvas('Execute Workflow', true, true);
// This mock fails when running with `test:e2e:dev` but works with `test:e2e:ui`,
// at least on macOS at version 1.94.0. ¯\_(ツ)_/¯
cy.window().then((win) => cy.stub(win, 'open').callsFake((url) => cy.visit(url)));
cy.interceptNewTab();
selectResourceLocatorAddResourceItem('workflowId', 'Create a');
// Need to wait for the trigger node to auto-open after a delay
cy.visitInterceptedTab();
getNdvContainer().should('be.visible');
cy.get('body').type('{esc}');
clickGetBackToCanvas();
workflowPage.actions.addNodeToCanvas(NOTION_NODE_NAME, true, true);
clickCreateNewCredential();
setCredentialValues({

View File

@@ -240,3 +240,18 @@ Cypress.Commands.add('resetDatabase', () => {
admin: INSTANCE_ADMIN,
});
});
Cypress.Commands.add('interceptNewTab', () => {
cy.window().then((win) => {
cy.stub(win, 'open').as('windowOpen');
});
});
Cypress.Commands.add('visitInterceptedTab', () => {
cy.get('@windowOpen')
.should('have.been.called')
.then((stub: any) => {
const url = stub.firstCall.args[0];
cy.visit(url);
});
});

View File

@@ -86,6 +86,8 @@ declare global {
>;
resetDatabase(): void;
setAppDate(targetDate: number | Date): void;
interceptNewTab(): Chainable<void>;
visitInterceptedTab(): Chainable<void>;
}
}
}