Skip to content

Commit 34557c0

Browse files
change: [UIE-9908] - Update Generational Plans default sort to show newest (G8) -> oldest (G6) (#13234)
* Update GP default sort to show newest (G8) -> oldest (G6) * Minor comment updates * Added changeset: Update Generational Plans default sort to show newest (G8) -> oldest (G6) * Make generation plan ranking more scalable * Update some e2e tests * Update more e2e test cases * Update e2e tests from stackscripts and marketplace
1 parent 921d956 commit 34557c0

File tree

9 files changed

+112
-2
lines changed

9 files changed

+112
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Changed
3+
---
4+
5+
Update Generational Plans default sort to show newest (G8) -> oldest (G6) ([#13234](https://github.com/linode/manager/pull/13234))

packages/manager/cypress/e2e/core/kubernetes/lke-update.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,13 @@ describe('LKE cluster updates', () => {
14051405
.findByTitle(`Add a Node Pool: ${mockCluster.label}`)
14061406
.should('be.visible')
14071407
.within(() => {
1408+
// For the "Dedicated 4 GB", use filter to select G6 Dedicated instead of relying on pagination
1409+
ui.autocomplete.findByLabel('Dedicated Plans').click();
1410+
1411+
ui.autocompletePopper.find().within(() => {
1412+
cy.findByText('G6 Dedicated').should('be.visible').click();
1413+
});
1414+
14081415
cy.findByText('Dedicated 4 GB')
14091416
.should('be.visible')
14101417
.closest('tr')

packages/manager/cypress/e2e/core/linodes/alerts-create.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ describe('Create flow when beta alerts enabled by region and feature flag', func
123123
cy.get('[data-qa-tp="Linode Plan"]')
124124
.should('be.visible')
125125
.within(() => {
126+
// For the Dedicated 8 GB, Use filter to select G6 Dedicated instead of relying on pagination
127+
ui.autocomplete.findByLabel('Dedicated Plans').click();
128+
ui.autocompletePopper.find().within(() => {
129+
cy.findByText('G6 Dedicated').should('be.visible').click();
130+
});
131+
126132
cy.get('[data-qa-plan-row="Dedicated 8 GB"]').click();
127133
});
128134
cy.get('[type="password"]').should('be.visible').scrollIntoView();
@@ -283,6 +289,12 @@ describe('Create flow when beta alerts enabled by region and feature flag', func
283289
cy.get('[data-qa-tp="Linode Plan"]')
284290
.should('be.visible')
285291
.within(() => {
292+
// For the Dedicated 8 GB, Use filter to select G6 Dedicated instead of relying on pagination
293+
ui.autocomplete.findByLabel('Dedicated Plans').click();
294+
ui.autocompletePopper.find().within(() => {
295+
cy.findByText('G6 Dedicated').should('be.visible').click();
296+
});
297+
286298
cy.get('[data-qa-plan-row="Dedicated 8 GB"]').click();
287299
});
288300
cy.get('[type="password"]').should('be.visible').scrollIntoView();
@@ -432,6 +444,12 @@ describe('Create flow when beta alerts enabled by region and feature flag', func
432444
cy.get('[data-qa-tp="Linode Plan"]')
433445
.should('be.visible')
434446
.within(() => {
447+
// For the Dedicated 8 GB, Use filter to select G6 Dedicated instead of relying on pagination
448+
ui.autocomplete.findByLabel('Dedicated Plans').click();
449+
ui.autocompletePopper.find().within(() => {
450+
cy.findByText('G6 Dedicated').should('be.visible').click();
451+
});
452+
435453
cy.get('[data-qa-plan-row="Dedicated 8 GB"]').click();
436454
});
437455
cy.get('[type="password"]').should('be.visible').scrollIntoView();

packages/manager/cypress/e2e/core/linodes/create-linode.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ describe('Create Linode', () => {
9393
linodeCreatePage.setLabel(linodeLabel);
9494
linodeCreatePage.selectImage('Debian 12');
9595
linodeCreatePage.selectRegionById(linodeRegion.id);
96+
97+
// For the "Dedicated 4 GB" plan under the "Dedicated CPU" plan type, use filter to select G6 Dedicated instead of relying on pagination
98+
if (planConfig.planType === 'Dedicated CPU') {
99+
ui.autocomplete.findByLabel('Dedicated Plans').click();
100+
101+
ui.autocompletePopper.find().within(() => {
102+
cy.findByText('G6 Dedicated').should('be.visible').click();
103+
});
104+
}
105+
96106
linodeCreatePage.selectPlan(
97107
planConfig.planType,
98108
planConfig.planLabel

packages/manager/cypress/e2e/core/oneClickApps/one-click-apps.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ describe('OneClick Apps (OCA)', () => {
221221
cy.focused().type(`${region.id}{enter}`);
222222

223223
// Choose a Linode plan
224+
// For the Dedicated 8 GB, Use filter to select G6 Dedicated instead of relying on pagination
225+
ui.autocomplete.findByLabel('Dedicated Plans').click();
226+
ui.autocompletePopper.find().within(() => {
227+
cy.findByText('G6 Dedicated').should('be.visible').click();
228+
});
224229
cy.get('[data-qa-plan-row="Dedicated 8 GB"]')
225230
.closest('tr')
226231
.within(() => {

packages/manager/cypress/e2e/core/stackscripts/create-stackscripts.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ const fillOutLinodeForm = (label: string, regionName: string) => {
114114
cy.focused().type(label);
115115

116116
cy.findByText('Dedicated CPU').should('be.visible').click();
117+
118+
// Use filter to select G6 Dedicated instead of relying on pagination
119+
ui.autocomplete.findByLabel('Dedicated Plans').click();
120+
ui.autocompletePopper.find().within(() => {
121+
cy.findByText('G6 Dedicated').should('be.visible').click();
122+
});
123+
117124
cy.get('[id="g6-dedicated-2"]').click();
118125
cy.findByLabelText('Root Password').should('be.visible').type(password);
119126
};

packages/manager/cypress/e2e/core/stackscripts/smoke-community-stackscripts.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,13 @@ describe('Community Stackscripts integration tests', () => {
379379

380380
// An error message shows up when no region is selected
381381
cy.contains('Plan is required.').should('be.visible');
382+
383+
// For the Dedicated 8 GB, Use filter to select G6 Dedicated instead of relying on pagination
384+
ui.autocomplete.findByLabel('Dedicated Plans').click();
385+
ui.autocompletePopper.find().within(() => {
386+
cy.findByText('G6 Dedicated').should('be.visible').click();
387+
});
388+
382389
cy.get('[data-qa-plan-row="Dedicated 8 GB"]')
383390
.closest('tr')
384391
.within(() => {

packages/manager/src/features/components/PlansPanel/utils/planFilters.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
filterPlansByGpuType,
1212
filterPlansByType,
1313
getAvailableTypes,
14+
getGenerationRank,
1415
supportsTypeFiltering,
1516
} from './planFilters';
1617

@@ -240,4 +241,32 @@ describe('planFilters utilities', () => {
240241
expect(result).toEqual(gpuPlans);
241242
});
242243
});
244+
245+
describe('getGenerationRank', () => {
246+
it('returns higher rank for newer generations', () => {
247+
expect(getGenerationRank('g8-dedicated-4-2')).toBeGreaterThan(
248+
getGenerationRank('g7-dedicated-4-2')
249+
);
250+
expect(getGenerationRank('g7-dedicated-4-2')).toBeGreaterThan(
251+
getGenerationRank('g6-dedicated-2')
252+
);
253+
});
254+
255+
it('handles multi-digit generations correctly', () => {
256+
expect(getGenerationRank('g10-dedicated-2')).toBeGreaterThan(
257+
getGenerationRank('g8-dedicated-4-2')
258+
);
259+
expect(getGenerationRank('g11-dedicated-2')).toBeGreaterThan(
260+
getGenerationRank('g10-dedicated-2')
261+
);
262+
});
263+
264+
it('returns 0 for unknown generations', () => {
265+
expect(getGenerationRank('legacy-plan')).toBe(0);
266+
expect(getGenerationRank('gg-xyz')).toBe(0);
267+
expect(getGenerationRank('g-pqr')).toBe(0);
268+
expect(getGenerationRank('x123')).toBe(0);
269+
expect(getGenerationRank('')).toBe(0);
270+
});
271+
});
243272
});

packages/manager/src/features/components/PlansPanel/utils/planFilters.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,26 @@ export const filterPlansByGeneration = (
6868
// Type Filtering
6969
// ============================================================================
7070

71+
/**
72+
* Returns the numeric generation of a plan based on its ID.
73+
* Higher generation number = newer plan (shown first).
74+
*
75+
* Example:
76+
* - "g8-dedicated-4-2" -> 8
77+
* - "g1-accelerated-netint-vpu" -> 1
78+
* - "legacy-plan" -> 0
79+
*/
80+
export const getGenerationRank = (planId: string): number => {
81+
const generation = planId.split('-')[0]; // eg., "g8" or "legacy"
82+
83+
// Safe fallback: must start with "g"
84+
if (!generation.startsWith('g')) return 0;
85+
86+
const num = Number(generation.slice(1));
87+
88+
return Number.isFinite(num) ? num : 0;
89+
};
90+
7191
/**
7292
* Filter plans by type within a generation
7393
*
@@ -88,9 +108,11 @@ export const filterPlansByType = (
88108
generation: PlanFilterGeneration,
89109
type: PlanFilterType
90110
): PlanWithAvailability[] => {
91-
// "All" returns all plans unchanged
111+
// "All" returns all plans, sorted from newest to oldest generations
92112
if (type === PLAN_FILTER_ALL) {
93-
return plans;
113+
return [...plans].sort(
114+
(a, b) => getGenerationRank(b.id) - getGenerationRank(a.id)
115+
);
94116
}
95117

96118
// G7, G6, and "All" generation only have "All" option (no sub-types)

0 commit comments

Comments
 (0)