Skip to content

Commit

Permalink
Crawler DomainsTable test coverage/improvements
Browse files Browse the repository at this point in the history
- Fix test failing locally due to timezones by increasing the timezone offset

- Cover missing branch line by adding a domain with no `lastCrawl`

- Remove unnecessary extra beforeEach with dupe re-shallow/mounts

- move getTable helper to its most relevant block (it's not being used in the generic column content checks, only in the actions column suite)
  • Loading branch information
cee-chen committed Jun 25, 2021
1 parent 652a1d6 commit 6a0b088
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@ const domains: CrawlerDomain[] = [
crawlRules: [],
entryPoints: [],
sitemaps: [],
lastCrawl: '2020-01-01T00:00:00-05:00',
createdOn: '2020-01-01T00:00:00-05:00',
lastCrawl: '2020-01-01T00:00:00-12:00',
createdOn: '2020-01-01T00:00:00-12:00',
},
{
id: '4567',
documentCount: 0,
url: 'empty.site',
crawlRules: [],
entryPoints: [],
sitemaps: [],
createdOn: '1970-01-01T00:00:00-12:00',
},
];

Expand Down Expand Up @@ -68,15 +77,6 @@ describe('DomainsTable', () => {
});

describe('columns', () => {
const getTable = () => wrapper.find(EuiInMemoryTable).dive().find(EuiBasicTable).dive();

beforeEach(() => {
wrapper = shallow(<DomainsTable />);
tableContent = mountWithIntl(<DomainsTable />)
.find(EuiInMemoryTable)
.text();
});

it('renders a url column', () => {
expect(tableContent).toContain('elastic.co');
});
Expand All @@ -92,8 +92,9 @@ describe('DomainsTable', () => {
});

describe('actions column', () => {
const getTable = () => wrapper.find(EuiInMemoryTable).dive().find(EuiBasicTable).dive();
const getActions = () => getTable().find('ExpandedItemActions');
const getActionItems = () => getActions().dive().find('DefaultItemAction');
const getActionItems = () => getActions().first().dive().find('DefaultItemAction');

it('will hide the action buttons if the user cannot manage/delete engines', () => {
setMockValues({
Expand Down

0 comments on commit 6a0b088

Please sign in to comment.