From 1bd43bae2d920b24730db6e5c60a0d93f689f680 Mon Sep 17 00:00:00 2001 From: Gilles De Mey Date: Wed, 17 Nov 2021 19:23:30 +0100 Subject: [PATCH] Alerting: fix e2e testing selectors (#41829) --- .pa11yci-pr.conf.js | 4 +++- .../components/UnifiedAlertingPromotion.test.tsx | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.pa11yci-pr.conf.js b/.pa11yci-pr.conf.js index 1d729078a94..816e6d8f6c5 100644 --- a/.pa11yci-pr.conf.js +++ b/.pa11yci-pr.conf.js @@ -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', diff --git a/public/app/features/alerting/components/UnifiedAlertingPromotion.test.tsx b/public/app/features/alerting/components/UnifiedAlertingPromotion.test.tsx index dba56797acf..1a5df7e6527 100644 --- a/public/app/features/alerting/components/UnifiedAlertingPromotion.test.tsx +++ b/public/app/features/alerting/components/UnifiedAlertingPromotion.test.tsx @@ -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(); - expect(promotion.queryByLabelText('Alert info')).toBeInTheDocument(); + render(); + 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(); + render(); - expect(promotion.queryByLabelText('Alert info')).not.toBeInTheDocument(); + expect(screen.queryByText('Try out the Grafana 8 alerting!')).not.toBeInTheDocument(); }); });