Skip to content

Commit

Permalink
[ML] Update transform_table and expanded_row tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Jun 16, 2020
1 parent 5711682 commit 93e70a0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -26,11 +26,26 @@ describe('Transform: Transform List <ExpandedRow />', () => {
moment.tz.setDefault('Browser');
});

test('Minimal initialization', () => {
test('Minimal initialization', async () => {
const item: TransformListRow = transformListRow;

const wrapper = shallow(<ExpandedRow item={item} />);
const { getByText, getByTestId } = render(<ExpandedRow item={item} />);

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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ export const ExpandedRow: FC<Props> = ({ 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',
Expand Down
10 changes: 0 additions & 10 deletions x-pack/test/functional/services/transform/transform_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 93e70a0

Please sign in to comment.