Skip to content

Commit

Permalink
fix(ci): reduce flakiness views select test (#6821)
Browse files Browse the repository at this point in the history
  • Loading branch information
anshbansal authored Dec 21, 2022
1 parent 8972ea4 commit 2fb0b1e
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const ViewBuilderForm = ({ urn, mode, state, updateState }: Props) => {
hasFeedback
>
<Input
data-testid="view-name-input"
placeholder="Data Analyst"
onChange={(event) => setName(event.target.value)}
disabled={mode === ViewBuilderMode.PREVIEW}
Expand All @@ -80,6 +81,7 @@ export const ViewBuilderForm = ({ urn, mode, state, updateState }: Props) => {
<Typography.Paragraph>Write a description for your View.</Typography.Paragraph>
<Form.Item name="description" rules={[{ whitespace: true }, { min: 1, max: 500 }]} hasFeedback>
<Input.TextArea
data-testid="view-description-input"
placeholder="This View is useful for Data Analysts"
onChange={(event) => setDescription(event.target.value)}
disabled={mode === ViewBuilderMode.PREVIEW}
Expand Down
2 changes: 1 addition & 1 deletion smoke-test/tests/cypress/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"projectId": "hkrxk5",
"defaultCommandTimeout": 10000,
"retries": {
"runMode": 2,
"runMode": 1,
"openMode": 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,8 @@ describe("glossaryTerm", () => {
cy.contains("Add Filter").click();
cy.contains(/^Tag$/).click({ force: true });

cy.get('[data-testid="tag-term-modal-input"]').type("Cypress2");
cy.wait(2000);
cy.get('[data-testid="tag-term-option"]').click({ force: true });
cy.get('[data-testid="add-tag-term-from-modal-btn"]').click({
force: true,
});
cy.selectOptionInTagTermModal("Cypress2");

cy.wait(2000);
cy.contains("SampleCypressHdfsDataset");
// Only 1 result.
cy.contains("of 1");
Expand All @@ -72,13 +66,9 @@ describe("glossaryTerm", () => {
cy.contains("Advanced").click();
cy.contains("Add Filter").click();
cy.contains(/^Tag$/).click({ force: true });
cy.get('[data-testid="tag-term-modal-input"]').type("Cypress2");
cy.wait(2000);
cy.get('[data-testid="tag-term-option"]').click({ force: true });
cy.get('[data-testid="add-tag-term-from-modal-btn"]').click({
force: true,
});
cy.wait(2000);

cy.selectOptionInTagTermModal("Cypress2")

cy.contains("Add Filter").click();
cy.get('[data-testid="adv-search-add-filter-description"]').click({
force: true,
Expand All @@ -105,13 +95,8 @@ describe("glossaryTerm", () => {
cy.wait(2000);
cy.contains("Add Filter").click();
cy.contains(/^Tag$/).click({ force: true });
cy.get('[data-testid="tag-term-modal-input"]').type("Cypress2");
cy.wait(2000);
cy.get('[data-testid="tag-term-option"]').click({ force: true });
cy.get('[data-testid="add-tag-term-from-modal-btn"]').click({
force: true,
});
cy.wait(2000);

cy.selectOptionInTagTermModal("Cypress2");

cy.contains("all filters").click();
cy.contains("any filter").click({ force: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,7 @@ describe("mutations", () => {
cy.contains("Add Term").click({ force: true })
);

cy.focused().type("CypressTerm");

cy.get(".ant-select-item-option-content").within(() =>
cy.contains("CypressTerm").click({ force: true })
);

cy.get('[data-testid="add-tag-term-from-modal-btn"]').click({
force: true,
});
cy.get('[data-testid="add-tag-term-from-modal-btn"]').should("not.exist");
cy.selectOptionInTagTermModal("CypressTerm");

cy.contains("CypressTerm");

Expand Down
47 changes: 4 additions & 43 deletions smoke-test/tests/cypress/cypress/integration/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,7 @@ describe("search", () => {

cy.contains("Add Term").click();

cy.focused().type("CypressTerm");

cy.get(".ant-select-item-option-content").within(() =>
cy.contains("CypressTerm").click({ force: true })
);

cy.get('[data-testid="add-tag-term-from-modal-btn"]').click({
force: true,
});
cy.get('[data-testid="add-tag-term-from-modal-btn"]').should("not.exist");
cy.selectOptionInTagTermModal("CypressTerm");

cy.contains("CypressTerm");
cy.visit("/search?query=cypress");
Expand All @@ -86,17 +77,7 @@ describe("search", () => {

cy.contains("Column Glossary Term").click({ force: true });

cy.get('[data-testid="tag-term-modal-input"]').type("CypressColumnInfo");

cy.wait(2000);

cy.get('[data-testid="tag-term-option"]').click({ force: true });

cy.get('[data-testid="add-tag-term-from-modal-btn"]').click({
force: true,
});

cy.wait(2000);
cy.selectOptionInTagTermModal("CypressColumnInfo");

// has the term in editable metadata
cy.contains("SampleCypressHdfsDataset");
Expand All @@ -120,17 +101,7 @@ describe("search", () => {

cy.contains("Column Glossary Term").click({ force: true });

cy.get('[data-testid="tag-term-modal-input"]').type("CypressColumnInfo");

cy.wait(2000);

cy.get('[data-testid="tag-term-option"]').click({ force: true });

cy.get('[data-testid="add-tag-term-from-modal-btn"]').click({
force: true,
});

cy.wait(2000);
cy.selectOptionInTagTermModal("CypressColumnInfo");

cy.contains("Add Filter").click();

Expand Down Expand Up @@ -159,17 +130,7 @@ describe("search", () => {

cy.contains("Column Glossary Term").click({ force: true });

cy.get('[data-testid="tag-term-modal-input"]').type("CypressColumnInfo");

cy.wait(2000);

cy.get('[data-testid="tag-term-option"]').click({ force: true });

cy.get('[data-testid="add-tag-term-from-modal-btn"]').click({
force: true,
});

cy.wait(2000);
cy.selectOptionInTagTermModal("CypressColumnInfo");

cy.contains("Add Filter").click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,7 @@ describe('siblings', () => {

cy.contains('Add Term').click();

cy.focused().type('CypressTerm');

cy.get('.ant-select-item-option-content').within(() => cy.contains('CypressTerm').click({force: true}));

cy.get('[data-testid="add-tag-term-from-modal-btn"]').click({force: true});

cy.wait(2000);
cy.selectOptionInTagTermModal('CypressTerm');

cy.visit('/dataset/urn:li:dataset:(urn:li:dataPlatform:dbt,cypress_project.jaffle_shop.customers,PROD)/?is_lineage_mode=false');

Expand Down
116 changes: 50 additions & 66 deletions smoke-test/tests/cypress/cypress/integration/views/view_select.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
function openViewEditDropDownAndClickId(data_id) {
cy.openMultiSelect('view-select');
cy.get('[data-testid="view-select-item"]').first().trigger('mouseover')
cy.get('[data-testid="views-table-dropdown"]').first().trigger('mouseover');
cy.clickOptionWithTestId(data_id);
}

describe("view select", () => {
it("click view select, create view, clear view, make defaults, clear view", () => {
const viewName = "Test View"
const viewDescription = "View Description"
const newViewName = "New View Name"
cy.login();
let randomNumber = Math.floor(Math.random() * 100000);
const viewName = `Test View ${randomNumber}`
const newViewName = `New View Name ${randomNumber}`

// Resize Observer Loop warning can be safely ignored - ref. https://github.com/cypress-io/cypress/issues/22113
const resizeObserverLoopErrRe = "ResizeObserver loop limit exceeded";
Expand All @@ -12,90 +20,66 @@ describe("view select", () => {
}
});

cy.login();
cy.visit("/search?page=1&query=%2A&unionType=0");
cy.goToStarSearchList();

// Create a View from the select
cy.get('[data-testid="view-select"]').click();
cy.clickOptionWithTestId("view-select-create");
cy.log("Create a View from the select")
cy.multiSelect('view-select', 'Create View');
cy.waitTextVisible("Create new View")

cy.get(".ant-form-item-control-input-content > input[type='text']").first().type(viewName);
cy.enterTextInTestId("view-name-input", viewName);

// Add Column Glossary Term Filter
cy.contains("Add Filter").click();
cy.contains("Column Glossary Term").click({ force: true });
cy.get('[data-testid="tag-term-modal-input"]').type("CypressColumnInfo");
cy.wait(2000);
cy.get('[data-testid="tag-term-option"]').click({ force: true });
cy.get('[data-testid="add-tag-term-from-modal-btn"]').click({
force: true,
});
cy.log("Add Column Glossary Term Filter")
cy.clickOptionWithText("Add Filter");
cy.clickOptionWithText("Column Glossary Term");

cy.clickOptionWithTestId("view-builder-save");
cy.waitTextVisible(viewName);
cy.waitTextVisible("Add Glossary Terms");
cy.selectOptionInTagTermModal("CypressColumnInfoType");

cy.wait(2000); // Allow search to reload
cy.clickOptionWithText("Save");
cy.ensureTextNotPresent("Save");
cy.waitTextVisible(viewName);

// Ensure the View filter has been applied correctly.
cy.log("Ensure the View filter has been applied correctly.")
cy.contains("SampleCypressHdfsDataset");
cy.contains("cypress_logging_events");
cy.contains("of 2 results");

// Clear the selected view view
cy.get('[data-testid="view-select"]').click();
cy.clickOptionWithTestId("view-select-clear");
cy.get("input[data-testid=search-input]").click(); // unfocus
cy.contains(viewName).should("not.be.visible");

cy.wait(2000); // Allow search to reload
cy.log("Clear the selected view")
cy.clearView(viewName);
cy.ensureTextNotPresent("of 2 results");

// Now edit the view
cy.get('[data-testid="view-select"]').click();
cy.get('[data-testid="view-select-item"]').first().trigger('mouseover')
cy.get('[data-testid="views-table-dropdown"]').first().trigger('mouseover');
cy.get('[data-testid="view-dropdown-edit"]').click();
cy.log("Now edit the view")
openViewEditDropDownAndClickId('view-dropdown-edit');
cy.get(".ant-form-item-control-input-content > input[type='text']").first().clear().type(newViewName);
// Update the actual filters by adding another filter
cy.log("Update the actual filters by adding another filter")
cy.contains("Add Filter").click();
cy.get('[data-testid="adv-search-add-filter-description"]').click({
force: true,
});
cy.get('[data-testid="edit-text-input"]').type("log event");
cy.get('[data-testid="edit-text-done-btn"]').click();
cy.clickOptionWithTestId('adv-search-add-filter-description');
cy.enterTextInTestId('edit-text-input', "log event");
cy.clickOptionWithTestId('edit-text-done-btn');

// Save View
cy.log("Save View")
cy.clickOptionWithTestId("view-builder-save");

cy.wait(2000); // Allow search to reload

cy.contains("cypress_logging_events");
cy.contains("of 1 result");

// Now set the View as the personal Default
cy.get('[data-testid="view-select"]').click();
cy.get('[data-testid="view-select-item"]').first().trigger('mouseover')
cy.get('[data-testid="views-table-dropdown"]').first().trigger('mouseover');
cy.get('[data-testid="view-dropdown-set-user-default"]').click();
cy.get("input[data-testid=search-input]").click(); // unfocus

// Now unset as the personal default
cy.get('[data-testid="view-select"]').click();
cy.get('[data-testid="view-select-item"]').first().trigger('mouseover')
cy.get('[data-testid="views-table-dropdown"]').first().trigger('mouseover');
cy.get('[data-testid="view-dropdown-remove-user-default"]').click();
cy.get("input[data-testid=search-input]").click(); // unfocus

// Now delete the View
cy.get('[data-testid="view-select"]').click();
cy.get('[data-testid="view-select-item"]').first().trigger('mouseover')
cy.get('[data-testid="views-table-dropdown"]').first().trigger('mouseover');
cy.get('[data-testid="view-dropdown-delete"]').click();

cy.log("Now set the View as the personal Default")
cy.clearView(viewName);
openViewEditDropDownAndClickId('view-dropdown-set-user-default');

cy.contains("of 1 result");
cy.clearView(newViewName);
cy.log("Now unset as the personal default")
openViewEditDropDownAndClickId('view-dropdown-remove-user-default');

cy.log("Now delete the View")
cy.clearView(newViewName);
openViewEditDropDownAndClickId('view-dropdown-delete');
cy.clickOptionWithText("Yes");

// Ensure that the view was deleted.
cy.ensureTextNotPresent(viewName);
cy.wait(2000); // Allow search to reload
cy.log("Ensure that the view was deleted.")
cy.goToViewsSettings();
cy.ensureTextNotPresent(newViewName);
cy.ensureTextNotPresent("of 1 result");

});
Expand Down
Loading

0 comments on commit 2fb0b1e

Please sign in to comment.