|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
import React from 'react'; |
|
|
|
|
|
|
|
|
|
import { render } from '@testing-library/react'; |
|
|
|
|
import { render, screen } from '@testing-library/react'; |
|
|
|
|
import userEvent from '@testing-library/user-event'; |
|
|
|
|
import { UnifiedAlertingPromotion, LOCAL_STORAGE_KEY } from './UnifiedAlertingPromotion'; |
|
|
|
|
|
|
|
|
@ -10,8 +10,8 @@ describe('Unified Alerting promotion', () => { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should show by default', () => { |
|
|
|
|
const promotion = render(<UnifiedAlertingPromotion />); |
|
|
|
|
expect(promotion.queryByLabelText('Alert info')).toBeInTheDocument(); |
|
|
|
|
render(<UnifiedAlertingPromotion />); |
|
|
|
|
expect(screen.queryByText('Try out the Grafana 8 alerting!')).toBeInTheDocument(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should be hidden if dismissed', () => { |
|
|
|
@ -21,14 +21,14 @@ describe('Unified Alerting promotion', () => { |
|
|
|
|
const dismissButton = promotion.getByRole('button'); |
|
|
|
|
userEvent.click(dismissButton); |
|
|
|
|
|
|
|
|
|
expect(promotion.queryByLabelText('Alert info')).not.toBeInTheDocument(); |
|
|
|
|
expect(screen.queryByText('Try out the Grafana 8 alerting!')).not.toBeInTheDocument(); |
|
|
|
|
expect(window.localStorage.getItem(LOCAL_STORAGE_KEY)).toBe('false'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should not render if previously dismissed', () => { |
|
|
|
|
window.localStorage.setItem(LOCAL_STORAGE_KEY, 'false'); |
|
|
|
|
const promotion = render(<UnifiedAlertingPromotion />); |
|
|
|
|
render(<UnifiedAlertingPromotion />); |
|
|
|
|
|
|
|
|
|
expect(promotion.queryByLabelText('Alert info')).not.toBeInTheDocument(); |
|
|
|
|
expect(screen.queryByText('Try out the Grafana 8 alerting!')).not.toBeInTheDocument(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|