mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Added offer link tests with portal button disabled
closes https://github.com/TryGhost/Team/issues/1323
This commit is contained in:
parent
0ffa5830fd
commit
c0500c1a40
2 changed files with 115 additions and 4 deletions
|
@ -31,8 +31,8 @@ const offerSetup = async ({site, member = null, offer}) => {
|
|||
<App api={ghostApi} />
|
||||
);
|
||||
|
||||
const triggerButtonFrame = await utils.findByTitle(/portal-trigger/i);
|
||||
const popupFrame = utils.queryByTitle(/portal-popup/i);
|
||||
const popupFrame = await utils.findByTitle(/portal-popup/i);
|
||||
const triggerButtonFrame = await utils.queryByTitle(/portal-trigger/i);
|
||||
const popupIframeDocument = popupFrame.contentDocument;
|
||||
const emailInput = within(popupIframeDocument).queryByLabelText(/email/i);
|
||||
const nameInput = within(popupIframeDocument).queryByLabelText(/name/i);
|
||||
|
@ -481,6 +481,42 @@ describe('Signup', () => {
|
|||
|
||||
window.location.hash = '';
|
||||
});
|
||||
|
||||
test('to an offer via link with portal disabled', async () => {
|
||||
let site = {
|
||||
...FixtureSite.singleTier.basic,
|
||||
portal_button: false
|
||||
};
|
||||
window.location.hash = `#/portal/offers/${FixtureOffer.id}`;
|
||||
const {
|
||||
ghostApi, popupFrame, triggerButtonFrame, emailInput, nameInput, signinButton, submitButton,
|
||||
siteTitle,
|
||||
offerName, offerDescription
|
||||
} = await offerSetup({
|
||||
site,
|
||||
offer: FixtureOffer
|
||||
});
|
||||
let planId = FixtureSite.singleTier.basic.products.find(p => p.type === 'paid').monthlyPrice.id;
|
||||
let offerId = FixtureOffer.id;
|
||||
expect(popupFrame).toBeInTheDocument();
|
||||
expect(triggerButtonFrame).not.toBeInTheDocument();
|
||||
expect(siteTitle).not.toBeInTheDocument();
|
||||
expect(emailInput).not.toBeInTheDocument();
|
||||
expect(nameInput).not.toBeInTheDocument();
|
||||
expect(signinButton).not.toBeInTheDocument();
|
||||
expect(submitButton).not.toBeInTheDocument();
|
||||
expect(offerName).not.toBeInTheDocument();
|
||||
expect(offerDescription).not.toBeInTheDocument();
|
||||
|
||||
expect(ghostApi.member.checkoutPlan).toHaveBeenLastCalledWith({
|
||||
email: undefined,
|
||||
name: undefined,
|
||||
offerId: offerId,
|
||||
plan: planId
|
||||
});
|
||||
|
||||
window.location.hash = '';
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -666,5 +702,41 @@ describe('Signup', () => {
|
|||
|
||||
window.location.hash = '';
|
||||
});
|
||||
|
||||
test('to an offer via link with portal disabled', async () => {
|
||||
let site = {
|
||||
...FixtureSite.multipleTiers.basic,
|
||||
portal_button: false
|
||||
};
|
||||
window.location.hash = `#/portal/offers/${FixtureOffer.id}`;
|
||||
const {
|
||||
ghostApi, popupFrame, triggerButtonFrame, emailInput, nameInput, signinButton, submitButton,
|
||||
siteTitle,
|
||||
offerName, offerDescription
|
||||
} = await offerSetup({
|
||||
site,
|
||||
offer: FixtureOffer
|
||||
});
|
||||
let planId = FixtureSite.singleTier.basic.products.find(p => p.type === 'paid').monthlyPrice.id;
|
||||
let offerId = FixtureOffer.id;
|
||||
expect(popupFrame).toBeInTheDocument();
|
||||
expect(triggerButtonFrame).not.toBeInTheDocument();
|
||||
expect(siteTitle).not.toBeInTheDocument();
|
||||
expect(emailInput).not.toBeInTheDocument();
|
||||
expect(nameInput).not.toBeInTheDocument();
|
||||
expect(signinButton).not.toBeInTheDocument();
|
||||
expect(submitButton).not.toBeInTheDocument();
|
||||
expect(offerName).not.toBeInTheDocument();
|
||||
expect(offerDescription).not.toBeInTheDocument();
|
||||
|
||||
expect(ghostApi.member.checkoutPlan).toHaveBeenLastCalledWith({
|
||||
email: undefined,
|
||||
name: undefined,
|
||||
offerId: offerId,
|
||||
plan: planId
|
||||
});
|
||||
|
||||
window.location.hash = '';
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -31,8 +31,8 @@ const offerSetup = async ({site, member = null, offer}) => {
|
|||
<App api={ghostApi} />
|
||||
);
|
||||
|
||||
const triggerButtonFrame = await utils.findByTitle(/portal-trigger/i);
|
||||
const popupFrame = utils.queryByTitle(/portal-popup/i);
|
||||
const popupFrame = await utils.findByTitle(/portal-popup/i);
|
||||
const triggerButtonFrame = utils.queryByTitle(/portal-trigger/i);
|
||||
const popupIframeDocument = popupFrame.contentDocument;
|
||||
const emailInput = within(popupIframeDocument).queryByLabelText(/email/i);
|
||||
const nameInput = within(popupIframeDocument).queryByLabelText(/name/i);
|
||||
|
@ -281,6 +281,45 @@ describe('Logged-in free member', () => {
|
|||
|
||||
window.location.hash = '';
|
||||
});
|
||||
|
||||
test('to an offer via link with portal disabled', async () => {
|
||||
let site = {
|
||||
...FixtureSite.singleTier.basic,
|
||||
portal_button: false
|
||||
};
|
||||
|
||||
window.location.hash = `#/portal/offers/${FixtureOffer.id}`;
|
||||
const {
|
||||
ghostApi, popupFrame, triggerButtonFrame, emailInput, nameInput, signinButton, submitButton,
|
||||
siteTitle,
|
||||
offerName, offerDescription
|
||||
} = await offerSetup({
|
||||
site: site,
|
||||
member: FixtureMember.altFree,
|
||||
offer: FixtureOffer
|
||||
});
|
||||
let planId = FixtureSite.singleTier.basic.products.find(p => p.type === 'paid').monthlyPrice.id;
|
||||
let offerId = FixtureOffer.id;
|
||||
expect(popupFrame).toBeInTheDocument();
|
||||
expect(triggerButtonFrame).not.toBeInTheDocument();
|
||||
expect(siteTitle).not.toBeInTheDocument();
|
||||
expect(emailInput).not.toBeInTheDocument();
|
||||
expect(nameInput).not.toBeInTheDocument();
|
||||
expect(signinButton).not.toBeInTheDocument();
|
||||
expect(submitButton).not.toBeInTheDocument();
|
||||
expect(offerName).not.toBeInTheDocument();
|
||||
expect(offerDescription).not.toBeInTheDocument();
|
||||
|
||||
expect(ghostApi.member.checkoutPlan).toHaveBeenLastCalledWith({
|
||||
metadata: {
|
||||
checkoutType: 'upgrade'
|
||||
},
|
||||
offerId: offerId,
|
||||
plan: planId
|
||||
});
|
||||
|
||||
window.location.hash = '';
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue