diff --git a/packages/manager/.changeset/pr-12442-tests-1751388010586.md b/packages/manager/.changeset/pr-12442-tests-1751388010586.md new file mode 100644 index 00000000000..3c47b59b324 --- /dev/null +++ b/packages/manager/.changeset/pr-12442-tests-1751388010586.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Tests +--- + +Linode alerts tab based on region and user preference ([#12442](https://github.com/linode/manager/pull/12442)) diff --git a/packages/manager/cypress/e2e/core/cloudpulse/aclp-support.spec.ts b/packages/manager/cypress/e2e/core/cloudpulse/aclp-support.spec.ts index d5c9e977b4b..d8f57e7ddaa 100644 --- a/packages/manager/cypress/e2e/core/cloudpulse/aclp-support.spec.ts +++ b/packages/manager/cypress/e2e/core/cloudpulse/aclp-support.spec.ts @@ -13,6 +13,13 @@ import { } from 'support/util/cloudpulse'; import { randomLabel, randomNumber } from 'support/util/random'; +import { + METRICS_BETA_MODE_BANNER_TEXT, + METRICS_BETA_MODE_BUTTON_TEXT, + METRICS_LEGACY_MODE_BANNER_TEXT, + METRICS_LEGACY_MODE_BUTTON_TEXT, +} from 'src/features/Linodes/constants'; + import type { Stats } from '@linode/api-v4'; /** @@ -87,12 +94,10 @@ describe('ACLP Components UI varies according to ACLP support by region and user cy.get('[data-testid="metrics-preference-banner-text"]').should( 'be.visible' ); - cy.contains( - 'Welcome to Metrics (Beta) with more options and greater flexibility for better data analysis.' - ).should('be.visible'); + cy.contains(METRICS_BETA_MODE_BANNER_TEXT).should('be.visible'); ui.button - .findByTitle('Switch to legacy Metrics') + .findByTitle(METRICS_BETA_MODE_BUTTON_TEXT) .should('be.visible') .should('be.enabled'); // UI displays mock error msg @@ -104,8 +109,6 @@ describe('ACLP Components UI varies according to ACLP support by region and user // UI displays legacy metrics, can switch to beta view it('user preference disables aclp', function () { - const msgBeta = - 'Try the new Metrics (Beta) with more options and greater flexibility for better data analysis. You can switch back to the current view at any time.'; mockGetUserPreferences({ isAclpMetricsBeta: false }).as( 'getUserPreferences' ); @@ -136,21 +139,19 @@ describe('ACLP Components UI varies according to ACLP support by region and user ); // expect legacy metrics view of LinodeSummary component to be displayed cy.get('[data-testid="linode-summary"]').should('be.visible'); - cy.contains(msgBeta).should('be.visible'); + cy.contains(METRICS_LEGACY_MODE_BANNER_TEXT).should('be.visible'); // switch to beta metrics ui.button - .findByTitle('Try the Metrics (Beta)') + .findByTitle(METRICS_LEGACY_MODE_BUTTON_TEXT) .should('be.visible') .should('be.enabled') .click(); // wait for dashboard query to complete cy.wait('@getDashboardError'); - cy.contains( - 'Welcome to Metrics (Beta) with more options and greater flexibility for better data analysis.' - ).should('be.visible'); - cy.contains(msgBeta).should('not.exist'); + cy.contains(METRICS_BETA_MODE_BANNER_TEXT).should('be.visible'); + cy.contains(METRICS_LEGACY_MODE_BANNER_TEXT).should('not.exist'); ui.button - .findByTitle('Switch to legacy Metrics') + .findByTitle(METRICS_BETA_MODE_BUTTON_TEXT) .should('be.visible') .should('be.enabled'); }); diff --git a/packages/manager/cypress/e2e/core/linodes/alerts-edit.spec.ts b/packages/manager/cypress/e2e/core/linodes/alerts-edit.spec.ts new file mode 100644 index 00000000000..29418530955 --- /dev/null +++ b/packages/manager/cypress/e2e/core/linodes/alerts-edit.spec.ts @@ -0,0 +1,499 @@ +import { linodeFactory, regionFactory } from '@linode/utilities'; +import { mockGetAlertDefinition } from 'support/intercepts/cloudpulse'; +import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags'; +import { + mockGetLinodeDetails, + mockUpdateLinode, +} from 'support/intercepts/linodes'; +import { mockGetRegions } from 'support/intercepts/regions'; +import { ui } from 'support/ui'; +import { assertLinodeAlertsEnabled } from 'support/util/linodes'; +import { randomLabel } from 'support/util/random'; + +import { alertFactory } from 'src/factories'; +import { + ALERTS_BETA_MODE_BANNER_TEXT, + ALERTS_BETA_MODE_BUTTON_TEXT, + ALERTS_LEGACY_MODE_BANNER_TEXT, + ALERTS_LEGACY_MODE_BUTTON_TEXT, +} from 'src/features/Linodes/constants'; + +const MOCK_LINODE_ID = 2; +const mockDisabledLegacyAlerts = { + cpu: 0, + io: 0, + network_in: 0, + network_out: 0, + transfer_quota: 0, +}; +const mockEnabledLegacyAlerts = { + cpu: 180, + io: 10000, + network_in: 10, + network_out: 10, + transfer_quota: 80, +}; + +const mockDisabledBetaAlerts = { + system: [], + user: [], +}; + +const mockEnabledBetaAlerts = { + system: [1, 2], + user: [3], +}; + +/* + * UI of Linode alerts tab based on beta and legacy alert values in linode.alerts. Dependent on region support for alerts + * Legacy alerts = 0, Beta alerts = [] (empty arrays or no values at all) => legacy disabled for `beta` stage OR beta disabled for `ga` stage + * Legacy alerts > 0, Beta alerts = [] (empty arrays or no values at all) => legacy enabled + * Legacy alerts = 0, Beta alerts has values (either system, user, or both) => beta enabled + * Legacy alerts > 0, Beta alerts has values (either system, user, or both) => beta enabled + * + * Note: Here, "disabled" means that all toggles are in the OFF state, but it's still editable (not read-only) + */ + +describe('region enables alerts', function () { + beforeEach(() => { + mockAppendFeatureFlags({ + aclpBetaServices: { + linode: { + alerts: true, + metrics: false, + }, + }, + }).as('getFeatureFlags'); + const mockEnabledRegion = regionFactory.build({ + capabilities: ['Linodes'], + monitors: { + alerts: ['Linodes'], + }, + }); + cy.wrap(mockEnabledRegion).as('mockEnabledRegion'); + mockGetRegions([mockEnabledRegion]).as('getRegions'); + + const alertDefinitions = [ + alertFactory.build({ + id: 1, + description: randomLabel(), + label: randomLabel(), + service_type: 'linode', + severity: 1, + status: 'enabled', + type: 'system', + entity_ids: [MOCK_LINODE_ID.toString()], + }), + alertFactory.build({ + id: 2, + description: randomLabel(), + label: randomLabel(), + service_type: 'linode', + severity: 1, + status: 'enabled', + type: 'system', + entity_ids: [MOCK_LINODE_ID.toString()], + }), + alertFactory.build({ + id: 3, + description: randomLabel(), + label: randomLabel(), + service_type: 'linode', + severity: 1, + status: 'enabled', + type: 'user', + entity_ids: [MOCK_LINODE_ID.toString()], + }), + ]; + cy.wrap(alertDefinitions).as('alertDefinitions'); + mockGetAlertDefinition('linode', alertDefinitions).as( + 'getAlertDefinitions' + ); + }); + + it('Legacy alerts = 0, Beta alerts = [] => legacy disabled', function () { + const mockLinode = linodeFactory.build({ + id: MOCK_LINODE_ID, + label: randomLabel(), + region: this.mockEnabledRegion.id, + alerts: { + ...mockDisabledLegacyAlerts, + ...mockDisabledBetaAlerts, + }, + }); + mockGetLinodeDetails(mockLinode.id, mockLinode).as('getLinode'); + cy.visitWithLogin(`/linodes/${mockLinode.id}/alerts`); + cy.wait(['@getFeatureFlags', '@getRegions', '@getLinode']); + ui.tabList.findTabByTitle('Alerts').within(() => { + cy.get('[data-testid="betaChip"]').should('not.exist'); + }); + cy.get('[data-reach-tab-panels]') + .should('be.visible') + .within(() => { + cy.contains('Alerts').should('be.visible'); + cy.get('[data-testid="notice-info"]') + .should('be.visible') + .within(() => { + cy.contains(ALERTS_LEGACY_MODE_BANNER_TEXT); + }); + // alerts are disabled so all toggles are off + ui.toggle.find().each(($toggle) => { + cy.wrap($toggle).should('have.attr', 'data-qa-toggle', 'false'); + }); + }); + + // upgrade from legacy alerts to ACLP alerts + ui.button + .findByTitle(ALERTS_LEGACY_MODE_BUTTON_TEXT) + .should('be.visible') + .should('be.enabled') + .click(); + + ui.tabList.findTabByTitle('Alerts').within(() => { + cy.get('[data-testid="betaChip"]').should('be.visible'); + }); + cy.get('[data-reach-tab-panels]') + .should('be.visible') + .within(() => { + cy.contains('Alerts').should('be.visible'); + cy.get('[data-testid="notice-info"]') + .should('be.visible') + .within(() => { + cy.contains(ALERTS_BETA_MODE_BANNER_TEXT); + }); + // possible to downgrade from ACLP alerts to legacy alerts + ui.button + .findByTitle(ALERTS_BETA_MODE_BUTTON_TEXT) + .should('be.visible') + .should('be.enabled'); + + cy.wait(['@getAlertDefinitions']); + assertLinodeAlertsEnabled(this.alertDefinitions); + }); + }); + + it('Legacy alerts > 0, Beta alerts = [] => legacy enabled. can upgrade to beta enabled', function () { + const mockLinode = linodeFactory.build({ + id: MOCK_LINODE_ID, + label: randomLabel(), + region: this.mockEnabledRegion.id, + alerts: { + // legacy alerts are enabled if value > 0 + ...mockEnabledLegacyAlerts, + }, + }); + mockGetLinodeDetails(mockLinode.id, mockLinode).as('getLinode'); + cy.visitWithLogin(`/linodes/${mockLinode.id}/alerts`); + cy.wait(['@getFeatureFlags', '@getRegions', '@getLinode']); + ui.tabList.findTabByTitle('Alerts').within(() => { + cy.get('[data-testid="betaChip"]').should('not.exist'); + }); + cy.get('[data-reach-tab-panels]') + .should('be.visible') + .within(() => { + cy.contains('Alerts').should('be.visible'); + cy.get('[data-testid="notice-info"]') + .should('be.visible') + .within(() => { + cy.contains(ALERTS_LEGACY_MODE_BANNER_TEXT); + }); + + // alerts are enabled so all toggles are on if val > 0 + ui.toggle.find().each(($toggle) => { + cy.wrap($toggle).should('have.attr', 'data-qa-toggle', 'true'); + }); + }); + + // upgrade from legacy alerts to ACLP alerts + ui.button + .findByTitle(ALERTS_LEGACY_MODE_BUTTON_TEXT) + .should('be.visible') + .should('be.enabled') + .click(); + ui.tabList.findTabByTitle('Alerts').within(() => { + cy.get('[data-testid="betaChip"]').should('be.visible'); + }); + cy.get('[data-reach-tab-panels]') + .should('be.visible') + .within(() => { + cy.contains('Alerts').should('be.visible'); + cy.get('[data-testid="notice-info"]') + .should('be.visible') + .within(() => { + cy.contains(ALERTS_BETA_MODE_BANNER_TEXT); + }); + cy.wait(['@getAlertDefinitions']); + // toggles in table are on but can be turned off + assertLinodeAlertsEnabled(this.alertDefinitions); + + mockUpdateLinode(mockLinode.id).as('updateLinode'); + ui.button + .findByTitle('Save') + .should('be.visible') + .should('be.enabled') + .click(); + }); + + // TODO: this test passes but modal behavior may change when properly implemented in api (M3-10195) + // ui.dialog + // .findByTitle('Save Alerts?') + // .should('be.visible') + // .within(() => { + // ui.button.findByTitle('Save').should('be.visible') + // .click(); + // }); + // TODO: content of request.body not match prod, 'alerts' attribute missing here + // cy.wait('@updateLinode').then((xhr) => { + // // can save changes. new beta alerts added in assertLinodeAlertsEnabled tests + // const edits = xhr.request.body; + // expect(JSON.stringify(edits.system)).to.equal( + // JSON.stringify([]) + // ); + // expect(JSON.stringify(edits.user)).to.equal( + // JSON.stringify([]) + // ); + // }); + }); + + it('Legacy alerts = 0, Beta alerts > 0, => beta enabled', function () { + const mockLinode = linodeFactory.build({ + id: 2, + label: randomLabel(), + region: this.mockEnabledRegion.id, + alerts: { + ...mockDisabledLegacyAlerts, + ...mockEnabledBetaAlerts, + }, + }); + mockGetLinodeDetails(mockLinode.id, mockLinode).as('getLinode'); + cy.visitWithLogin(`/linodes/${mockLinode.id}/alerts`); + cy.wait(['@getFeatureFlags', '@getRegions', '@getLinode']); + ui.tabList.findTabByTitle('Alerts').within(() => { + cy.get('[data-testid="betaChip"]').should('be.visible'); + }); + cy.get('[data-reach-tab-panels]') + .should('be.visible') + .within(() => { + cy.contains('Alerts').should('be.visible'); + cy.get('[data-testid="notice-info"]') + .should('be.visible') + .within(() => { + cy.contains(ALERTS_BETA_MODE_BANNER_TEXT); + }); + cy.wait(['@getAlertDefinitions']); + assertLinodeAlertsEnabled(this.alertDefinitions); + }); + + // downgrade from ACLP alerts to legacy alerts + ui.button + .findByTitle(ALERTS_BETA_MODE_BUTTON_TEXT) + .should('be.visible') + .should('be.enabled') + .click(); + + ui.tabList.findTabByTitle('Alerts').within(() => { + cy.get('[data-testid="betaChip"]').should('not.exist'); + }); + cy.get('[data-reach-tab-panels]') + .should('be.visible') + .within(() => { + cy.contains('Alerts').should('be.visible'); + cy.get('[data-testid="notice-info"]') + .should('be.visible') + .within(() => { + cy.contains(ALERTS_LEGACY_MODE_BANNER_TEXT); + }); + // alerts are disabled so all toggles are off + ui.toggle.find().each(($toggle) => { + cy.wrap($toggle) + .should('have.attr', 'data-qa-toggle', 'false') + .should('be.visible') + .should('be.enabled') + .click(); + }); + // possible to upgrade to beta + ui.button + .findByTitle(ALERTS_LEGACY_MODE_BUTTON_TEXT) + .should('be.visible') + .should('be.enabled'); + + // can save changes + ui.button.findByTitle('Save').should('be.visible').should('be.enabled'); + }); + }); + + it('Legacy alerts > 0, Beta alerts > 0, => beta enabled. can downgrade to legacy enabled', function () { + const mockLinode = linodeFactory.build({ + id: MOCK_LINODE_ID, + label: randomLabel(), + region: this.mockEnabledRegion.id, + alerts: { + ...mockEnabledLegacyAlerts, + ...mockEnabledBetaAlerts, + }, + }); + mockGetLinodeDetails(mockLinode.id, mockLinode).as('getLinode'); + cy.visitWithLogin(`/linodes/${mockLinode.id}/alerts`); + cy.wait(['@getFeatureFlags', '@getRegions', '@getLinode']); + ui.tabList.findTabByTitle('Alerts').within(() => { + cy.get('[data-testid="betaChip"]').should('be.visible'); + }); + cy.get('[data-reach-tab-panels]') + .should('be.visible') + .within(() => { + cy.contains('Alerts').should('be.visible'); + cy.get('[data-testid="notice-info"]') + .should('be.visible') + .within(() => { + cy.contains(ALERTS_BETA_MODE_BANNER_TEXT); + }); + cy.wait(['@getAlertDefinitions']); + assertLinodeAlertsEnabled(this.alertDefinitions); + // downgrade from ACLP alerts to legacy alerts + ui.button + .findByTitle(ALERTS_BETA_MODE_BUTTON_TEXT) + .should('be.visible') + .should('be.enabled') + .click(); + }); + + // beta alerts UI loaded + ui.tabList.findTabByTitle('Alerts').within(() => { + cy.get('[data-testid="betaChip"]').should('not.exist'); + }); + cy.get('[data-reach-tab-panels]') + .should('be.visible') + .within(() => { + cy.contains('Alerts').should('be.visible'); + cy.get('[data-testid="notice-info"]') + .should('be.visible') + .within(() => { + cy.contains(ALERTS_LEGACY_MODE_BANNER_TEXT); + }); + // turn the toggles off + ui.toggle + .find() + .should('have.attr', 'data-qa-toggle', 'true') + .should('be.visible') + .click({ multiple: true }); + ui.toggle.find().should('have.attr', 'data-qa-toggle', 'false'); + + mockUpdateLinode(mockLinode.id).as('updateLinode'); + cy.scrollTo('bottom'); + // save changes + ui.button + .findByTitle('Save') + .should('be.visible') + .should('be.enabled') + .click(); + }); + // TODO: this test passes but modal behavior may change when properly implemented in api (M3-10195) + // ui.dialog + // .findByTitle('Are you sure you want to save legacy Alerts?') + // .should('be.visible') + // .within(() => { + // ui.button.findByTitle('Confirm').should('be.visible') + // .click(); + // }); + // TODO: this test passes but modal behavior will change when properly implemented in api (M3-10195) + // TODO: this test passes but modal behavior may change when properly implemented in api (M3-10195) + // ui.dialog + // .findByTitle('Save Alerts?') + // .should('be.visible') + // .within(() => { + // ui.button.findByTitle('Save').should('be.visible') + // .click(); + // }); + }); +}); + +describe('region disables alerts. beta alerts not available regardless of linode settings', function () { + beforeEach(() => { + mockAppendFeatureFlags({ + aclpBetaServices: { + linode: { + alerts: true, + metrics: false, + }, + }, + }).as('getFeatureFlags'); + + const mockDisabledRegion = regionFactory.build({ + capabilities: ['Linodes'], + monitors: { + alerts: [], + }, + }); + cy.wrap(mockDisabledRegion).as('mockDisabledRegion'); + mockGetRegions([mockDisabledRegion]).as('getRegions'); + }); + + it('Legacy alerts = 0, Beta alerts > 0, => legacy disabled', function () { + const mockLinode = linodeFactory.build({ + id: MOCK_LINODE_ID, + label: randomLabel(), + region: this.mockDisabledRegion.id, + alerts: { + ...mockDisabledLegacyAlerts, + ...mockEnabledBetaAlerts, + }, + }); + mockGetLinodeDetails(mockLinode.id, mockLinode).as('getLinode'); + cy.visitWithLogin(`/linodes/${mockLinode.id}/alerts`); + cy.wait(['@getFeatureFlags', '@getRegions', '@getLinode']); + ui.tabList.findTabByTitle('Alerts').within(() => { + cy.get('[data-testid="betaChip"]').should('not.exist'); + }); + cy.get('[data-reach-tab-panels]') + .should('be.visible') + .within(() => { + cy.contains('Alerts').should('be.visible'); + cy.get('[data-testid="notice-info"]').should('not.exist'); + // not possible to upgrade or downgrade + cy.findByText(ALERTS_LEGACY_MODE_BUTTON_TEXT).should('not.exist'); + cy.findByText(ALERTS_BETA_MODE_BUTTON_TEXT).should('not.exist'); + // alerts are disabled so all toggles are off but are not readonly + ui.toggle.find().each(($toggle) => { + cy.wrap($toggle) + .should('have.attr', 'data-qa-toggle', 'false') + .should('be.visible') + .should('be.enabled') + .click(); + cy.wrap($toggle).should('have.attr', 'data-qa-toggle', 'true'); + }); + }); + }); + + it('Legacy alerts > 0, Beta alerts = 0, => legacy enabled', function () { + const mockLinode = linodeFactory.build({ + id: MOCK_LINODE_ID, + label: randomLabel(), + region: this.mockDisabledRegion.id, + alerts: { ...mockEnabledLegacyAlerts }, + }); + mockGetLinodeDetails(mockLinode.id, mockLinode).as('getLinode'); + cy.visitWithLogin(`/linodes/${mockLinode.id}/alerts`); + cy.wait(['@getFeatureFlags', '@getRegions', '@getLinode']); + ui.tabList.findTabByTitle('Alerts').within(() => { + cy.get('[data-testid="betaChip"]').should('not.exist'); + }); + cy.get('[data-reach-tab-panels]') + .should('be.visible') + .within(() => { + cy.contains('Alerts').should('be.visible'); + cy.get('[data-testid="notice-info"]').should('not.exist'); + // not possible to upgrade or downgrade + cy.findByText(ALERTS_LEGACY_MODE_BUTTON_TEXT).should('not.exist'); + cy.findByText(ALERTS_BETA_MODE_BUTTON_TEXT).should('not.exist'); + // legacy alerts are enabled + ui.toggle.find().each(($toggle) => { + cy.wrap($toggle) + .should('have.attr', 'data-qa-toggle', 'true') + .should('be.visible') + .should('be.enabled') + .click(); + cy.wrap($toggle).should('have.attr', 'data-qa-toggle', 'false'); + }); + }); + }); +}); diff --git a/packages/manager/cypress/support/intercepts/linodes.ts b/packages/manager/cypress/support/intercepts/linodes.ts index f6d42673ea7..d57a0f76908 100644 --- a/packages/manager/cypress/support/intercepts/linodes.ts +++ b/packages/manager/cypress/support/intercepts/linodes.ts @@ -779,3 +779,14 @@ export const mockGetLinodeStats = ( makeResponse(stats) ); }; + +/** + * Intercepts PUT request to edit details of a linode + * + * @param linodeId - ID of Linode for intercepted request. + * + * @returns Cypress chainable. + */ +export const mockUpdateLinode = (linodeId: number): Cypress.Chainable => { + return cy.intercept('PUT', apiMatcher(`linode/instances/${linodeId}`)); +}; diff --git a/packages/manager/cypress/support/util/linodes.ts b/packages/manager/cypress/support/util/linodes.ts index 73e2dfee084..174ed08ea9e 100644 --- a/packages/manager/cypress/support/util/linodes.ts +++ b/packages/manager/cypress/support/util/linodes.ts @@ -30,6 +30,7 @@ import { chooseRegion } from 'support/util/regions'; import { depaginate } from './paginate'; import type { + Alert, Config, CreateLinodeRequest, InterfacePayload, @@ -338,3 +339,51 @@ export const assertNewLinodeInterfacesIsAvailable = ( cy.findByText(networkConnectionSectionText).should(expectedBehavior); cy.findByText(networkConnectionDescriptionText).should(expectedBehavior); }; + +/** + * Validates the table cell contents against the alerts provided + * + * @param linodeInterfacesEnabled - Indicator if Linode Interfaces feature is enabled. + */ +export const assertLinodeAlertsEnabled = (alertDefinitions: Alert[]) => { + cy.get('table[data-testid="alert-table"]') + .should('be.visible') + .get('tbody > tr') + .should('have.length', 3) + .each((row, index) => { + // match alert definitions to table cell contents + cy.wrap(row).within(() => { + cy.get('td') + .eq(0) + .within(() => { + // each alert's toggle should be enabled/on/true and editable + ui.toggle + .find() + .should('have.attr', 'data-qa-toggle', 'true') + .should('be.visible') + .should('be.enabled') + .click(); + ui.toggle.find().should('have.attr', 'data-qa-toggle', 'false'); + }); + cy.get('td') + .eq(1) + .within(() => { + cy.findByText(alertDefinitions[index].label).should('be.visible'); + }); + cy.get('td') + .eq(2) + .within(() => { + const rule = alertDefinitions[index].rule_criteria.rules[0]; + const str = `${rule.label} = ${rule.threshold} ${rule.unit}`; + cy.findByText(str).should('be.visible'); + }); + cy.get('td') + .eq(3) + .within(() => { + cy.findByText(alertDefinitions[index].type, { + exact: false, + }).should('be.visible'); + }); + }); + }); +}; diff --git a/packages/manager/src/features/Linodes/AclpPreferenceToggle.test.tsx b/packages/manager/src/features/Linodes/AclpPreferenceToggle.test.tsx index 7579e715b01..281f2cca69b 100644 --- a/packages/manager/src/features/Linodes/AclpPreferenceToggle.test.tsx +++ b/packages/manager/src/features/Linodes/AclpPreferenceToggle.test.tsx @@ -6,6 +6,16 @@ import { vi } from 'vitest'; import { renderWithTheme } from 'src/utilities/testHelpers'; import { AclpPreferenceToggle } from './AclpPreferenceToggle'; +import { + ALERTS_BETA_MODE_BANNER_TEXT, + ALERTS_BETA_MODE_BUTTON_TEXT, + ALERTS_LEGACY_MODE_BANNER_TEXT, + ALERTS_LEGACY_MODE_BUTTON_TEXT, + METRICS_BETA_MODE_BANNER_TEXT, + METRICS_BETA_MODE_BUTTON_TEXT, + METRICS_LEGACY_MODE_BANNER_TEXT, + METRICS_LEGACY_MODE_BUTTON_TEXT, +} from './constants'; import type { AclpPreferenceToggleType } from './AclpPreferenceToggle'; @@ -23,21 +33,17 @@ const expectedAclpPreferences: Record< > = { metrics: { preference: true, - legacyModeBannerText: - 'Try the new Metrics (Beta) with more options and greater flexibility for better data analysis. You can switch back to the current view at any time.', - betaModeBannertext: - 'Welcome to Metrics (Beta) with more options and greater flexibility for better data analysis.', - legacyModeButtonText: 'Try the Metrics (Beta)', - betaModeButtonText: 'Switch to legacy Metrics', + legacyModeBannerText: METRICS_LEGACY_MODE_BANNER_TEXT, + betaModeBannertext: METRICS_BETA_MODE_BANNER_TEXT, + legacyModeButtonText: METRICS_LEGACY_MODE_BUTTON_TEXT, + betaModeButtonText: METRICS_BETA_MODE_BUTTON_TEXT, }, alerts: { preference: true, - legacyModeBannerText: - 'Try the Alerts (Beta), featuring new options like customizable alerts. You can switch back to legacy Alerts at any time.', - betaModeBannertext: - 'Welcome to Alerts (Beta), designed for flexibility with features like customizable alerts.', - legacyModeButtonText: 'Try Alerts (Beta)', - betaModeButtonText: 'Switch to legacy Alerts', + legacyModeBannerText: ALERTS_LEGACY_MODE_BANNER_TEXT, + betaModeBannertext: ALERTS_BETA_MODE_BANNER_TEXT, + legacyModeButtonText: ALERTS_LEGACY_MODE_BUTTON_TEXT, + betaModeButtonText: ALERTS_BETA_MODE_BUTTON_TEXT, }, }; diff --git a/packages/manager/src/features/Linodes/constants.ts b/packages/manager/src/features/Linodes/constants.ts index 824305a7d7b..aebe974fa8b 100644 --- a/packages/manager/src/features/Linodes/constants.ts +++ b/packages/manager/src/features/Linodes/constants.ts @@ -6,3 +6,24 @@ export const PUBLIC_IP_ADDRESSES_LINODE_INTERFACE_NOT_ASSIGNED_TOOLTIP_TEXT = export const PUBLIC_IP_ADDRESSES_LINODE_INTERFACE_DEFAULT_ROUTE_TOOLTIP_TEXT = 'This Public IP Address is provisionally reserved but not the default route. To update this, please review your Interface Settings.'; + +export const METRICS_LEGACY_MODE_BANNER_TEXT = + 'Try the new Metrics (Beta) with more options and greater flexibility for better data analysis. You can switch back to the current view at any time.'; + +export const METRICS_BETA_MODE_BANNER_TEXT = + 'Welcome to Metrics (Beta) with more options and greater flexibility for better data analysis.'; + +export const METRICS_LEGACY_MODE_BUTTON_TEXT = 'Try the Metrics (Beta)'; + +export const METRICS_BETA_MODE_BUTTON_TEXT = 'Switch to legacy Metrics'; + +export const ALERTS_LEGACY_MODE_BANNER_TEXT = + 'Try the Alerts (Beta), featuring new options like customizable alerts. You can switch back to legacy Alerts at any time.'; + +export const ALERTS_BETA_MODE_BANNER_TEXT = + 'Welcome to Alerts (Beta), designed for flexibility with features like customizable alerts.'; + +export const ALERTS_LEGACY_MODE_BUTTON_TEXT = 'Try Alerts (Beta)'; + +export const ALERTS_BETA_MODE_BUTTON_TEXT = 'Switch to legacy Alerts'; +