@@ -14,6 +14,7 @@ import { alertFactory } from 'src/factories';
1414import {
1515 ALERTS_BETA_MODE_BANNER_TEXT ,
1616 ALERTS_BETA_MODE_BUTTON_TEXT ,
17+ ALERTS_BETA_PROMPT ,
1718 ALERTS_LEGACY_MODE_BANNER_TEXT ,
1819 ALERTS_LEGACY_MODE_BUTTON_TEXT ,
1920 ALERTS_LEGACY_PROMPT ,
@@ -240,26 +241,6 @@ describe('region enables alerts', function () {
240241 . should ( 'be.enabled' )
241242 . click ( ) ;
242243 } ) ;
243-
244- // TODO: this test passes but modal behavior may change when properly implemented in api (M3-10195)
245- // ui.dialog
246- // .findByTitle('Save Alerts?')
247- // .should('be.visible')
248- // .within(() => {
249- // ui.button.findByTitle('Save').should('be.visible')
250- // .click();
251- // });
252- // TODO: content of request.body not match prod, 'alerts' attribute missing here
253- // cy.wait('@updateLinode').then((xhr) => {
254- // // can save changes. new beta alerts added in assertLinodeAlertsEnabled tests
255- // const edits = xhr.request.body;
256- // expect(JSON.stringify(edits.system)).to.equal(
257- // JSON.stringify([])
258- // );
259- // expect(JSON.stringify(edits.user)).to.equal(
260- // JSON.stringify([])
261- // );
262- // });
263244 } ) ;
264245
265246 it ( 'Legacy alerts = 0, Beta alerts > 0, => beta enabled' , function ( ) {
@@ -401,6 +382,131 @@ describe('region enables alerts', function () {
401382 ui . button . findByTitle ( 'Confirm' ) . should ( 'be.visible' ) . click ( ) ;
402383 } ) ;
403384 } ) ;
385+
386+ it ( 'in default beta mode, edits to beta alerts do not trigger confirmation modal' , function ( ) {
387+ const mockLinode = linodeFactory . build ( {
388+ id : 2 ,
389+ label : randomLabel ( ) ,
390+ region : this . mockEnabledRegion . id ,
391+ alerts : {
392+ ...mockEnabledBetaAlerts ,
393+ } ,
394+ } ) ;
395+ mockGetLinodeDetails ( mockLinode . id , mockLinode ) . as ( 'getLinode' ) ;
396+ cy . visitWithLogin ( `/linodes/${ mockLinode . id } /alerts` ) ;
397+ cy . wait ( [ '@getFeatureFlags' , '@getRegions' , '@getLinode' ] ) ;
398+ ui . tabList . findTabByTitle ( 'Alerts' ) . within ( ( ) => {
399+ cy . get ( '[data-testid="betaChip"]' ) . should ( 'be.visible' ) ;
400+ } ) ;
401+ cy . get ( '[data-reach-tab-panels]' )
402+ . should ( 'be.visible' )
403+ . within ( ( ) => {
404+ cy . contains ( 'Alerts' ) . should ( 'be.visible' ) ;
405+ cy . get ( '[data-testid="notice-info"]' )
406+ . should ( 'be.visible' )
407+ . within ( ( ) => {
408+ cy . contains ( ALERTS_BETA_MODE_BANNER_TEXT ) ;
409+ } ) ;
410+ cy . wait ( [ '@getAlertDefinitions' ] ) ;
411+ // toggles in table are on but can be turned off
412+ assertLinodeAlertsEnabled ( this . alertDefinitions ) ;
413+
414+ mockUpdateLinode ( mockLinode . id ) . as ( 'updateLinode' ) ;
415+ ui . button
416+ . findByTitle ( 'Save' )
417+ . should ( 'be.visible' )
418+ . should ( 'be.enabled' )
419+ . click ( ) ;
420+ } ) ;
421+ // M3-10369: "Save Alerts?" prompt does not appear bc beta is already default mode
422+ ui . dialog . find ( ) . should ( 'not.exist' ) ;
423+ } ) ;
424+
425+ it ( 'in default legacy mode, edits to beta alerts trigger confirmation modal ' , function ( ) {
426+ const mockLinode = linodeFactory . build ( {
427+ id : 2 ,
428+ label : randomLabel ( ) ,
429+ region : this . mockEnabledRegion . id ,
430+ alerts : {
431+ ...mockEnabledLegacyAlerts ,
432+ } ,
433+ } ) ;
434+ mockGetLinodeDetails ( mockLinode . id , mockLinode ) . as ( 'getLinode' ) ;
435+ cy . visitWithLogin ( `/linodes/${ mockLinode . id } /alerts` ) ;
436+ cy . wait ( [ '@getFeatureFlags' , '@getRegions' , '@getLinode' ] ) ;
437+ ui . tabList . findTabByTitle ( 'Alerts' ) . within ( ( ) => {
438+ cy . get ( '[data-testid="betaChip"]' ) . should ( 'not.exist' ) ;
439+ } ) ;
440+ cy . get ( '[data-reach-tab-panels]' )
441+ . should ( 'be.visible' )
442+ . within ( ( ) => {
443+ cy . contains ( 'Alerts' ) . should ( 'be.visible' ) ;
444+ cy . get ( '[data-testid="notice-info"]' )
445+ . should ( 'be.visible' )
446+ . within ( ( ) => {
447+ cy . contains ( ALERTS_LEGACY_MODE_BANNER_TEXT ) ;
448+ } ) ;
449+ } ) ;
450+
451+ // upgrade from legacy alerts to ACLP alerts
452+ ui . button
453+ . findByTitle ( ALERTS_LEGACY_MODE_BUTTON_TEXT )
454+ . should ( 'be.visible' )
455+ . should ( 'be.enabled' )
456+ . click ( ) ;
457+
458+ ui . tabList . findTabByTitle ( 'Alerts' ) . within ( ( ) => {
459+ cy . get ( '[data-testid="betaChip"]' ) . should ( 'be.visible' ) ;
460+ } ) ;
461+ cy . get ( '[data-reach-tab-panels]' )
462+ . should ( 'be.visible' )
463+ . within ( ( ) => {
464+ cy . contains ( 'Alerts' ) . should ( 'be.visible' ) ;
465+ cy . get ( '[data-testid="notice-info"]' )
466+ . should ( 'be.visible' )
467+ . within ( ( ) => {
468+ cy . contains ( ALERTS_BETA_MODE_BANNER_TEXT ) ;
469+ } ) ;
470+ cy . wait ( [ '@getAlertDefinitions' ] ) ;
471+ cy . get ( 'table[data-testid="alert-table"]' )
472+ . should ( 'be.visible' )
473+ . get ( 'tbody > tr' )
474+ . should ( 'have.length' , 3 )
475+ . each ( ( row , index ) => {
476+ // match alert definitions to table cell contents
477+ cy . wrap ( row ) . within ( ( ) => {
478+ cy . get ( 'td' )
479+ . eq ( 0 )
480+ . within ( ( ) => {
481+ // each alert's toggle should be enabled/on/true and editable
482+ ui . toggle
483+ . find ( )
484+ . should ( 'have.attr' , 'data-qa-toggle' , 'true' )
485+ . should ( 'be.visible' )
486+ . should ( 'be.enabled' )
487+ . click ( ) ;
488+ ui . toggle
489+ . find ( )
490+ . should ( 'have.attr' , 'data-qa-toggle' , 'false' ) ;
491+ } ) ;
492+ } ) ;
493+ } ) ;
494+
495+ mockUpdateLinode ( mockLinode . id ) . as ( 'updateLinode' ) ;
496+ ui . button
497+ . findByTitle ( 'Save' )
498+ . should ( 'be.visible' )
499+ . should ( 'be.enabled' )
500+ . click ( ) ;
501+ } ) ;
502+ // M3-10369: "Save Alerts?" prompt appears bc of edits to beta alerts but linode was previously in legacy mode
503+ ui . dialog
504+ . findByTitle ( ALERTS_BETA_PROMPT )
505+ . should ( 'be.visible' )
506+ . within ( ( ) => {
507+ ui . button . findByTitle ( 'Confirm' ) . should ( 'be.visible' ) . click ( ) ;
508+ } ) ;
509+ } ) ;
404510} ) ;
405511
406512describe ( 'region disables alerts. beta alerts not available regardless of linode settings' , function ( ) {
0 commit comments