diff --git a/src/components/ColumnsModal/ColumnsModalComponent.test.js b/src/components/ColumnsModal/ColumnsModalComponent.test.js index 8f613389b..0fcf5cdc4 100644 --- a/src/components/ColumnsModal/ColumnsModalComponent.test.js +++ b/src/components/ColumnsModal/ColumnsModalComponent.test.js @@ -18,7 +18,6 @@ import { within, } from 'custom-testing-lib'; import ColumnsModalComponent from './ColumnsModalComponent'; - describe('ColumnsModalComponent', () => { let baseStore; let store; @@ -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 @@ -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; @@ -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; @@ -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;