From 433437f6975d6cf1460f12ca17890d12c2843580 Mon Sep 17 00:00:00 2001 From: Anthony Grullon Date: Tue, 28 Feb 2023 14:53:34 -0500 Subject: [PATCH] Launchpad: Add launchpad sidebar upsell domain task unit tests (#73784) --- .../launchpad/test/sidebar.tsx | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/client/landing/stepper/declarative-flow/internals/steps-repository/launchpad/test/sidebar.tsx b/client/landing/stepper/declarative-flow/internals/steps-repository/launchpad/test/sidebar.tsx index df6179109b6fd0..2d36f01fa48c0f 100644 --- a/client/landing/stepper/declarative-flow/internals/steps-repository/launchpad/test/sidebar.tsx +++ b/client/landing/stepper/declarative-flow/internals/steps-repository/launchpad/test/sidebar.tsx @@ -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(); + } ); + } ); + } ); } );