Skip to content

Commit

Permalink
add test for w/o account capability, update tests based on banners
Browse files Browse the repository at this point in the history
  • Loading branch information
coliu-akamai committed Nov 25, 2024
1 parent 0c02c9d commit 8b7c275
Showing 1 changed file with 120 additions and 80 deletions.
200 changes: 120 additions & 80 deletions packages/manager/cypress/e2e/core/linodes/plan-selection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,6 @@ describe('displays linode plans panel based on availability', () => {
cy.findAllByTestId('disabled-plan-tooltip').should('have.length', 0);
});
});

// Confirms Accelerated tab does not show up without account availability
cy.findByText('Accelerated').should('not.exist');
});
});

Expand Down Expand Up @@ -412,61 +409,31 @@ describe('displays specific linode plans for GPU', () => {
});
});

describe('Accelerated plans', () => {
describe('Linode Accelerated plans', () => {
beforeEach(() => {
mockGetAccount(
accountFactory.build({
capabilities: ['NETINT Quadra T1U'],
})
).as('getAccount');
mockGetRegions(mockRegions).as('getRegions');
mockGetLinodeTypes(mockLinodeTypes).as('getLinodeTypes');
mockGetRegionAvailability(mockRegions[0].id, mockRegionAvailability).as(
'getRegionAvailability'
);
});

describe('Linodes', () => {
it('displays Accelerated plans when the feature flag is on', () => {
describe('without necessary account capability', () => {
beforeEach(() => {
mockGetAccount(
accountFactory.build({
capabilities: [],
})
).as('getAccount');
mockAppendFeatureFlags({
acceleratedPlans: {
linodePlans: true,
lkePlans: false,
lkePlans: true,
},
}).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', 2);
cy.get(notices.unavailable).should('be.visible');

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('does not display Accelerated plans when the feature flag is off', () => {
mockAppendFeatureFlags({
acceleratedPlans: {
linodePlans: false,
lkePlans: false,
},
}).as('getFeatureFlags');
it('should not render accelerated plans for linodes', () => {
cy.visitWithLogin('/linodes/create');
cy.wait([
'@getRegions',
Expand All @@ -475,19 +442,10 @@ describe('Accelerated plans', () => {
'@getFeatureFlags',
]);

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

describe('LKE clusters', () => {
it('displays Accelerated plans when the feature flag is on', () => {
mockAppendFeatureFlags({
acceleratedPlans: {
linodePlans: false,
lkePlans: true,
},
}).as('getFeatureFlags');
it('should not render accelerated plans for kubernetes', () => {
cy.visitWithLogin('/kubernetes/create');
cy.wait([
'@getRegions',
Expand All @@ -496,40 +454,122 @@ describe('Accelerated plans', () => {
'@getFeatureFlags',
]);

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

cy.wait(['@getRegionAvailability']);
cy.findByText('Accelerated').should('not.exist');
});
});

cy.findByText('Accelerated').click();
cy.get(k8PlansPanel).within(() => {
cy.findAllByRole('alert').should('have.length', 2);
cy.get(notices.unavailable).should('be.visible');
describe('with necessary account capability', () => {
beforeEach(() => {
mockGetAccount(
accountFactory.build({
capabilities: ['NETINT Quadra T1U'],
})
).as('getAccount');
});

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

it('does not display 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',
]);
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');
});
});
});

// Confirms Accelerated tab does not show up for LKE clusters
cy.findByText('Accelerated').should('not.exist');
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');
});
});
});
});

0 comments on commit 8b7c275

Please sign in to comment.