From 6a0b0883a8704c0fe657940aeba32818b2a6e22d Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Fri, 25 Jun 2021 12:19:50 -0700 Subject: [PATCH] Crawler DomainsTable test coverage/improvements - 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) --- .../crawler/components/domains_table.test.tsx | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/domains_table.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/domains_table.test.tsx index aab2909d630ed..fc5ad0cb06411 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/domains_table.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/domains_table.test.tsx @@ -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', }, ]; @@ -68,15 +77,6 @@ describe('DomainsTable', () => { }); describe('columns', () => { - const getTable = () => wrapper.find(EuiInMemoryTable).dive().find(EuiBasicTable).dive(); - - beforeEach(() => { - wrapper = shallow(); - tableContent = mountWithIntl() - .find(EuiInMemoryTable) - .text(); - }); - it('renders a url column', () => { expect(tableContent).toContain('elastic.co'); }); @@ -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({