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-8321] - Clean up feature flag mocks #10892

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10892-tests-1725546783401.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Clean up feature flag mocks ([#10892](https://github.com/linode/manager/pull/10892))
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ import { mockGetAccount, mockUpdateAccount } from 'support/intercepts/account';
import { accountFactory } from 'src/factories/account';
import type { Account } from '@linode/api-v4';
import { ui } from 'support/ui';
import { makeFeatureFlagData } from 'support/util/feature-flags';
import { TAX_ID_HELPER_TEXT } from 'src/features/Billing/constants';
import {
mockAppendFeatureFlags,
mockGetFeatureFlagClientstream,
} from 'support/intercepts/feature-flags';
import type { Flags } from 'src/featureFlags';
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';

/* eslint-disable sonarjs/no-duplicate-string */
const accountData = accountFactory.build({
Expand Down Expand Up @@ -72,11 +67,10 @@ const checkAccountContactDisplay = (accountInfo: Account) => {
describe('Billing Contact', () => {
beforeEach(() => {
mockAppendFeatureFlags({
taxId: makeFeatureFlagData<Flags['taxId']>({
taxId: {
enabled: true,
}),
},
});
mockGetFeatureFlagClientstream();
});
it('Edit Contact Info', () => {
// mock the user's account data and confirm that it is displayed correctly upon page load
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { linodeFactory, regionFactory } from '@src/factories';
import { randomString, randomLabel } from 'support/util/random';
import { mockGetRegions } from 'support/intercepts/regions';
import { mockGetAccountAgreements } from 'support/intercepts/account';

import type { Region } from '@linode/api-v4';
import { mockCreateLinode } from 'support/intercepts/linodes';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import 'cypress-file-upload';
import {
mockAppendFeatureFlags,
mockGetFeatureFlagClientstream,
} from 'support/intercepts/feature-flags';
import { makeFeatureFlagData } from 'support/util/feature-flags';
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
import { ui } from 'support/ui';
import {
randomItem,
Expand Down Expand Up @@ -48,9 +44,8 @@ describe('close support tickets', () => {
}

mockAppendFeatureFlags({
supportTicketSeverity: makeFeatureFlagData(true),
supportTicketSeverity: true,
});
mockGetFeatureFlagClientstream();
mockGetSupportTickets([mockTicket]);
mockGetSupportTicket(mockTicket).as('getSupportTicket');
mockGetSupportTicketReplies(mockTicket.id, []).as('getReplies');
Expand Down Expand Up @@ -107,9 +102,8 @@ describe('close support tickets', () => {
}

mockAppendFeatureFlags({
supportTicketSeverity: makeFeatureFlagData(true),
supportTicketSeverity: true,
});
mockGetFeatureFlagClientstream();
mockGetSupportTickets([mockTicket]);
mockGetSupportTicket(mockTicket).as('getSupportTicket');
mockGetSupportTicketReplies(mockTicket.id, []).as('getReplies');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
/* eslint-disable sonarjs/no-duplicate-string */
import 'cypress-file-upload';
import { interceptGetProfile } from 'support/intercepts/profile';
import {
mockAppendFeatureFlags,
mockGetFeatureFlagClientstream,
} from 'support/intercepts/feature-flags';
import { makeFeatureFlagData } from 'support/util/feature-flags';
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
import { ui } from 'support/ui';
import {
randomItem,
Expand Down Expand Up @@ -69,9 +65,8 @@ describe('open support tickets', () => {
*/
it('can open a support ticket', () => {
mockAppendFeatureFlags({
supportTicketSeverity: makeFeatureFlagData(false),
supportTicketSeverity: false,
});
mockGetFeatureFlagClientstream();

const image = 'test_screenshot.png';
const ticketDescription = 'this is a test ticket';
Expand Down Expand Up @@ -159,9 +154,8 @@ describe('open support tickets', () => {
}

mockAppendFeatureFlags({
supportTicketSeverity: makeFeatureFlagData(true),
supportTicketSeverity: true,
});
mockGetFeatureFlagClientstream();
mockCreateSupportTicket(mockTicket).as('createTicket');
mockGetSupportTickets([]);
mockGetSupportTicket(mockTicket);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { interceptGetProfile } from 'support/intercepts/profile';
import {
mockAppendFeatureFlags,
mockGetFeatureFlagClientstream,
} from 'support/intercepts/feature-flags';
import { makeFeatureFlagData } from 'support/util/feature-flags';
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
import {
randomItem,
randomLabel,
Expand Down Expand Up @@ -38,9 +34,8 @@ describe('support tickets landing page', () => {
*/
it('shows the empty message when there are no tickets.', () => {
mockAppendFeatureFlags({
supportTicketSeverity: makeFeatureFlagData(false),
supportTicketSeverity: false,
});
mockGetFeatureFlagClientstream();

interceptGetProfile().as('getProfile');

Expand Down Expand Up @@ -92,9 +87,8 @@ describe('support tickets landing page', () => {
const mockTickets = [mockTicket, mockAnotherTicket];

mockAppendFeatureFlags({
supportTicketSeverity: makeFeatureFlagData(true),
supportTicketSeverity: true,
});
mockGetFeatureFlagClientstream();
mockGetSupportTickets(mockTickets);

cy.visitWithLogin('/support/tickets');
Expand Down Expand Up @@ -156,9 +150,8 @@ describe('support tickets landing page', () => {
}

mockAppendFeatureFlags({
supportTicketSeverity: makeFeatureFlagData(true),
supportTicketSeverity: true,
});
mockGetFeatureFlagClientstream();
mockGetSupportTickets([mockTicket]);
mockGetSupportTicket(mockTicket).as('getSupportTicket');
mockGetSupportTicketReplies(mockTicket.id, []).as('getReplies');
Expand Down Expand Up @@ -251,9 +244,8 @@ describe('support tickets landing page', () => {
}

mockAppendFeatureFlags({
supportTicketSeverity: makeFeatureFlagData(true),
supportTicketSeverity: true,
});
mockGetFeatureFlagClientstream();
mockGetSupportTickets([mockTicket]);
mockGetSupportTicket(mockTicket).as('getSupportTicket');
mockGetSupportTicketReplies(mockTicket.id, []).as('getReplies');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { mockGetAccount } from 'support/intercepts/account';
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
import { ui } from 'support/ui';
import { cleanUp } from 'support/util/cleanup';
import { makeFeatureFlagData } from 'support/util/feature-flags';
import { createTestLinode } from 'support/util/linodes';
import { randomLabel, randomPhrase } from 'support/util/random';
import { mockGetRegions } from 'support/intercepts/regions';
Expand Down Expand Up @@ -127,7 +126,7 @@ describe('create image (e2e)', () => {
it('displays notice informing user that Images are not encrypted, provided the LDE feature is enabled and the selected linode is not in an Edge region', () => {
// Mock feature flag -- @TODO LDE: Remove feature flag once LDE is fully rolled out
mockAppendFeatureFlags({
linodeDiskEncryption: makeFeatureFlagData(true),
linodeDiskEncryption: true,
}).as('getFeatureFlags');

// Mock responses
Expand Down Expand Up @@ -164,7 +163,7 @@ describe('create image (e2e)', () => {
it('does not display a notice informing user that Images are not encrypted if the LDE feature is disabled', () => {
// Mock feature flag -- @TODO LDE: Remove feature flag once LDE is fully rolled out
mockAppendFeatureFlags({
linodeDiskEncryption: makeFeatureFlagData(false),
linodeDiskEncryption: false,
}).as('getFeatureFlags');

// Mock responses
Expand Down Expand Up @@ -201,7 +200,7 @@ describe('create image (e2e)', () => {
it('does not display a notice informing user that Images are not encrypted if the selected linode is in an Edge region', () => {
// Mock feature flag -- @TODO LDE: Remove feature flag once LDE is fully rolled out
mockAppendFeatureFlags({
linodeDiskEncryption: makeFeatureFlagData(true),
linodeDiskEncryption: true,
}).as('getFeatureFlags');

// Mock responses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,15 @@ import {
import { getRegionById } from 'support/util/regions';
import { readDownload } from 'support/util/downloads';
import { ui } from 'support/ui';
import {
mockAppendFeatureFlags,
mockGetFeatureFlagClientstream,
} from 'support/intercepts/feature-flags';
import { makeFeatureFlagData } from 'support/util/feature-flags';
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
import { mockGetAccount } from 'support/intercepts/account';

describe('LKE landing page', () => {
it('does not display a Disk Encryption info banner if the LDE feature is disabled', () => {
// Mock feature flag -- @TODO LDE: Remove feature flag once LDE is fully rolled out
mockAppendFeatureFlags({
linodeDiskEncryption: makeFeatureFlagData(false),
linodeDiskEncryption: false,
}).as('getFeatureFlags');
mockGetFeatureFlagClientstream().as('getClientStream');

// Mock responses
const mockAccount = accountFactory.build({
Expand All @@ -51,9 +46,8 @@ describe('LKE landing page', () => {
it('displays a Disk Encryption info banner if the LDE feature is enabled', () => {
// Mock feature flag -- @TODO LDE: Remove feature flag once LDE is fully rolled out
mockAppendFeatureFlags({
linodeDiskEncryption: makeFeatureFlagData(true),
linodeDiskEncryption: true,
}).as('getFeatureFlags');
mockGetFeatureFlagClientstream().as('getClientStream');

// Mock responses
const mockAccount = accountFactory.build({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { ui } from 'support/ui';
import {
regionFactory,
} from '@src/factories';
import { regionFactory } from '@src/factories';
import { mockGetRegions } from 'support/intercepts/regions';
import { extendRegion } from 'support/util/regions';

Expand Down Expand Up @@ -85,12 +83,9 @@ describe('Linode Create Region Select', () => {
cy.get('[data-qa-autocomplete-popper="true"]').should('not.exist');

// Confirm that the selected region is displayed in the input field.
cy.findByLabelText('Region').should(
'have.value',
'UK, London (eu-west)'
);
cy.findByLabelText('Region').should('have.value', 'UK, London (eu-west)');

// Confirm that selecting a valid region updates the Plan Selection panel.
expect(cy.get('[data-testid="table-row-empty"]').should('not.exist'));
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import { ui } from 'support/ui';

import { randomLabel, randomString } from 'support/util/random';
import { linodeCreatePage } from 'support/ui/pages';
import {
mockAppendFeatureFlags,
mockGetFeatureFlagClientstream,
} from 'support/intercepts/feature-flags';

import { makeFeatureFlagData } from 'support/util/feature-flags';
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
import { chooseRegion } from 'support/util/regions';

describe('Create Linode', () => {
Expand All @@ -23,9 +18,8 @@ describe('Create Linode', () => {
// TODO Delete these mocks once `apicliDxToolsAdditions` feature flag is retired.
beforeEach(() => {
mockAppendFeatureFlags({
apicliDxToolsAdditions: makeFeatureFlagData(true),
apicliDxToolsAdditions: true,
});
mockGetFeatureFlagClientstream();
});
it(`view code snippets in create linode flow`, () => {
const linodeLabel = randomLabel();
Expand Down Expand Up @@ -149,15 +143,14 @@ describe('Create Linode', () => {
});
});
});

describe('Create Linode flow with apicliDxToolsAdditions disabled', () => {
// Enable the `apicliDxToolsAdditions` feature flag.
// TODO Delete these mocks and test once `apicliDxToolsAdditions` feature flag is retired.
beforeEach(() => {
mockAppendFeatureFlags({
apicliDxToolsAdditions: makeFeatureFlagData(false),
apicliDxToolsAdditions: false,
});
mockGetFeatureFlagClientstream();
});
it(`view code snippets in create linode flow`, () => {
const linodeLabel = randomLabel();
Expand Down Expand Up @@ -219,8 +212,10 @@ describe('Create Linode', () => {

cy.get('[id="g6-dedicated-2"]').click();

cy.findByLabelText('Linode Label')
.should('have.value', `debian-${linodeRegion.id}`);
cy.findByLabelText('Linode Label').should(
'have.value',
`debian-${linodeRegion.id}`
);

cy.findByLabelText('Linode Label')
.should('be.visible')
Expand All @@ -244,9 +239,7 @@ describe('Create Linode', () => {
.should('be.visible')
.within(() => {
// Switch to cURL view if necessary.
cy.findByText('cURL')
.should('be.visible')
.click();
cy.findByText('cURL').should('be.visible').click();

// Confirm that cURL command has expected details.
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { ui } from 'support/ui';
import { randomLabel } from 'support/util/random';
import { getRegionById } from 'support/util/regions';
import {
linodeFactory,
} from '@src/factories';
import { linodeFactory } from '@src/factories';
import {
dcPricingPlanPlaceholder,
dcPricingMockLinodeTypes,
Expand Down Expand Up @@ -58,8 +56,8 @@ describe('Create Linode with DC-specific pricing', () => {
mockCreateLinode(mockLinode).as('linodeCreated');

cy.get('[data-qa-header="Create"]').should('have.text', 'Create');
ui.button.findByTitle("Create Linode").click();

ui.button.findByTitle('Create Linode').click();

// A message is shown to instruct users to select a region in order to view plans and prices
cy.get('[data-qa-tp="Linode Plan"]').should(
Expand All @@ -78,11 +76,10 @@ describe('Create Linode with DC-specific pricing', () => {
cy.findByText('Shared CPU').click();
cy.get(`[id="${dcPricingMockLinodeTypes[0].id}"]`).click();
// Confirm that the backup prices are displayed as expected.
cy.get('[data-qa-add-ons="true"]')
.within(() => {
cy.findByText(`$${currentBackupPrice.monthly}`).should('be.visible');
cy.findByText('per month').should('be.visible');
});
cy.get('[data-qa-add-ons="true"]').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-linode-create-summary="true"]').within(() => {
cy.findByText(`$${currentPrice.monthly!.toFixed(2)}/month`).should(
Expand All @@ -103,11 +100,10 @@ describe('Create Linode with DC-specific pricing', () => {
cy.findByText('Shared CPU').click();
cy.get(`[id="${dcPricingMockLinodeTypes[0].id}"]`).click();
// Confirm that the backup prices are displayed as expected.
cy.get('[data-qa-add-ons="true"]')
.within(() => {
cy.findByText(`$${newBackupPrice.monthly}`).should('be.visible');
cy.findByText('per month').should('be.visible');
});
cy.get('[data-qa-add-ons="true"]').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-linode-create-summary="true"]').within(() => {
cy.findByText(`$${newPrice.monthly!.toFixed(2)}/month`).should(
Expand All @@ -119,4 +115,4 @@ describe('Create Linode with DC-specific pricing', () => {
);
});
});
});
});
Loading
Loading