From eb2018b642cd986b0f7fec9c1825452e341d9e75 Mon Sep 17 00:00:00 2001 From: Justin Kambic Date: Wed, 13 Jan 2021 12:24:52 -0500 Subject: [PATCH] [Uptime] Unskip jest tests for `ExecutedStep` component (#88105) * Revise skipped tests to use RTL. * Rename a test. * Add a test covering default status badge text. * Refactor a test to remove redundant code. --- .../monitor/synthetics/executed_step.test.tsx | 407 ++---------------- 1 file changed, 37 insertions(+), 370 deletions(-) diff --git a/x-pack/plugins/uptime/public/components/monitor/synthetics/executed_step.test.tsx b/x-pack/plugins/uptime/public/components/monitor/synthetics/executed_step.test.tsx index 5f40b60420f8..c0ac5d959bda 100644 --- a/x-pack/plugins/uptime/public/components/monitor/synthetics/executed_step.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/synthetics/executed_step.test.tsx @@ -7,11 +7,9 @@ import React from 'react'; import { ExecutedStep } from './executed_step'; import { Ping } from '../../../../common/runtime_types'; -import { mountWithRouter } from '../../../lib'; import { render } from '../../../lib/helper/rtl_helpers'; -// FLAKY: https://github.com/elastic/kibana/issues/85899 -describe.skip('ExecutedStep', () => { +describe('ExecutedStep', () => { let step: Ping; beforeEach(() => { @@ -42,105 +40,28 @@ describe.skip('ExecutedStep', () => { }); it('renders a link to the step detail view', () => { - expect( - mountWithRouter().find( - 'StepDetailLink' - ) - ).toMatchInlineSnapshot(` - - - - - - `); + const { getByRole, getByText } = render( + + ); + expect(getByRole('link')).toHaveAttribute('href', '/journey/fake-group/step/4'); + expect(getByText('4. STEP_NAME')); }); - it('supplies status badge correct status', () => { + it.each([ + ['succeeded', 'Succeeded'], + ['failed', 'Failed'], + ['skipped', 'Skipped'], + ['somegarbage', '4.'], + ])('supplies status badge correct status', (status, expectedStatus) => { step.synthetics = { - payload: { status: 'THE_STATUS' }, + payload: { status }, }; - expect( - mountWithRouter().find( - 'StatusBadge' - ) - ).toMatchInlineSnapshot(` - - - - - - - - - - `); + const { getByText } = render(); + expect(getByText(expectedStatus)); }); - it('renders accordions for step, error message, and error stack script', () => { + it('renders accordion for step', () => { step.synthetics = { - error: { - message: 'There was an error executing the step.', - stack: 'some.stack.trace.string', - }, payload: { source: 'const someVar = "the var"', }, @@ -150,280 +71,26 @@ describe.skip('ExecutedStep', () => { }, }; - expect( - mountWithRouter().find( - 'CodeBlockAccordion' - ) - ).toMatchInlineSnapshot(` - Array [ - - -
-
- -
-
- -
-
- - -
-
-                              
-                                const someVar = "the var"
-                              
-                            
-
-
-
-
-
-
-
-
-
-
, - - -
-
- -
-
- -
-
- - -
-
-                              
-                                There was an error executing the step.
-                              
-                            
-
-
-
-
-
-
-
-
-
-
, - - -
-
- -
-
- -
-
- - -
-
-                              
-                                some.stack.trace.string
-                              
-                            
-
-
-
-
-
-
-
-
-
-
, - ] - `); + const { getByText } = render(); + + expect(getByText('4. STEP_NAME')); + expect(getByText('Step script')); + expect(getByText(`const someVar = "the var"`)); + }); + + it('renders accordions for error message, and stack trace', () => { + step.synthetics = { + error: { + message: 'There was an error executing the step.', + stack: 'some.stack.trace.string', + }, + }; + + const { getByText } = render(); + + expect(getByText('4.')); + expect(getByText('Error')); + expect(getByText('There was an error executing the step.')); + expect(getByText('some.stack.trace.string')); }); });