@@ -148,7 +148,6 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
148148
149149 private async refreshRules ( ) : Promise < Partial < IState > > {
150150 const ruleSets = await MatrixClientPeg . get ( ) . getPushRules ( ) ;
151-
152151 const categories = {
153152 [ RuleId . Master ] : RuleClass . Master ,
154153
@@ -182,6 +181,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
182181 for ( const k in ruleSets . global ) {
183182 // noinspection JSUnfilteredForInLoop
184183 const kind = k as PushRuleKind ;
184+
185185 for ( const r of ruleSets . global [ kind ] ) {
186186 const rule : IAnnotatedPushRule = Object . assign ( r , { kind } ) ;
187187 const category = categories [ rule . rule_id ] ?? RuleClass . Other ;
@@ -471,6 +471,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
471471
472472 private renderTopSection ( ) {
473473 const masterSwitch = < LabelledToggleSwitch
474+ data-test-id = 'notif-master-switch'
474475 value = { ! this . isInhibited }
475476 label = { _t ( "Enable for this account" ) }
476477 onChange = { this . onMasterRuleChanged }
@@ -484,6 +485,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
484485
485486 const emailSwitches = ( this . state . threepids || [ ] ) . filter ( t => t . medium === ThreepidMedium . Email )
486487 . map ( e => < LabelledToggleSwitch
488+ data-test-id = 'notif-email-switch'
487489 key = { e . address }
488490 value = { this . state . pushers . some ( p => p . kind === "email" && p . pushkey === e . address ) }
489491 label = { _t ( "Enable email notifications for %(email)s" , { email : e . address } ) }
@@ -495,20 +497,23 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
495497 { masterSwitch }
496498
497499 < LabelledToggleSwitch
500+ data-test-id = 'notif-setting-notificationsEnabled'
498501 value = { SettingsStore . getValue ( "notificationsEnabled" ) }
499502 onChange = { this . onDesktopNotificationsChanged }
500503 label = { _t ( 'Enable desktop notifications for this session' ) }
501504 disabled = { this . state . phase === Phase . Persisting }
502505 />
503506
504507 < LabelledToggleSwitch
508+ data-test-id = 'notif-setting-notificationBodyEnabled'
505509 value = { SettingsStore . getValue ( "notificationBodyEnabled" ) }
506510 onChange = { this . onDesktopShowBodyChanged }
507511 label = { _t ( 'Show message in desktop notification' ) }
508512 disabled = { this . state . phase === Phase . Persisting }
509513 />
510514
511515 < LabelledToggleSwitch
516+ data-test-id = 'notif-setting-audioNotificationsEnabled'
512517 value = { SettingsStore . getValue ( "audioNotificationsEnabled" ) }
513518 onChange = { this . onAudioNotificationsChanged }
514519 label = { _t ( 'Enable audible notifications for this session' ) }
@@ -559,17 +564,27 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
559564 /> ;
560565 }
561566
567+ const VectorStateToLabel = {
568+ [ VectorState . On ] : _t ( 'On' ) ,
569+ [ VectorState . Off ] : _t ( 'Off' ) ,
570+ [ VectorState . Loud ] : _t ( 'Noisy' ) ,
571+ } ;
572+
562573 const makeRadio = ( r : IVectorPushRule , s : VectorState ) => (
563574 < StyledRadioButton
564575 key = { r . ruleId }
565576 name = { r . ruleId }
566577 checked = { r . vectorState === s }
567578 onChange = { this . onRadioChecked . bind ( this , r , s ) }
568579 disabled = { this . state . phase === Phase . Persisting }
580+ aria-label = { VectorStateToLabel [ s ] }
569581 />
570582 ) ;
571583
572- const rows = this . state . vectorPushRules [ category ] . map ( r => < tr key = { category + r . ruleId } >
584+ const rows = this . state . vectorPushRules [ category ] . map ( r => < tr
585+ data-test-id = { category + r . ruleId }
586+ key = { category + r . ruleId }
587+ >
573588 < td > { r . description } </ td >
574589 < td > { makeRadio ( r , VectorState . Off ) } </ td >
575590 < td > { makeRadio ( r , VectorState . On ) } </ td >
@@ -592,13 +607,13 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
592607 }
593608
594609 return < >
595- < table className = 'mx_UserNotifSettings_pushRulesTable' >
610+ < table data-test-id = { `notif-section- ${ category } ` } className = 'mx_UserNotifSettings_pushRulesTable' >
596611 < thead >
597612 < tr >
598613 < th > { sectionName } </ th >
599- < th > { _t ( " Off" ) } </ th >
600- < th > { _t ( "On" ) } </ th >
601- < th > { _t ( "Noisy" ) } </ th >
614+ < th > { VectorStateToLabel [ VectorState . Off ] } </ th >
615+ < th > { VectorStateToLabel [ VectorState . On ] } </ th >
616+ < th > { VectorStateToLabel [ VectorState . Loud ] } </ th >
602617 </ tr >
603618 </ thead >
604619 < tbody >
@@ -635,7 +650,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
635650 // Ends up default centered
636651 return < Spinner /> ;
637652 } else if ( this . state . phase === Phase . Error ) {
638- return < p > { _t ( "There was an error loading your notification settings." ) } </ p > ;
653+ return < p data-test-id = 'error-message' > { _t ( "There was an error loading your notification settings." ) } </ p > ;
639654 }
640655
641656 return < div className = 'mx_UserNotifSettings' >
0 commit comments