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-8835] - Add accelerated plans test case to plan-selection.spec.ts #11323

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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-11323-tests-1732563014945.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Add tests for accelerated plans in `plan-selection.spec.ts` ([#11323](https://github.com/linode/manager/pull/11323))
178 changes: 177 additions & 1 deletion packages/manager/cypress/e2e/core/linodes/plan-selection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
// Move this to cypress component testing once the setup is complete - see https://github.com/linode/manager/pull/10134
import { ui } from 'support/ui';
import {
accountFactory,
linodeTypeFactory,
regionFactory,
regionAvailabilityFactory,
linodeTypeFactory,
} from '@src/factories';
import { authenticate } from 'support/api/authentication';
import {
mockGetRegions,
mockGetRegionAvailability,
} from 'support/intercepts/regions';
import { mockGetLinodeTypes } from 'support/intercepts/linodes';
import { mockGetAccount } from 'support/intercepts/account';
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';

const mockRegions = [
Expand Down Expand Up @@ -84,11 +86,20 @@ const mockGPUType = [
}),
];

const mockAcceleratedType = [
linodeTypeFactory.build({
id: 'accelerated-1',
label: 'accelerated-1',
class: 'accelerated',
}),
];

const mockLinodeTypes = [
...mockDedicatedLinodeTypes,
...mockHighMemoryLinodeTypes,
...mockSharedLinodeTypes,
...mockGPUType,
...mockAcceleratedType,
];

const mockRegionAvailability = [
Expand Down Expand Up @@ -397,3 +408,168 @@ describe('displays specific linode plans for GPU', () => {
});
});
});

describe('Linode Accelerated plans', () => {
beforeEach(() => {
mockGetRegions(mockRegions).as('getRegions');
mockGetLinodeTypes(mockLinodeTypes).as('getLinodeTypes');
mockGetRegionAvailability(mockRegions[0].id, mockRegionAvailability).as(
'getRegionAvailability'
);
});

describe('without necessary account capability', () => {
beforeEach(() => {
mockGetAccount(
accountFactory.build({
capabilities: [],
})
).as('getAccount');
mockAppendFeatureFlags({
acceleratedPlans: {
linodePlans: true,
lkePlans: true,
},
}).as('getFeatureFlags');
});

it('should not render accelerated plans for linodes', () => {
cy.visitWithLogin('/linodes/create');
cy.wait([
'@getRegions',
'@getLinodeTypes',
'@getAccount',
'@getFeatureFlags',
]);

cy.findByText('Accelerated').should('not.exist');
});

it('should not render accelerated plans for kubernetes', () => {
cy.visitWithLogin('/kubernetes/create');
cy.wait([
'@getRegions',
'@getLinodeTypes',
'@getAccount',
'@getFeatureFlags',
]);

cy.findByText('Accelerated').should('not.exist');
});
});

describe('with necessary account capability', () => {
beforeEach(() => {
mockGetAccount(
accountFactory.build({
capabilities: ['NETINT Quadra T1U'],
})
).as('getAccount');
});

describe('Linodes plans panel', () => {
it('should render Accelerated plans when the feature flag is on', () => {
mockAppendFeatureFlags({
acceleratedPlans: {
linodePlans: true,
lkePlans: false,
},
}).as('getFeatureFlags');
cy.visitWithLogin('/linodes/create');
cy.wait([
'@getRegions',
'@getLinodeTypes',
'@getAccount',
'@getFeatureFlags',
]);

ui.regionSelect.find().click();
ui.regionSelect.findItemByRegionLabel(mockRegions[0].label).click();

cy.findByText('Accelerated').click();
cy.get(linodePlansPanel).within(() => {
cy.findAllByRole('alert').should('have.length', 1);

cy.findByRole('table', {
name: 'List of Linode Plans',
}).within(() => {
cy.findByText('NETINT Quadra T1U').should('be.visible');
cy.findAllByRole('row').should('have.length', 2);
cy.get('[id="accelerated-1"]').should('be.disabled');
});
});
});

it('should not render Accelerated plans when the feature flag is off', () => {
mockAppendFeatureFlags({
acceleratedPlans: {
linodePlans: false,
lkePlans: false,
},
}).as('getFeatureFlags');
cy.visitWithLogin('/linodes/create');
cy.wait([
'@getRegions',
'@getLinodeTypes',
'@getAccount',
'@getFeatureFlags',
]);

// Confirms Accelerated tab does not show up for LKE clusters
cy.findByText('Accelerated').should('not.exist');
});
});

describe('kubernetes plans panel', () => {
it('should render Accelerated plans when the feature flag is on', () => {
mockAppendFeatureFlags({
acceleratedPlans: {
linodePlans: false,
lkePlans: true,
},
}).as('getFeatureFlags');
cy.visitWithLogin('/kubernetes/create');
cy.wait([
'@getRegions',
'@getLinodeTypes',
'@getAccount',
'@getFeatureFlags',
]);

ui.regionSelect.find().click();
ui.regionSelect.findItemByRegionLabel(mockRegions[0].label).click();

cy.wait(['@getRegionAvailability']);

cy.findByText('Accelerated').click();
cy.get(k8PlansPanel).within(() => {
cy.findAllByRole('alert').should('have.length', 1);

cy.findByRole('table', { name: planSelectionTable }).within(() => {
cy.findAllByRole('row').should('have.length', 2);
cy.get('[data-qa-plan-row="accelerated-1"]').should('be.visible');
});
});
});

it('should not render Accelerated plans when the feature flag is off', () => {
mockAppendFeatureFlags({
acceleratedPlans: {
linodePlans: false,
lkePlans: false,
},
}).as('getFeatureFlags');
cy.visitWithLogin('/kubernetes/create');
cy.wait([
'@getRegions',
'@getLinodeTypes',
'@getAccount',
'@getFeatureFlags',
]);

// Confirms Accelerated tab does not show up for LKE clusters
cy.findByText('Accelerated').should('not.exist');
});
});
});
});