Skip to content

Commit

Permalink
fix tier three mocked cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Bangay committed Jul 31, 2024
1 parent d83e0d1 commit 70c8f07
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 17 deletions.
14 changes: 7 additions & 7 deletions client/fixtures/productBuilder/baseProducts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ export function baseTierThree(): ProductDetail {
phoneRegionsToDisplay: ['UK & ROW', 'US', 'AUS'],
},
billingCountry: 'United Kingdom',
joinDate: '2024-06-13',
joinDate: '2021-11-29',
optIn: true,
subscription: {
paymentMethod: 'Card',
Expand All @@ -532,15 +532,15 @@ export function baseTierThree(): ProductDetail {
country: 'United Kingdom',
},
safeToUpdatePaymentMethod: true,
start: '2024-06-28',
end: '2025-06-13',
start: '2021-12-24',
end: '2022-12-15',
nextPaymentPrice: 2500,
nextPaymentDate: '2024-06-28',
lastPaymentDate: null,
potentialCancellationDate: null,
chargedThroughDate: null,
renewalDate: '2025-06-13',
anniversaryDate: '2025-06-28',
renewalDate: '2022-12-15',
anniversaryDate: '2022-12-24',
cancelledAt: false,
subscriptionId: 'A-S00897035',
trialLength: 4,
Expand All @@ -560,8 +560,8 @@ export function baseTierThree(): ProductDetail {
futurePlans: [
{
name: null,
start: '2024-06-28',
end: '2025-06-13',
start: '2021-12-10',
end: '2022-11-29',
shouldBeVisible: true,
chargedThrough: null,
price: 2500,
Expand Down
8 changes: 7 additions & 1 deletion cypress/tests/mocked/parallel-2/cancelContribution.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ describe('Cancel contribution', () => {
};

beforeEach(() => {
const contributionCancelled = JSON.parse(
JSON.stringify(contributionPaidByCard()),
);
contributionCancelled.subscription.cancelledAt = true;

cy.setCookie('GU_mvt_id', '0');

signInAndAcceptCookies();
Expand Down Expand Up @@ -66,8 +71,9 @@ describe('Cancel contribution', () => {

cy.intercept('GET', '/api/me/mma/**', {
statusCode: 200,
body: toMembersDataApiResponse(),
body: toMembersDataApiResponse(contributionCancelled),
}).as('new_product_detail');

cy.intercept('GET', '/api/cancelled/', {
statusCode: 200,
body: [],
Expand Down
22 changes: 16 additions & 6 deletions cypress/tests/mocked/parallel-2/cancelGW.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ import { toMembersDataApiResponse } from '../../../../client/fixtures/mdapiRespo
import { signInAndAcceptCookies } from '../../../lib/signInAndAcceptCookies';

describe('Cancel guardian weekly', () => {
const GWwithSelfCancelEnabled = JSON.parse(
JSON.stringify(guardianWeeklyPaidByCard()),
);
GWwithSelfCancelEnabled.selfServiceCancellation.isAllowed = true;

const GWSelfCancelEnabledAndCancelled = JSON.parse(
JSON.stringify(guardianWeeklyPaidByCard()),
);
GWSelfCancelEnabledAndCancelled.subscription.cancelledAt = true;

beforeEach(() => {
signInAndAcceptCookies();

const GWwithSelfCancelEnabled = JSON.parse(
JSON.stringify(guardianWeeklyPaidByCard()),
);
GWwithSelfCancelEnabled.selfServiceCancellation.isAllowed = true;

cy.intercept('POST', '/api/case', {
statusCode: 200,
body: {
Expand Down Expand Up @@ -45,7 +50,7 @@ describe('Cancel guardian weekly', () => {

cy.intercept('GET', '/api/me/mma/**', {
statusCode: 200,
body: toMembersDataApiResponse(),
body: toMembersDataApiResponse(GWwithSelfCancelEnabled),
}).as('new_product_detail');

cy.intercept('GET', '/api/cancelled/', {
Expand Down Expand Up @@ -105,6 +110,11 @@ describe('Cancel guardian weekly', () => {
});

it('cancels Guardian Weekly (reason: I dont have time to use my subscription, effective: next billing date)', () => {
cy.intercept('GET', '/api/me/mma/**', {
statusCode: 200,
body: toMembersDataApiResponse(GWSelfCancelEnabledAndCancelled),
}).as('new_product_detail');

cy.visit('/');

cy.findByText('Manage subscription').click();
Expand Down
4 changes: 2 additions & 2 deletions cypress/tests/mocked/parallel-2/cancelSupporterPlus.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Cancel Supporter Plus', () => {

cy.intercept('GET', '/api/me/mma/**', {
statusCode: 200,
body: toMembersDataApiResponse(),
body: toMembersDataApiResponse(supporterPlus()),
}).as('new_product_detail');

cy.intercept('GET', '/api/cancelled/', {
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('Cancel Supporter Plus', () => {

cy.intercept('GET', '/api/me/mma/**', {
statusCode: 200,
body: toMembersDataApiResponse(),
body: toMembersDataApiResponse(supporterPlusCancelled()),
}).as('get_cancelled_product');

cy.findByRole('radio', {
Expand Down
9 changes: 8 additions & 1 deletion cypress/tests/mocked/parallel-3/holidayStops.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
existingHolidaysFirstIssueDecember,
yearSpanningPotentialDeliveries,
} from '../../../../client/fixtures/holidays';
import { guardianWeeklyPaidByCard } from '../../../../client/fixtures/productBuilder/testProducts';
import {
guardianWeeklyPaidByCard,
tierThree,
} from '../../../../client/fixtures/productBuilder/testProducts';
import { signInAndAcceptCookies } from '../../../lib/signInAndAcceptCookies';

describe('Holiday stops', () => {
Expand Down Expand Up @@ -86,6 +89,10 @@ describe('Holiday stops', () => {
});

it('can add a new holiday stop for Tier Three', () => {
cy.intercept('GET', '/api/me/mma?productType=TierThree', {
statusCode: 200,
body: toMembersDataApiResponse(tierThree()),
}).as('product_detail');
cy.visit('/suspend/digital+print');
cy.wait('@fetch_existing_holidays');
cy.wait('@product_detail');
Expand Down

0 comments on commit 70c8f07

Please sign in to comment.