Skip to content

Commit

Permalink
test: waits
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Jan 24, 2025
1 parent b58c211 commit 9e7d396
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 14 deletions.
6 changes: 6 additions & 0 deletions cypress/e2e/organizations/groups.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,31 @@ describe('Organization Groups page', () => {
aliasMutation(req, 'addGroupToOrganization');
});
registerIdleHandler('groupQuery');
registerIdleHandler('idle');

cy.login(Cypress.env('user_platformowner'), Cypress.env('user_platformowner'));
cy.visit(`${Cypress.env('url')}/organizations/lagoon-demo-organization/groups`);
});

it('Adds a group', () => {
cy.waitForNetworkIdle('@idle', 1000);
group.doAddGroup(testData.organizations.groups.newGroupName, testData.organizations.groups.newGroupName2);
});

it('Searches groups', () => {
cy.waitForNetworkIdle('@idle', 1000);
group.doGroupSearch(testData.organizations.groups.newGroupName, testData.organizations.groups.newGroupName2);
});

it('Adds a member to a group', () => {
cy.waitForNetworkIdle('@idle', 1000);
group.doAddMemberToGroup(testData.organizations.users.email, testData.organizations.groups.newGroupName);
});

it('Deletes groups', () => {
cy.waitForNetworkIdle('@idle', 1000);
group.doDeleteGroup(testData.organizations.groups.newGroupName);
cy.waitForNetworkIdle('@idle', 1000);
group.doDeleteGroup(testData.organizations.groups.newGroupName2);
});
});
18 changes: 12 additions & 6 deletions cypress/e2e/organizations/notifications.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,34 @@ describe('Org Notifications page', () => {
});

it('Adds Slack notification', () => {
cy.waitForNetworkIdle('@idle', 1000);
const slackData = testData.organizations.notifications.slack;

notifications.doAddNotification('slack', slackData);
});
it('Adds Rocketchat notification', () => {
cy.waitForNetworkIdle('@idle', 1000);
const rocketData = testData.organizations.notifications.rocketChat;
notifications.doAddNotification('rocketChat', rocketData);
});
it('Adds Teams notification', () => {
cy.waitForNetworkIdle('@idle', 1000);
const teamsData = testData.organizations.notifications.teams;
notifications.doAddNotification('teams', teamsData);
});
it('Adds Email notification', () => {
cy.waitForNetworkIdle('@idle', 1000);
const emailData = testData.organizations.notifications.email;
notifications.doAddNotification('email', emailData);
});
it('Adds Webhook notification', () => {
cy.waitForNetworkIdle('@idle', 1000);
const webhookData = testData.organizations.notifications.webhook;
notifications.doAddNotification('webhook', webhookData);
});

it('Edits notification', () => {
cy.waitForNetworkIdle('@idle', 500);
cy.waitForNetworkIdle('@idle', 1000);
notifications.doEditNotification();
});

Expand All @@ -57,15 +62,16 @@ describe('Org Notifications page', () => {
slack: { name: slackName },
} = testData.organizations.notifications;

cy.waitForNetworkIdle('@idle', 500);
cy.waitForNetworkIdle('@idle', 1000);
notifications.doDeleteNotification(webhooknName);
cy.waitForNetworkIdle('@idle', 500);
cy.waitForNetworkIdle('@idle', 1000);
notifications.doDeleteNotification(emailName);
cy.waitForNetworkIdle('@idle', 500);
cy.waitForNetworkIdle('@idle', 1000);
notifications.doDeleteNotification(teamsName);
cy.waitForNetworkIdle('@idle', 500);
cy.waitForNetworkIdle('@idle', 1000);
notifications.doDeleteNotification(rocketChatName);
cy.waitForNetworkIdle('@idle', 500);
cy.waitForNetworkIdle('@idle', 1000);
notifications.doDeleteNotification(slackName);
cy.waitForNetworkIdle('@idle', 1000);
});
});
11 changes: 9 additions & 2 deletions cypress/e2e/organizations/users.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,41 @@ describe('Org Users page', () => {
beforeEach(() => {
cy.login(Cypress.env('user_platformowner'), Cypress.env('user_platformowner'));
cy.visit(`${Cypress.env('url')}/organizations/lagoon-demo-organization/users`);
registerIdleHandler('idle');
cy.waitForNetworkIdle('@idle', 1000);

cy.intercept('POST', Cypress.env('api'), req => {
aliasQuery(req, 'getOrganization');
aliasMutation(req, 'addUserToGroup');
aliasMutation(req, 'removeUserFromGroup');
aliasMutation(req, 'addGroupToOrganization');
});
registerIdleHandler('idle');
cy.waitForNetworkIdle('@idle', 1000);
});

it('Creates a group', () => {
cy.visit(`${Cypress.env('url')}/organizations/lagoon-demo-organization/groups`);
cy.waitForNetworkIdle('@idle', 1000);
group.doAddGroup(testData.organizations.groups.newGroupName, testData.organizations.groups.newGroupName2);
});

it('Adds a user to the group', () => {
cy.waitForNetworkIdle('@idle', 1000);
users.doAddUser(testData.organizations.users.email);
});

it('Deletes user', () => {
cy.waitForNetworkIdle('@idle', 500);
cy.waitForNetworkIdle('@idle', 1000);
users.doDeleteUser(testData.organizations.users.email);
});

after(() => {
cy.waitForNetworkIdle('@idle', 1000);
cy.visit(`${Cypress.env('url')}/organizations/lagoon-demo-organization/groups`);
cy.waitForNetworkIdle('@idle', 1000);
registerIdleHandler('groupQuery');
group.doDeleteGroup(testData.organizations.groups.newGroupName);
cy.waitForNetworkIdle('@idle', 1000);
group.doDeleteGroup(testData.organizations.groups.newGroupName2);
});
});
4 changes: 1 addition & 3 deletions cypress/e2e/rbac/maintainer.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ describe('MAINTAINER permission test suites', () => {

variable.doDeleteVariable(name);

cy.intercept('POST', Cypress.env('api')).as('deleteRequest');

cy.wait('@deleteRequest');
cy.waitForNetworkIdle('@idle', 500);

cy.contains('No Project variables set').should('exist');
});
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/rbac/organizations/orgViewer.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe(`Organizations ORGVIEWER journey`, () => {

it('Navigates to a project, fails to add a group or notifications - no permission for ORGVIEWER', () => {
cy.visit(`${Cypress.env('url')}/organizations/lagoon-demo-organization/projects/lagoon-demo-org`);
cy.waitForNetworkIdle('@idle', 1000);

cy.getBySel('addGroupToProject').click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ orgownerAndPlatformOwner.forEach(owner => {
testData.organizations.project.projectName
}`
);
cy.waitForNetworkIdle('@idle', 1000);

cy.getBySel('addGroupToProject').click();

Expand Down Expand Up @@ -140,6 +141,8 @@ orgownerAndPlatformOwner.forEach(owner => {

group.doDeleteGroup(testData.organizations.groups.newGroupName);
cy.wait('@gqldeleteGroupMutation');

cy.waitForNetworkIdle('@idle', 500);

group.doDeleteGroup(testData.organizations.groups.newGroupName2);
cy.wait('@gqldeleteGroupMutation');
Expand Down
6 changes: 3 additions & 3 deletions cypress/support/actions/organizations/GroupsAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default class GroupAction {
groupRepo.getAddGroupSubmitBtn().click();

cy.wait(['@gqladdGroupToOrganizationMutation', '@gqlgetOrganizationQuery']);
cy.waitForNetworkIdle('@idle', 1000);
cy.getBySel('table-row').should('contain', newGroup1);

cy.log('Add another');
Expand All @@ -19,6 +20,7 @@ export default class GroupAction {
groupRepo.getAddGroupSubmitBtn().click();

cy.wait(['@gqladdGroupToOrganizationMutation', '@gqlgetOrganizationQuery']);
cy.waitForNetworkIdle('@idle', 1000);

cy.getBySel('table-row').should('contain', newGroup2);
}
Expand Down Expand Up @@ -76,9 +78,7 @@ export default class GroupAction {
groupRepo.getDeleteGroupBtn('deleteGroup').first().click();
cy.getBySel('confirm').click();

cy.intercept('POST', Cypress.env('api')).as('deleteGroup');
cy.wait('@deleteGroup');
cy.waitForNetworkIdle('@groupQuery', 500);
cy.waitForNetworkIdle('@idle', 1000);

cy.getBySel('label-text').each($span => {
const text = $span.text();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default class NotificationsAction {
cy.getBySel('addNotifBtn').click();

cy.wait(`@gqladdNotification${getMutationName(notifType)}Mutation`);
cy.waitForNetworkIdle('@idle', 1000);

// notification name
cy.getBySel('notification-row').should('include.text', notificationData.name);
Expand Down

0 comments on commit 9e7d396

Please sign in to comment.