Skip to content

Commit

Permalink
test: [M3-7189] - Add assertions for backup prices in Linode Create f…
Browse files Browse the repository at this point in the history
…low (#9821)

* M3-7189 Add assertions for backup prices in Linode Create flow

* Fixed comments
  • Loading branch information
cliu-akamai authored Nov 1, 2023
1 parent aff2cf5 commit 13ccb71
Showing 1 changed file with 45 additions and 8 deletions.
53 changes: 45 additions & 8 deletions packages/manager/cypress/e2e/core/linodes/create-linode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ describe('create linode', () => {
* - Confirms DC-specific pricing UI flow works as expected during Linode creation.
* - Confirms that pricing notice is shown in "Region" section.
* - Confirms that notice is shown when selecting a region with a different price structure.
* - Confirms that backups pricing is correct when selecting a region with a different price structure.
*/
it('shows DC-specific pricing information during create flow', () => {
const rootpass = randomString(32);
Expand All @@ -147,6 +148,19 @@ describe('create linode', () => {
type: dcPricingMockLinodeTypes[0].id,
});

const currentPrice = dcPricingMockLinodeTypes[0].region_prices.find(
(regionPrice) => regionPrice.id === initialRegion.id
);
const currentBackupPrice = dcPricingMockLinodeTypes[0].addons.backups.region_prices.find(
(regionPrice) => regionPrice.id === initialRegion.id
);
const newPrice = dcPricingMockLinodeTypes[1].region_prices.find(
(linodeType) => linodeType.id === newRegion.id
);
const newBackupPrice = dcPricingMockLinodeTypes[1].addons.backups.region_prices.find(
(regionPrice) => regionPrice.id === newRegion.id
);

mockAppendFeatureFlags({
dcSpecificPricing: makeFeatureFlagData(true),
}).as('getFeatureFlags');
Expand Down Expand Up @@ -175,15 +189,28 @@ describe('create linode', () => {
dcPricingPlanPlaceholder
);

// Confirm that the checkout summary at the bottom of the page reflects the correct price.
// Check the 'Backups' add on
cy.get('[data-testid="backups"]').should('be.visible').click();

containsClick(selectRegionString).type(`${initialRegion.label} {enter}`);
fbtClick('Shared CPU');
getClick(`[id="${dcPricingMockLinodeTypes[0].id}"]`);
// Confirm that the backup prices are displayed as expected.
cy.get('[data-qa-add-ons="true"]')
.eq(1)
.within(() => {
cy.findByText(`$${currentBackupPrice.monthly}`).should('be.visible');
cy.findByText('per month').should('be.visible');
});
// Confirm that the checkout summary at the bottom of the page reflects the correct price.
cy.get('[data-qa-summary="true"]').within(() => {
const currentPrice = dcPricingMockLinodeTypes[0].region_prices.find(
(regionPrice) => regionPrice.id === initialRegion.id
cy.findByText(`$${currentPrice.monthly.toFixed(2)}/month`).should(
'be.visible'
);
cy.findByText('Backups').should('be.visible');
cy.findByText(`$${currentBackupPrice.monthly.toFixed(2)}/month`).should(
'be.visible'
);
cy.findByText(`$${currentPrice.monthly}0/month`).should('be.visible');
});

// Confirms that a notice is shown in the "Region" section of the Linode Create form informing the user of tiered pricing
Expand All @@ -194,15 +221,25 @@ describe('create linode', () => {
// .should('be.visible')
// .should('have.attr', 'href', dcPricingDocsUrl);

// Confirms that the summary updates to reflect price changes if the user changes their region and plan selection.
containsClick(initialRegion.label).type(`${newRegion.label} {enter}`);
fbtClick('Shared CPU');
getClick(`[id="${dcPricingMockLinodeTypes[0].id}"]`);
// Confirm that the backup prices are displayed as expected.
cy.get('[data-qa-add-ons="true"]')
.eq(1)
.within(() => {
cy.findByText(`$${newBackupPrice.monthly}`).should('be.visible');
cy.findByText('per month').should('be.visible');
});
// Confirms that the summary updates to reflect price changes if the user changes their region and plan selection.
cy.get('[data-qa-summary="true"]').within(() => {
const currentPrice = dcPricingMockLinodeTypes[1].region_prices.find(
(regionPrice) => regionPrice.id === newRegion.id
cy.findByText(`$${newPrice.monthly.toFixed(2)}/month`).should(
'be.visible'
);
cy.findByText('Backups').should('be.visible');
cy.findByText(`$${newBackupPrice.monthly.toFixed(2)}/month`).should(
'be.visible'
);
cy.findByText(`$${currentPrice.monthly}0/month`).should('be.visible');
});

getClick('#linode-label').clear().type(linodeLabel);
Expand Down

0 comments on commit 13ccb71

Please sign in to comment.