Skip to content

Commit

Permalink
Add cy.then after logout/login
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Dec 9, 2024
1 parent 6382fb5 commit bc63ce5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
46 changes: 32 additions & 14 deletions spec/cypress/e2e/vouchers_redemptions_spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ function testVoucherRedemptionWithNothingToClaim(context, role, itemType) {
helpers.redeemVoucherToBecomeRole(context, role);
helpers.verifyLectureIsSubscribed(context);
helpers.logoutAndLoginAsTeacher(context);
helpers.visitEditPage(context, itemType);
helpers.verifyNoClaimsYetButUserEligibleForRole(context, role);
helpers.verifyRoleNotification(context, role);
helpers.verifyNothingClaimedInNotification(context, itemType);

cy.then(() => {
helpers.visitEditPage(context, itemType);
helpers.verifyNoClaimsYetButUserEligibleForRole(context, role);
helpers.verifyRoleNotification(context, role);
helpers.verifyNothingClaimedInNotification(context, itemType);
});
}

function testVoucherRedemptionWithSomethingClaimed(context, itemType, role) {
Expand All @@ -31,9 +34,9 @@ function testVoucherRedemptionWithSomethingClaimed(context, itemType, role) {

helpers.verifyLectureIsSubscribed(context);
helpers.logoutAndLoginAsTeacher(context);
helpers.visitEditPage(context, itemType);

cy.then(() => {
helpers.visitEditPage(context, itemType);
helpers.verifyClaimsContainUserName(context, itemType, itemIds);
});

Expand All @@ -51,7 +54,9 @@ function testAlreadyRedeemedVoucher(context, role) {
helpers.verifyAlreadyRedeemedVoucherMessage(context, role);
helpers.verifyCancelVoucherButton();
helpers.logoutAndLoginAsTeacher(context);
helpers.verifyNoNewNotification();
cy.then(() => {
helpers.verifyNoNewNotification();
});
}

function testAlreadyRoleForAllItems(context, itemType) {
Expand All @@ -60,7 +65,9 @@ function testAlreadyRoleForAllItems(context, itemType) {
helpers.verifyAllItemsTakenMessage(context, itemType);
helpers.verifyCancelVoucherButton();
helpers.logoutAndLoginAsTeacher(context);
helpers.verifyNoNotification();
cy.then(() => {
helpers.verifyNoNotification();
});
}

describe("Verify Voucher Form", () => {
Expand Down Expand Up @@ -137,16 +144,21 @@ describe("Editor voucher redemption", () => {
helpers.verifyAlreadyRedeemedVoucherMessage(this, "editor");
helpers.verifyCancelVoucherButton();
helpers.logoutAndLoginAsTeacher(this);
helpers.verifyNoNewNotification();
cy.then(() => {
helpers.verifyNoNewNotification();
});
});
});

context("when the user is the teacher of the lecture", () => {
it("displays the message that a teacher cannot become an editor", function () {
helpers.logoutAndLoginAsTeacher(this);
helpers.submitVoucher(this.voucher);
helpers.verifyTeachersCantBecomeEditorsMessage(this);
helpers.verifyCancelVoucherButton();

cy.then(() => {
helpers.submitVoucher(this.voucher);
helpers.verifyTeachersCantBecomeEditorsMessage(this);
helpers.verifyCancelVoucherButton();
});
});
});
});
Expand All @@ -172,9 +184,12 @@ describe("Teacher voucher redemption", () => {
context("when the user is already the teacher", () => {
it("displays a message that the user is already the teacher", function () {
helpers.logoutAndLoginAsTeacher(this);
helpers.submitVoucher(this.voucher);
helpers.verifyAlreadyTeacherMessage(this);
helpers.verifyCancelVoucherButton();

cy.then(() => {
helpers.submitVoucher(this.voucher);
helpers.verifyAlreadyTeacherMessage(this);
helpers.verifyCancelVoucherButton();
});
});
});
});
Expand Down Expand Up @@ -225,6 +240,9 @@ describe("User & Redemption deletion", () => {

cy.then(() => {
helpers.logoutAndLoginAsTeacher(this);
});

cy.then(() => {
helpers.visitEditPage(this, "tutorial");
helpers.verifyNoTutorialsButUserEligibleAsTutor(this, false);
});
Expand Down
4 changes: 3 additions & 1 deletion spec/cypress/e2e/vouchers_redemptions_spec_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ export function verifyClaimsContainUserName(context, claimType, claimIds, totalC

export function logoutAndLoginAsTeacher(context) {
cy.logout();
cy.login(context.teacher);
cy.then(() => {
cy.login(context.teacher);
});
}

export function verifyNoTutorialsButUserEligibleAsTutor(context, shouldBeEligible = true) {
Expand Down

0 comments on commit bc63ce5

Please sign in to comment.