@@ -333,8 +333,55 @@ describe('AlertRulesList', () => {
333333 expect ( rules [ 0 ] ) . toBeInTheDocument ( ) ;
334334
335335 expect ( screen . getByText ( 'Triggered' ) ) . toBeInTheDocument ( ) ;
336- expect ( screen . getByText ( 'Above 70' ) ) . toBeInTheDocument ( ) ;
337- expect ( screen . getByText ( 'Below 36' ) ) . toBeInTheDocument ( ) ;
336+ expect ( screen . getByText ( 'Above 70' ) ) . toBeInTheDocument ( ) ; // the fixture trigger threshold
337+ expect ( screen . getByText ( 'Below 36' ) ) . toBeInTheDocument ( ) ; // the fixture resolved threshold
338+ expect ( screen . getAllByTestId ( 'alert-badge' ) [ 0 ] ) . toBeInTheDocument ( ) ;
339+ } ) ;
340+
341+ it ( 'displays activated metric alert status' , async ( ) => {
342+ rulesMock = MockApiClient . addMockResponse ( {
343+ url : '/organizations/org-slug/combined-rules/' ,
344+ headers : { Link : pageLinks } ,
345+ body : [
346+ MetricRuleFixture ( {
347+ id : '1' ,
348+ projects : [ 'earth' ] ,
349+ name : 'Active Activated Alert' ,
350+ monitorType : 1 ,
351+ activationCondition : 0 ,
352+ activations : [
353+ {
354+ alertRuleId : '1' ,
355+ dateCreated : '2021-08-01T00:00:00Z' ,
356+ finishedAt : '' ,
357+ id : '1' ,
358+ isComplete : false ,
359+ querySubscriptionId : '1' ,
360+ } ,
361+ ] ,
362+ latestIncident : IncidentFixture ( {
363+ status : IncidentStatus . CRITICAL ,
364+ } ) ,
365+ } ) ,
366+ MetricRuleFixture ( {
367+ id : '2' ,
368+ projects : [ 'earth' ] ,
369+ name : 'Ready Activated Alert' ,
370+ monitorType : 1 ,
371+ activationCondition : 0 ,
372+ } ) ,
373+ ] ,
374+ } ) ;
375+ const { routerContext, organization} = initializeOrg ( { organization : defaultOrg } ) ;
376+ render ( < AlertRulesList /> , { context : routerContext , organization} ) ;
377+
378+ expect ( await screen . findByText ( 'Active Activated Alert' ) ) . toBeInTheDocument ( ) ;
379+ expect ( await screen . findByText ( 'Ready Activated Alert' ) ) . toBeInTheDocument ( ) ;
380+
381+ expect ( screen . getByText ( 'Last activated' ) ) . toBeInTheDocument ( ) ;
382+ expect ( screen . getByText ( 'Alert has not been activated yet' ) ) . toBeInTheDocument ( ) ;
383+ expect ( screen . getByText ( 'Above 70' ) ) . toBeInTheDocument ( ) ; // the fixture trigger threshold
384+ expect ( screen . getByText ( 'Below 70' ) ) . toBeInTheDocument ( ) ; // Alert has never fired, so no resolved threshold
338385 expect ( screen . getAllByTestId ( 'alert-badge' ) [ 0 ] ) . toBeInTheDocument ( ) ;
339386 } ) ;
340387
0 commit comments