Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: [M3-7189] - Add assertions for backup prices in Linode Create flow #9821

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 45 additions & 8 deletions packages/manager/cypress/e2e/core/linodes/create-linode.spec.ts
mjac0bs marked this conversation as resolved.
Show resolved Hide resolved
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