From 93e70a0be86dd2d5000298f3ec40fe3dfff8e277 Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Tue, 16 Jun 2020 16:58:06 -0500 Subject: [PATCH] [ML] Update transform_table and expanded_row tests --- .../transform_list/expanded_row.test.tsx | 25 +++++++++++++++---- .../transform_list/expanded_row.tsx | 5 ++-- .../services/transform/transform_table.ts | 10 -------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.test.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.test.tsx index d13730eb6dc6..2b1ddf654e47 100644 --- a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.test.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.test.tsx @@ -4,14 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallow } from 'enzyme'; +import { render, fireEvent } from '@testing-library/react'; import React from 'react'; import moment from 'moment-timezone'; - import { TransformListRow } from '../../../../common'; import { ExpandedRow } from './expanded_row'; import transformListRow from '../../../../common/__mocks__/transform_list_row.json'; +import { within } from '@testing-library/dom'; jest.mock('../../../../../shared_imports', () => ({ formatHumanReadableDateTimeSeconds: jest.fn(), @@ -26,11 +26,26 @@ describe('Transform: Transform List ', () => { moment.tz.setDefault('Browser'); }); - test('Minimal initialization', () => { + test('Minimal initialization', async () => { const item: TransformListRow = transformListRow; - const wrapper = shallow(); + const { getByText, getByTestId } = render(); + + expect(getByText('Settings')).toBeInTheDocument(); + expect(getByText('Details')).toBeInTheDocument(); + expect(getByText('Stats')).toBeInTheDocument(); + expect(getByText('JSON')).toBeInTheDocument(); + expect(getByText('Messages')).toBeInTheDocument(); + expect(getByText('Preview')).toBeInTheDocument(); + + const tabContent = getByTestId('transformDetailsTabContent'); + expect(tabContent).toBeInTheDocument(); + + expect(getByTestId('transformSettingsTab')).toHaveAttribute('aria-selected', 'true'); + expect(within(tabContent).getByText('General')).toBeInTheDocument(); - expect(wrapper).toMatchSnapshot(); + fireEvent.click(getByTestId('transformStatsTab')); + expect(getByTestId('transformStatsTab')).toHaveAttribute('aria-selected', 'true'); + expect(within(tabContent).getByText('Stats')).toBeInTheDocument(); }); }); diff --git a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx index b0576b4efded..0e3c3542edc8 100644 --- a/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx +++ b/x-pack/plugins/transform/public/app/sections/transform_management/components/transform_list/expanded_row.tsx @@ -79,9 +79,8 @@ export const ExpandedRow: FC = ({ item }) => { }, { title: 'create_time', - description: formatHumanReadableDateTimeSeconds( - moment(item.config.create_time).unix() * 1000 - ), + description: + formatHumanReadableDateTimeSeconds(moment(item.config.create_time).unix() * 1000) ?? '', }, { title: 'source_index', diff --git a/x-pack/test/functional/services/transform/transform_table.ts b/x-pack/test/functional/services/transform/transform_table.ts index 3155ef0b2605..0c9a5414bdd2 100644 --- a/x-pack/test/functional/services/transform/transform_table.ts +++ b/x-pack/test/functional/services/transform/transform_table.ts @@ -31,16 +31,6 @@ export function TransformTableProvider({ getService }: FtrProviderContext) { .find('.euiTableCellContent') .text() .trim(), - sourceIndex: $tr - .findTestSubject('transformListColumnSourceIndex') - .find('.euiTableCellContent') - .text() - .trim(), - destinationIndex: $tr - .findTestSubject('transformListColumnDestinationIndex') - .find('.euiTableCellContent') - .text() - .trim(), status: $tr .findTestSubject('transformListColumnStatus') .find('.euiTableCellContent')