mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:37:32 +00:00
test(e2e): improve error reporting (#4931)
* cleanup * test(e2e): improve error reporting * lint * lint * better timeout messages * fix shouldNotExist
This commit is contained in:
@@ -26,8 +26,11 @@ import 'cypress-wait-until';
|
||||
//
|
||||
|
||||
interface ShouldNotExistOptions {
|
||||
selector?: string;
|
||||
timeout?: number;
|
||||
selector: string;
|
||||
timeout?: {
|
||||
errMessage: string;
|
||||
ms: number;
|
||||
};
|
||||
}
|
||||
|
||||
declare global {
|
||||
@@ -43,7 +46,11 @@ declare global {
|
||||
/**
|
||||
* Custom command that waits until the selector finds zero elements.
|
||||
*/
|
||||
shouldNotExist(options?: ShouldNotExistOptions): Cypress.Chainable<null>;
|
||||
shouldNotExist(options: ShouldNotExistOptions): Cypress.Chainable<null>;
|
||||
/**
|
||||
* Custom command that asserts success is printed after a change.
|
||||
*/
|
||||
shouldConfirmSuccess(): Cypress.Chainable<null>;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,11 +77,32 @@ Cypress.Commands.add('clipboardMatches', { prevSubject: false }, (pattern: RegEx
|
||||
*/
|
||||
});
|
||||
|
||||
Cypress.Commands.add('shouldNotExist', { prevSubject: false }, (options?: ShouldNotExistOptions) => {
|
||||
return cy.waitUntil(
|
||||
() => {
|
||||
return Cypress.$(options?.selector).length === 0;
|
||||
},
|
||||
{ timeout: typeof options?.timeout === 'number' ? options.timeout : 500 },
|
||||
);
|
||||
Cypress.Commands.add('shouldNotExist', { prevSubject: false }, (options: ShouldNotExistOptions) => {
|
||||
if (!options.timeout) {
|
||||
const elements = Cypress.$(options.selector);
|
||||
expect(elements.text()).to.be.empty;
|
||||
expect(elements.length).to.equal(0);
|
||||
return null;
|
||||
}
|
||||
return cy
|
||||
.waitUntil(
|
||||
() => {
|
||||
const elements = Cypress.$(options.selector);
|
||||
if (!elements.length) {
|
||||
return cy.wrap(true);
|
||||
}
|
||||
return cy.log(`elements with selector ${options.selector} and text ${elements.text()} exist`).wrap(false);
|
||||
},
|
||||
{
|
||||
timeout: options.timeout.ms,
|
||||
errorMsg: options.timeout.errMessage,
|
||||
},
|
||||
)
|
||||
.then(() => null);
|
||||
});
|
||||
|
||||
Cypress.Commands.add('shouldConfirmSuccess', { prevSubject: false }, () => {
|
||||
cy.get('.data-e2e-message');
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
cy.get('.data-e2e-success');
|
||||
});
|
||||
|
@@ -1,5 +1,3 @@
|
||||
import { debug } from 'console';
|
||||
|
||||
export enum User {
|
||||
OrgOwner = 'org_owner',
|
||||
OrgOwnerViewer = 'org_owner_viewer',
|
||||
|
Reference in New Issue
Block a user