Skip to content

Commit

Permalink
Update unit tests for custom column UI changes
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Reynolds <[email protected]>
  • Loading branch information
gsreynolds committed Jul 23, 2024
1 parent e703506 commit 86e826a
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/components/ColumnsModal/ColumnsModalComponent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
within,
} from 'custom-testing-lib';
import ColumnsModalComponent from './ColumnsModalComponent';

describe('ColumnsModalComponent', () => {
let baseStore;
let store;
Expand Down Expand Up @@ -93,14 +92,18 @@ describe('ColumnsModalComponent', () => {
expect(screen.getAllByLabelText('Remove column')).toHaveLength(8);
expect(screen.getByRole('heading', { name: 'Available' })).toBeInTheDocument();
expect(screen.getByRole('heading', { name: 'Custom' })).toBeInTheDocument();
expect(screen.getByRole('heading', { name: 'alert' })).toBeInTheDocument();
expect(screen.getByRole('heading', { name: 'computed' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'OK' })).toBeInTheDocument();
});

it('should render an enabled custom column option with unique header name', () => {
// Find the Custom header, and find the CustomField DnD box near it
const customColumns = screen.getByText('Custom').parentElement.parentElement;
const customColumn = within(customColumns).getByText('CustomField:details.to.some.path');
const customColumns = screen.getByRole('heading', { name: 'alert' }).parentElement.parentElement;
const customColumn = within(customColumns).getAllByText('Header', { exact: false })[0].parentElement.parentElement;
expect(customColumn).toBeInTheDocument();
expect(customColumn).toHaveTextContent('CustomField');
expect(customColumn).toHaveTextContent('details.to.some.path');
expect(within(customColumn).getByLabelText('Remove column')).toBeInTheDocument();

// Find the Selected header, and find the Selected DnD box near it
Expand All @@ -111,11 +114,11 @@ describe('ColumnsModalComponent', () => {
});

it('should render an available custom alert column option with unique header name', () => {
const customColumns = screen.getByText('Custom').parentElement.parentElement;
const customColumn = within(customColumns).getByText(
'AnotherCustomField:details.to.some.other.path',
);
const customColumns = screen.getByRole('heading', { name: 'alert' }).parentElement.parentElement;
const customColumn = within(customColumns).getAllByText('Header', { exact: false })[1].parentElement.parentElement;
expect(customColumn).toBeInTheDocument();
expect(customColumn).toHaveTextContent('AnotherCustomField');
expect(customColumn).toHaveTextContent('details.to.some.other.path');
expect(within(customColumn).getByLabelText('Remove column')).toBeInTheDocument();

const availableColumns = screen.getByText('Available').parentElement.parentElement;
Expand All @@ -125,11 +128,11 @@ describe('ColumnsModalComponent', () => {
});

it('should render an enabled custom column option with JSON path containing spaces', () => {
const customColumns = screen.getByText('Custom').parentElement.parentElement;
const customColumn = within(customColumns).getByText(
"Fav Flavour:details.['favorite ice cream flavor']",
);
const customColumns = screen.getByRole('heading', { name: 'alert' }).parentElement.parentElement;
const customColumn = within(customColumns).getAllByText('Header', { exact: false })[2].parentElement.parentElement;
expect(customColumn).toBeInTheDocument();
expect(customColumn).toHaveTextContent('Fav Flavour');
expect(customColumn).toHaveTextContent("details.['favorite ice cream flavor']");
expect(within(customColumn).getByLabelText('Remove column')).toBeInTheDocument();

const selectedColumns = screen.getByText('Selected').parentElement.parentElement;
Expand All @@ -148,11 +151,12 @@ describe('ColumnsModalComponent', () => {
// });

it('should render an available computed option with unique header name', () => {
const customColumns = screen.getByText('Custom').parentElement.parentElement;
const customColumn = within(customColumns).getByText(
'regex-single in incident body:first_trigger_log_entry.channel.details:(.*.example.com)',
);
const customColumns = screen.getByRole('heading', { name: 'computed' }).parentElement.parentElement;
const customColumn = within(customColumns).getByText('Header', { exact: false }).parentElement.parentElement;
expect(customColumn).toBeInTheDocument();
expect(customColumn).toHaveTextContent('regex-single in incident body');
expect(customColumn).toHaveTextContent('first_trigger_log_entry.channel.details');
expect(customColumn).toHaveTextContent('(.*.example.com)');
expect(within(customColumn).getByLabelText('Remove column')).toBeInTheDocument();

const availableColumns = screen.getByText('Available').parentElement.parentElement;
Expand Down

0 comments on commit 86e826a

Please sign in to comment.