Skip to content

Commit

Permalink
Launchpad: Add launchpad sidebar upsell domain task unit tests (Autom…
Browse files Browse the repository at this point in the history
  • Loading branch information
agrullon95 authored Feb 28, 2023
1 parent 5eb2d62 commit 433437f
Showing 1 changed file with 117 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,121 @@ describe( 'Sidebar', () => {
} );
} );
} );

describe( 'when the tailored flow includes a upsell task', () => {
describe( 'and the site is on a free plan', () => {
it( 'displays the upgrade plan badge on the "Choose a domain" task for free flow', () => {
const freeFlowProps = { ...props, flow: 'free' };

const siteDetails = buildSiteDetails( {
options: {
...defaultSiteDetails.options,
},
plan: {
is_free: true,
},
} );
renderSidebar( freeFlowProps, siteDetails );

const domainUpsellTaskFreeFlow = screen.queryByText( 'Choose a domain' );
const domainUpsellTaskBadgeFreeFlow = screen.queryByText( 'Upgrade plan' );
expect( domainUpsellTaskFreeFlow ).toBeVisible();
expect( domainUpsellTaskBadgeFreeFlow ).toBeVisible();
} );

it( 'displays the upgrade plan badge on the "Choose a domain" task for write flow', () => {
const writeFlowProps = { ...props, flow: 'write' };

const siteDetails = buildSiteDetails( {
options: {
...defaultSiteDetails.options,
},
plan: {
is_free: true,
},
} );
renderSidebar( writeFlowProps, siteDetails );

const domainUpsellTaskFreeFlow = screen.queryByText( 'Choose a domain' );
const domainUpsellTaskBadgeFreeFlow = screen.queryByText( 'Upgrade plan' );
expect( domainUpsellTaskFreeFlow ).toBeVisible();
expect( domainUpsellTaskBadgeFreeFlow ).toBeVisible();
} );

it( 'displays the upgrade plan badge on the "Choose a domain" task for build flow', () => {
const buildFlowProps = { ...props, flow: 'build' };

const siteDetails = buildSiteDetails( {
options: {
...defaultSiteDetails.options,
},
plan: {
is_free: true,
},
} );
renderSidebar( buildFlowProps, siteDetails );

const domainUpsellTaskFreeFlow = screen.queryByText( 'Choose a domain' );
const domainUpsellTaskBadgeFreeFlow = screen.queryByText( 'Upgrade plan' );
expect( domainUpsellTaskFreeFlow ).toBeVisible();
expect( domainUpsellTaskBadgeFreeFlow ).toBeVisible();
} );
} );

describe( 'and the site is on a paid plan', () => {
it( 'does not display the upgrade plan badge on the "Choose a domain" task for free flow', () => {
const freeFlowProps = { ...props, flow: 'free' };
const siteDetails = buildSiteDetails( {
options: {
...defaultSiteDetails.options,
},
plan: {
is_free: false,
},
} );
renderSidebar( freeFlowProps, siteDetails );

const domainUpsellTask = screen.queryByText( 'Choose a domain' );
const domainUpsellTaskBadge = screen.queryByText( 'Upgrade plan' );
expect( domainUpsellTask ).toBeVisible();
expect( domainUpsellTaskBadge ).toBeNull();
} );

it( 'does not display the upgrade plan badge on the "Choose a domain" task for write flow', () => {
const writeFlowProps = { ...props, flow: 'write' };
const siteDetails = buildSiteDetails( {
options: {
...defaultSiteDetails.options,
},
plan: {
is_free: false,
},
} );
renderSidebar( writeFlowProps, siteDetails );

const domainUpsellTask = screen.queryByText( 'Choose a domain' );
const domainUpsellTaskBadge = screen.queryByText( 'Upgrade plan' );
expect( domainUpsellTask ).toBeVisible();
expect( domainUpsellTaskBadge ).toBeNull();
} );

it( 'does not display the upgrade plan badge on the "Choose a domain" task for build flow', () => {
const buildFlowProps = { ...props, flow: 'build' };
const siteDetails = buildSiteDetails( {
options: {
...defaultSiteDetails.options,
},
plan: {
is_free: false,
},
} );
renderSidebar( buildFlowProps, siteDetails );

const domainUpsellTask = screen.queryByText( 'Choose a domain' );
const domainUpsellTaskBadge = screen.queryByText( 'Upgrade plan' );
expect( domainUpsellTask ).toBeVisible();
expect( domainUpsellTaskBadge ).toBeNull();
} );
} );
} );
} );

0 comments on commit 433437f

Please sign in to comment.