From e631fc9c402521a96ac09f0bdf5b105ef2b737d7 Mon Sep 17 00:00:00 2001 From: Joshua Eilers Date: Wed, 9 Aug 2023 11:57:48 -0700 Subject: [PATCH] harden autocomplete test (#8603) --- .../search/autoComplete/AutoCompleteItem.tsx | 4 +- .../e2e/auto_complete/auto_complete.js | 110 ++++++++++-------- 2 files changed, 62 insertions(+), 52 deletions(-) diff --git a/datahub-web-react/src/app/search/autoComplete/AutoCompleteItem.tsx b/datahub-web-react/src/app/search/autoComplete/AutoCompleteItem.tsx index c97d171b4c..84a5e283cf 100644 --- a/datahub-web-react/src/app/search/autoComplete/AutoCompleteItem.tsx +++ b/datahub-web-react/src/app/search/autoComplete/AutoCompleteItem.tsx @@ -45,7 +45,9 @@ export default function AutoCompleteItem({ query, entity }: Props) { placement="top" color="rgba(0, 0, 0, 0.9)" > - {componentToRender} + + {componentToRender} + ); } diff --git a/smoke-test/tests/cypress/cypress/e2e/auto_complete/auto_complete.js b/smoke-test/tests/cypress/cypress/e2e/auto_complete/auto_complete.js index 48a34ec04c..7221956611 100644 --- a/smoke-test/tests/cypress/cypress/e2e/auto_complete/auto_complete.js +++ b/smoke-test/tests/cypress/cypress/e2e/auto_complete/auto_complete.js @@ -1,56 +1,64 @@ +describe("auto-complete", () => { + it("should see auto-complete results after typing in a search query", () => { + cy.login(); + cy.visit("/"); -describe('auto-complete', () => { - it('should see auto-complete results after typing in a search query', () => { - cy.login(); - cy.visit("/"); - - // look for a dataset - cy.get("input[data-testid=search-input]").type("SampleCypressHive"); - cy.contains("Datasets") - cy.contains("SampleCypressHiveDataset") - cy.focused().clear(); - - // look for a dashboard - cy.get("input[data-testid=search-input]").type("baz"); - cy.contains("Dashboards") - cy.contains("Baz Dashboard") - cy.focused().clear(); + // look for a dataset + cy.get("input[data-testid=search-input]").type("SampleCypressHive"); + cy.contains("Datasets"); + cy.contains("SampleCypressHiveDataset"); + cy.focused().clear(); - // look for a dataflow - cy.get("input[data-testid=search-input]").type("dataflow user"); - cy.contains("Pipelines") - cy.contains("Users") - cy.focused().clear(); - }); + // look for a dashboard + cy.get("input[data-testid=search-input]").type("baz"); + cy.contains("Dashboards"); + cy.contains("Baz Dashboard"); + cy.focused().clear(); - it('should send you to the entity profile after clicking on an auto-complete option', () => { - cy.login(); - cy.visit("/"); - cy.get("input[data-testid=search-input]").type("SampleCypressHiveDataset"); - cy.get('[data-testid="auto-complete-option"]').first().click(); - cy.url().should('include', 'dataset/urn:li:dataset:(urn:li:dataPlatform:hive,SampleCypressHiveDataset,PROD)'); - cy.wait(2000); - }); + // look for a dataflow + cy.get("input[data-testid=search-input]").type("dataflow user"); + cy.contains("Pipelines"); + cy.contains("Users"); + cy.focused().clear(); + }); - it('should filter auto-complete results when clicking on a quick filter', () => { - cy.login(); - cy.visit("/"); - cy.get("input[data-testid=search-input]").type("baz"); - cy.contains("Baz Chart 2") - cy.get('[data-testid="quick-filter-DASHBOARD"]').click(); - cy.wait(2000); - cy.ensureTextNotPresent("Baz Chart 2"); - cy.contains("Baz Dashboard"); - cy.wait(1000); - }); + it("should send you to the entity profile after clicking on an auto-complete option", () => { + cy.login(); + cy.visit("/"); + cy.get("input[data-testid=search-input]").type("SampleCypressHiveDataset"); + cy.get('[data-testid^="auto-complete-option"]').first().click(); + cy.url().should( + "include", + "dataset/urn:li:dataset:(urn:li:dataPlatform:hive,SampleCypressHiveDataset,PROD)" + ); + cy.wait(2000); + }); - it('should filter search results when when searching with a quick filter selected', () => { - cy.login(); - cy.visit("/"); - cy.get("input[data-testid=search-input]").type("raw_pay"); - cy.contains("raw_payments") - cy.get('[data-testid="quick-filter-urn:li:dataPlatform:bigquery"]').click(); - cy.focused().type("{enter}"); - cy.url().should('include', '?filter_platform___false___EQUAL___0=urn%3Ali%3AdataPlatform%3Abigquery'); - }); -}) \ No newline at end of file + it("should filter auto-complete results when clicking on a quick filter", () => { + cy.login(); + cy.visit("/"); + cy.get("input[data-testid=search-input]").type("baz"); + + cy.get('[data-testid="auto-complete-option--urn:li:chart:(looker,baz2)"'); + cy.get('[data-testid="quick-filter-DASHBOARD"]').click(); + cy.wait(2000); + cy.get( + '[data-testid="auto-complete-option--urn:li:chart:(looker,baz2)"' + ).should("not.exist"); + cy.contains("Baz Dashboard"); + cy.wait(1000); + }); + + it("should filter search results when when searching with a quick filter selected", () => { + cy.login(); + cy.visit("/"); + cy.get("input[data-testid=search-input]").type("raw_pay"); + cy.contains("raw_payments"); + cy.get('[data-testid="quick-filter-urn:li:dataPlatform:bigquery"]').click(); + cy.focused().type("{enter}"); + cy.url().should( + "include", + "?filter_platform___false___EQUAL___0=urn%3Ali%3AdataPlatform%3Abigquery" + ); + }); +});