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:
@@ -31,12 +31,11 @@ describe('applications', () => {
|
||||
cy.get('[data-e2e="continue-button-redirecturis"]').click();
|
||||
cy.get('[data-e2e="create-button"]').click();
|
||||
cy.get('[id*=overlay]').should('exist');
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldConfirmSuccess();
|
||||
const expectClientId = new RegExp(`^.*[0-9]+\\@${testProjectName}.*$`);
|
||||
cy.get('[data-e2e="client-id-copy"]').click();
|
||||
cy.contains('[data-e2e="client-id"]', expectClientId);
|
||||
cy.clipboardMatches(expectClientId);
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -32,14 +32,13 @@ describe('humans', () => {
|
||||
cy.get('[formcontrolname="lastName"]').type('e2ehumanlastname');
|
||||
cy.get('[formcontrolname="phone"]').type('+41 123456789');
|
||||
cy.get('[data-e2e="create-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldConfirmSuccess();
|
||||
let loginName = user.addName;
|
||||
if (user.mustBeDomain) {
|
||||
loginName = loginname(user.addName, Cypress.env('ORGANIZATION'));
|
||||
}
|
||||
cy.contains('[data-e2e="copy-loginname"]', loginName).click();
|
||||
cy.clipboardMatches(loginName);
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -58,9 +57,11 @@ describe('humans', () => {
|
||||
cy.get(rowSelector).find('[data-e2e="enabled-delete-button"]').click({ force: true });
|
||||
cy.get('[data-e2e="confirm-dialog-input"]').focus().type(loginName);
|
||||
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldNotExist({ selector: rowSelector, timeout: 2000 });
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
cy.shouldConfirmSuccess();
|
||||
cy.shouldNotExist({
|
||||
selector: rowSelector,
|
||||
timeout: { ms: 2000, errMessage: 'timed out before human disappeared from the table' },
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -30,14 +30,13 @@ describe('machines', () => {
|
||||
cy.get('[formcontrolname="name"]').type('e2emachinename');
|
||||
cy.get('[formcontrolname="description"]').type('e2emachinedescription');
|
||||
cy.get('[data-e2e="create-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldConfirmSuccess();
|
||||
let loginName = machine.addName;
|
||||
if (machine.mustBeDomain) {
|
||||
loginName = loginname(machine.addName, Cypress.env('ORGANIZATION'));
|
||||
}
|
||||
cy.contains('[data-e2e="copy-loginname"]', loginName).click();
|
||||
cy.clipboardMatches(loginName);
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -56,9 +55,11 @@ describe('machines', () => {
|
||||
cy.get(rowSelector).find('[data-e2e="enabled-delete-button"]').click({ force: true });
|
||||
cy.get('[data-e2e="confirm-dialog-input"]').focus().type(loginName);
|
||||
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldNotExist({ selector: rowSelector, timeout: 2000 });
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
cy.shouldConfirmSuccess();
|
||||
cy.shouldNotExist({
|
||||
selector: rowSelector,
|
||||
timeout: { ms: 2000, errMessage: 'timed out before machine disappeared from the table' },
|
||||
});
|
||||
});
|
||||
|
||||
it('should create a personal access token');
|
||||
|
@@ -27,8 +27,7 @@ describe('organizations', () => {
|
||||
|
||||
cy.get('[data-e2e="name"]').focus().clear().type(testOrgNameChange);
|
||||
cy.get('[data-e2e="dialog-submit"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
cy.shouldConfirmSuccess();
|
||||
cy.visit(orgPath);
|
||||
cy.get('[data-e2e="top-view-title"').should('contain', testOrgNameChange);
|
||||
});
|
||||
|
@@ -39,9 +39,8 @@ describe('permissions', () => {
|
||||
cy.get('[data-e2e="user-option"]').click();
|
||||
cy.contains('[data-e2e="role-checkbox"]', roles[0]).click();
|
||||
cy.get('[data-e2e="confirm-add-member-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldConfirmSuccess();
|
||||
cy.contains('[data-e2e="member-avatar"]', 'ee');
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -59,9 +58,11 @@ describe('permissions', () => {
|
||||
it('should remove a manager', () => {
|
||||
cy.get('@managerRow').find('[data-e2e="remove-member-button"]').click({ force: true });
|
||||
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldNotExist({ selector: rowSelector, timeout: 2000 });
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
cy.shouldConfirmSuccess();
|
||||
cy.shouldNotExist({
|
||||
selector: rowSelector,
|
||||
timeout: { ms: 2000, errMessage: 'timed out before manager disappeared from the table' },
|
||||
});
|
||||
});
|
||||
|
||||
it('should remove a managers authorization', () => {
|
||||
@@ -71,11 +72,10 @@ describe('permissions', () => {
|
||||
.find('[data-e2e="remove-role-button"]')
|
||||
.click({ force: true }); // TODO: Is this a bug?
|
||||
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldConfirmSuccess();
|
||||
cy.get('@managerRow')
|
||||
.find('[data-e2e="remove-role-button"]')
|
||||
.should('have.length', roles.length - 1);
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -156,9 +156,8 @@ describe('permissions', () => {
|
||||
cy.get('[formcontrolname="displayName"]').type('e2eroleundertestdisplay');
|
||||
cy.get('[formcontrolname="group"]').type('e2eroleundertestgroup');
|
||||
cy.get('[data-e2e="save-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldConfirmSuccess();
|
||||
cy.contains('tr', testRoleName);
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
});
|
||||
it('should remove a role');
|
||||
});
|
||||
|
@@ -19,8 +19,7 @@ describe('projects', () => {
|
||||
cy.get('.add-project-button').click({ force: true });
|
||||
cy.get('input').type(testProjectNameCreate);
|
||||
cy.get('[data-e2e="continue-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
cy.shouldConfirmSuccess();
|
||||
});
|
||||
|
||||
it('should configure a project to assert roles on authentication');
|
||||
@@ -40,9 +39,11 @@ describe('projects', () => {
|
||||
cy.get(rowSelector).find('[data-e2e="delete-project-button"]').click({ force: true });
|
||||
cy.get('[data-e2e="confirm-dialog-input"]').focus().type(testProjectNameDelete);
|
||||
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldNotExist({ selector: rowSelector, timeout: 2000 });
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
cy.shouldConfirmSuccess();
|
||||
cy.shouldNotExist({
|
||||
selector: rowSelector,
|
||||
timeout: { ms: 2000, errMessage: 'timed out before project disappeared from the table' },
|
||||
});
|
||||
});
|
||||
|
||||
it('removes the project from grid view', () => {
|
||||
@@ -50,9 +51,11 @@ describe('projects', () => {
|
||||
cy.get(cardSelector).find('[data-e2e="delete-project-button"]').click({ force: true });
|
||||
cy.get('[data-e2e="confirm-dialog-input"]').focus().type(testProjectNameDelete);
|
||||
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldNotExist({ selector: cardSelector, timeout: 2000 });
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
cy.shouldConfirmSuccess();
|
||||
cy.shouldNotExist({
|
||||
selector: cardSelector,
|
||||
timeout: { ms: 2000, errMessage: 'timed out before project disappeared from the grid' },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -33,6 +33,6 @@ describe('oidc settings', () => {
|
||||
.clear()
|
||||
.type('7');
|
||||
cy.get('[data-e2e="save-button"]').click();
|
||||
cy.get('.data-e2e-success');
|
||||
cy.shouldConfirmSuccess();
|
||||
});
|
||||
});
|
||||
|
@@ -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