Skip to content

Commit 8c4211e

Browse files
ankita-akamainikhagra-akamaiagorthi-akamaidmcintyr-akamai
authored
[DI-26394] - Add new flag to control services types in alerts and metrics (linode#12671)
* [DI-26394] - Add new flag to control services types in alerts and metrics in ui * [DI-26394] - Update type * [DI-26394] - fix eslint issues * [DI-26394] - Cleanup * [DI-26394] - Remove aclpBetaServices flag * [DI-26394] - Update type * [DI-26394] - Remove fallbacks * [DI-26394] - Update reusable comp as per aclp-dev * [DI-26394] - Update comments * [DI-26394] - reuse type * upcoming: [DI-26394] - Update comment Co-authored-by: Nikhil Agrawal <[email protected]> * [DI-26394] - Make props optional and update test cases * [DI-26394] - Update component * [DI-26394] - Update component * test[DI-26398]: Add/Update spec to cover aclpServices LaunchDarkly flags for Alert and Metrics features * test[DI-26398]: Add/Update spec to cover aclpServices * test[DI-26398]: Fix typecheck issue * [DI-26394] - remove type assertion * [DI-26394] - Add changeset * upcoming:[DI-26394]: Use appropriate flag prop for linode create and details page * [DI-26394] - update flag check and e2e test desc * upcoming:[DI-26394]: Update flag correctly --------- Co-authored-by: Nikhil Agrawal <[email protected]> Co-authored-by: agorthi <[email protected]> Co-authored-by: dmcintyr-akamai <[email protected]>
1 parent 9849406 commit 8c4211e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1197
-246
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
CloudPulse: Add new flag - 'aclpServices', filter services at `CloudPulseDashboardSelect.tsx`, `AlertListing.tsx`, `ServiceTypeSelect.tsx` ([#12671](https://github.com/linode/manager/pull/12671))

packages/manager/cypress/e2e/core/cloudpulse/aclp-support.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ import type { Stats } from '@linode/api-v4';
3232
describe('ACLP Components UI varies according to ACLP support by region and user preference', function () {
3333
beforeEach(function () {
3434
mockAppendFeatureFlags({
35-
aclpBetaServices: {
35+
aclpServices: {
3636
linode: {
37-
alerts: false,
38-
metrics: true,
37+
alerts: { beta: false, enabled: false },
38+
metrics: { beta: true, enabled: true },
3939
},
4040
},
4141
}).as('getFeatureFlags');

packages/manager/cypress/e2e/core/cloudpulse/alert-errors.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ import {
77
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
88
import { ui } from 'support/ui';
99

10-
import { accountFactory, alertFactory } from 'src/factories';
11-
12-
import type { Flags } from 'src/featureFlags';
13-
14-
const flags: Partial<Flags> = { aclp: { beta: true, enabled: true } };
10+
import { accountFactory, alertFactory, flagsFactory } from 'src/factories';
1511
const mockAccount = accountFactory.build();
1612
const mockAlerts = [
1713
alertFactory.build({
@@ -39,7 +35,7 @@ describe('Alerts Listing Page - Error Handling', () => {
3935
* - Confirms that the UI does not reflect a successful state change if the request fails.
4036
*/
4137
beforeEach(() => {
42-
mockAppendFeatureFlags(flags);
38+
mockAppendFeatureFlags(flagsFactory.build());
4339
mockGetAccount(mockAccount);
4440
mockGetCloudPulseServices(['linode', 'dbaas']);
4541
mockGetAllAlertDefinitions(mockAlerts).as('getAlertDefinitionsList');

packages/manager/cypress/e2e/core/cloudpulse/alerts-listing-page.spec.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
1515
import { mockGetProfile } from 'support/intercepts/profile';
1616
import { ui } from 'support/ui';
1717

18-
import { accountFactory, alertFactory, alertRulesFactory } from 'src/factories';
18+
import {
19+
accountFactory,
20+
alertFactory,
21+
alertRulesFactory,
22+
flagsFactory,
23+
} from 'src/factories';
1924
import {
2025
alertLimitMessage,
2126
alertToolTipText,
@@ -33,19 +38,11 @@ import type {
3338
AlertStatusType,
3439
CloudPulseServiceType,
3540
} from '@linode/api-v4';
36-
import type { Flags } from 'src/featureFlags';
3741
const alertDefinitionsUrl = '/alerts/definitions';
3842

3943
const mockProfile = profileFactory.build({
4044
timezone: 'gmt',
4145
});
42-
const flags: Partial<Flags> = {
43-
aclp: { beta: true, enabled: true },
44-
aclpBetaServices: {
45-
dbaas: { metrics: true, alerts: true },
46-
linode: { metrics: true, alerts: true },
47-
},
48-
};
4946
const mockAccount = accountFactory.build();
5047
const now = new Date();
5148
const mockAlerts = [
@@ -215,7 +212,7 @@ describe('Integration Tests for CloudPulse Alerts Listing Page', () => {
215212
* - Ensures API calls return correct responses and status codes.
216213
*/
217214
beforeEach(() => {
218-
mockAppendFeatureFlags(flags);
215+
mockAppendFeatureFlags(flagsFactory.build());
219216
mockGetAccount(mockAccount);
220217
mockGetProfile(mockProfile);
221218
mockGetCloudPulseServices(['linode', 'dbaas']);
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/**
2+
* @file Integration tests for feature flag behavior on the alert page.
3+
*/
4+
import { widgetDetails } from 'support/constants/widgets';
5+
import { mockGetAccount } from 'support/intercepts/account';
6+
import {
7+
mockGetCloudPulseMetricDefinitions,
8+
mockGetCloudPulseServices,
9+
} from 'support/intercepts/cloudpulse';
10+
import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
11+
import { mockGetUserPreferences } from 'support/intercepts/profile';
12+
import { ui } from 'support/ui';
13+
14+
import {
15+
accountFactory,
16+
dashboardMetricFactory,
17+
flagsFactory,
18+
} from 'src/factories';
19+
/**
20+
* This test ensures that widget titles are displayed correctly on the dashboard.
21+
* This test suite is dedicated to verifying the functionality and display of widgets on the Cloudpulse dashboard.
22+
* It includes:
23+
* Validating that widgets are correctly loaded and displayed.
24+
* Ensuring that widget titles and data match the expected values.
25+
* Verifying that widget settings, such as granularity and aggregation, are applied correctly.
26+
* Testing widget interactions, including zooming and filtering, to ensure proper behavior.
27+
* Each test ensures that widgets on the dashboard operate correctly and display accurate information.
28+
*/
29+
30+
const { metrics } = widgetDetails.linode;
31+
const serviceType = 'linode';
32+
33+
const metricDefinitions = metrics.map(({ name, title, unit }) =>
34+
dashboardMetricFactory.build({
35+
label: title,
36+
metric: name,
37+
unit,
38+
})
39+
);
40+
41+
const mockAccount = accountFactory.build();
42+
const CREATE_ALERT_PAGE_URL = '/alerts/definitions/create';
43+
const NO_OPTIONS_TEXT = 'You have no options to choose from';
44+
45+
describe('Linode ACLP Metrics and Alerts Flag Behavior', () => {
46+
beforeEach(() => {
47+
mockGetAccount(mockAccount); // Enables the account to have capability for Akamai Cloud Pulse
48+
mockGetCloudPulseMetricDefinitions(serviceType, metricDefinitions);
49+
mockGetCloudPulseServices([serviceType]).as('fetchServices');
50+
mockGetUserPreferences({});
51+
});
52+
53+
it('should show Linode with beta tag in Service dropdown on Alert page when alerts.beta is true', () => {
54+
mockAppendFeatureFlags(flagsFactory.build());
55+
cy.visitWithLogin(CREATE_ALERT_PAGE_URL);
56+
ui.autocomplete.findByLabel('Service').as('serviceInput');
57+
cy.get('@serviceInput').click();
58+
59+
cy.get('[data-qa-id="linode"]')
60+
.should('have.text', 'Linode')
61+
.parent()
62+
.as('linodeBetaServiceOption');
63+
64+
cy.get('@linodeBetaServiceOption')
65+
.find('[data-testid="betaChip"]')
66+
.should('be.visible')
67+
.and('have.text', 'beta');
68+
69+
cy.get('@serviceInput').should('be.visible').type('Linode');
70+
ui.autocompletePopper.findByTitle('Linode').should('be.visible').click();
71+
});
72+
it('should exclude Linode beta in Service dropdown when alerts.beta is false', () => {
73+
// Mock feature flags with alerts beta disabled
74+
const mockflags = flagsFactory.build({
75+
aclpServices: {
76+
linode: {
77+
alerts: { beta: false, enabled: false },
78+
},
79+
},
80+
});
81+
82+
mockAppendFeatureFlags(mockflags);
83+
84+
// Visit the alert creation page
85+
cy.visitWithLogin(CREATE_ALERT_PAGE_URL);
86+
87+
// Click the Service dropdown
88+
ui.autocomplete.findByLabel('Service').as('serviceInput');
89+
cy.get('@serviceInput').click();
90+
91+
// Assert dropdown behavior
92+
cy.get('[data-qa-autocomplete-popper]')
93+
.should('be.visible')
94+
.and('have.text', NO_OPTIONS_TEXT)
95+
.and('not.contain.text', 'Linode beta');
96+
});
97+
98+
it('should show no available services in the Service dropdown when Linode alerts are disabled but beta is true', () => {
99+
const mockflags = flagsFactory.build({
100+
aclpServices: {
101+
linode: {
102+
alerts: { beta: true, enabled: false },
103+
},
104+
},
105+
});
106+
107+
mockAppendFeatureFlags(mockflags);
108+
// Visit the alert creation page
109+
cy.visitWithLogin(CREATE_ALERT_PAGE_URL);
110+
// Click the Service dropdown
111+
ui.autocomplete.findByLabel('Service').as('serviceInput');
112+
cy.get('@serviceInput').click();
113+
114+
// ---------- Assert ----------
115+
cy.get('[data-qa-autocomplete-popper]')
116+
.should('be.visible')
117+
.and('have.text', NO_OPTIONS_TEXT)
118+
.and('not.contain.text', 'Linode beta');
119+
});
120+
121+
it('should show no options and exclude Linode beta in Service dropdown when alerts are disabled but beta is true', () => {
122+
const mockflags = flagsFactory.build({
123+
aclpServices: {
124+
linode: {
125+
alerts: { beta: true, enabled: false },
126+
},
127+
},
128+
});
129+
130+
mockAppendFeatureFlags(mockflags);
131+
// Visit the alert creation page
132+
cy.visitWithLogin(CREATE_ALERT_PAGE_URL);
133+
// Click the Service dropdown
134+
ui.autocomplete.findByLabel('Service').as('serviceInput');
135+
cy.get('@serviceInput').click();
136+
137+
// ---------- Assert ----------
138+
cy.get('[data-qa-autocomplete-popper]')
139+
.should('be.visible')
140+
.and('contain.text', 'You have no options to choose from')
141+
.and('not.contain.text', 'Linode beta');
142+
});
143+
144+
it('should show Linode without beta tag in Service dropdown when alerts are enabled but not in beta', () => {
145+
const mockflags = flagsFactory.build({
146+
aclpServices: {
147+
linode: {
148+
alerts: { beta: false, enabled: true },
149+
},
150+
},
151+
});
152+
mockAppendFeatureFlags(mockflags);
153+
cy.visitWithLogin(CREATE_ALERT_PAGE_URL);
154+
ui.autocomplete.findByLabel('Service').as('serviceInput');
155+
cy.get('@serviceInput').click();
156+
157+
// ---------- Assert ----------
158+
cy.get('[data-qa-id="linode"]')
159+
.should('have.text', 'Linode')
160+
.parent()
161+
.as('linodeBetaServiceOption');
162+
163+
cy.get('@linodeBetaServiceOption')
164+
.find('[data-testid="betaChip"]')
165+
.should('not.exist');
166+
});
167+
});

packages/manager/cypress/e2e/core/cloudpulse/cloudpulse-dashboard-errors.spec.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ import {
3333
dashboardFactory,
3434
dashboardMetricFactory,
3535
databaseFactory,
36+
flagsFactory,
3637
widgetFactory,
3738
} from 'src/factories';
3839

3940
import type { Database } from '@linode/api-v4';
40-
import type { Flags } from 'src/featureFlags';
4141

4242
/**
4343
* Verifies the presence and values of specific properties within the aclpPreference object
@@ -47,22 +47,6 @@ import type { Flags } from 'src/featureFlags';
4747
* @param requestPayload - The payload received from the request, containing the aclpPreference object.
4848
* @param expectedValues - An object containing the expected values for properties to validate against the requestPayload.
4949
*/
50-
51-
const flags: Partial<Flags> = {
52-
aclp: { beta: true, enabled: true },
53-
aclpResourceTypeMap: [
54-
{
55-
dimensionKey: 'LINODE_ID',
56-
maxResourceSelections: 10,
57-
serviceType: 'linode',
58-
},
59-
{
60-
dimensionKey: 'cluster_id',
61-
maxResourceSelections: 10,
62-
serviceType: 'dbaas',
63-
},
64-
],
65-
};
6650
const { clusterName, dashboardName, engine, id, metrics, nodeType } =
6751
widgetDetails.dbaas;
6852
const serviceType = 'dbaas';
@@ -132,7 +116,7 @@ const mockAccount = accountFactory.build();
132116

133117
describe('Tests for API error handling', () => {
134118
beforeEach(() => {
135-
mockAppendFeatureFlags(flags);
119+
mockAppendFeatureFlags(flagsFactory.build());
136120
mockGetAccount(mockAccount);
137121
mockGetCloudPulseMetricDefinitions(serviceType, metricDefinitions);
138122
mockGetCloudPulseDashboards(serviceType, [dashboard]).as('fetchDashboard');

packages/manager/cypress/e2e/core/cloudpulse/create-user-alert.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@ import {
2626
cpuRulesFactory,
2727
dashboardMetricFactory,
2828
databaseFactory,
29+
flagsFactory,
2930
memoryRulesFactory,
3031
notificationChannelFactory,
3132
triggerConditionFactory,
3233
} from 'src/factories';
3334
import { CREATE_ALERT_SUCCESS_MESSAGE } from 'src/features/CloudPulse/Alerts/constants';
3435
import { formatDate } from 'src/utilities/formatDate';
35-
36-
import type { Flags } from 'src/featureFlags';
37-
3836
export interface MetricDetails {
3937
aggregationType: string;
4038
dataField: string;
@@ -43,8 +41,6 @@ export interface MetricDetails {
4341
threshold: string;
4442
}
4543

46-
const flags: Partial<Flags> = { aclp: { beta: true, enabled: true } };
47-
4844
// Create mock data
4945
const mockAccount = accountFactory.build();
5046
const mockRegions = [
@@ -176,7 +172,7 @@ describe('Create Alert', () => {
176172
* - Confirms that the UI displays a success message after creating an alert.
177173
*/
178174
beforeEach(() => {
179-
mockAppendFeatureFlags(flags);
175+
mockAppendFeatureFlags(flagsFactory.build());
180176
mockGetAccount(mockAccount);
181177
mockGetProfile(mockProfile);
182178
mockGetCloudPulseServices([serviceType]);

packages/manager/cypress/e2e/core/cloudpulse/dbaas-widgets-verification.spec.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
dashboardMetricFactory,
2828
databaseFactory,
2929
dimensionFilterFactory,
30+
flagsFactory,
3031
kubeLinodeFactory,
3132
widgetFactory,
3233
} from 'src/factories';
@@ -40,7 +41,6 @@ import type {
4041
DimensionFilter,
4142
Widgets,
4243
} from '@linode/api-v4';
43-
import type { Flags } from 'src/featureFlags';
4444
import type { Interception } from 'support/cypress-exports';
4545

4646
/**
@@ -55,23 +55,6 @@ import type { Interception } from 'support/cypress-exports';
5555
*/
5656
const expectedGranularityArray = ['Auto', '1 day', '1 hr', '5 min'];
5757
const timeDurationToSelect = 'Last 24 Hours';
58-
59-
const flags: Partial<Flags> = {
60-
aclp: { beta: true, enabled: true },
61-
aclpResourceTypeMap: [
62-
{
63-
dimensionKey: 'LINODE_ID',
64-
maxResourceSelections: 10,
65-
serviceType: 'linode',
66-
},
67-
{
68-
dimensionKey: 'cluster_id',
69-
maxResourceSelections: 10,
70-
serviceType: 'dbaas',
71-
},
72-
],
73-
};
74-
7558
const { clusterName, dashboardName, engine, id, metrics, nodeType } =
7659
widgetDetails.dbaas;
7760
const serviceType = 'dbaas';
@@ -199,7 +182,7 @@ const validateWidgetFilters = (widget: Widgets) => {
199182

200183
describe('Integration Tests for DBaaS Dashboard ', () => {
201184
beforeEach(() => {
202-
mockAppendFeatureFlags(flags);
185+
mockAppendFeatureFlags(flagsFactory.build());
203186
mockGetAccount(mockAccount); // Enables the account to have capability for Akamai Cloud Pulse
204187
mockGetLinodes([mockLinode]);
205188
mockGetCloudPulseMetricDefinitions(serviceType, metricDefinitions);

0 commit comments

Comments
 (0)