Alerting: fix e2e testing selectors (#41829)

This commit is contained in:
Gilles De Mey 2021-11-17 19:23:30 +01:00 committed by GitHub
parent b611d54349
commit 1bd43bae2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -55,7 +55,9 @@ var config = {
url: '${HOST}/alerting/list',
wait: 500,
rootElement: '.main-view',
threshold: 0,
// the unified alerting promotion alert's content contrast is too low
// see https://github.com/grafana/grafana/pull/41829
threshold: 5,
},
{
url: '${HOST}/datasources',

View File

@ -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();
});
});