Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(build): refactor cypress tests, add some tests for invite users, domain creation #6259

Merged
merged 10 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datahub-web-react/src/app/domain/DomainListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function DomainListItem({ domain, onDelete }: Props) {
const totalEntitiesText = getElasticCappedTotalValueText(domain.entities?.total || 0);

return (
<List.Item>
<List.Item data-testid={domain.urn}>
<DomainItemContainer>
<DomainStartContainer>
<Link to={entityRegistry.getEntityUrl(EntityType.Domain, domain.urn)}>
Expand Down
3 changes: 3 additions & 0 deletions smoke-test/smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ source venv/bin/activate
pip install --upgrade pip wheel setuptools
pip install -r requirements.txt

mkdir -p ~/.datahub/plugins/frontend/auth/
echo "test_user:test_pass" >> ~/.datahub/plugins/frontend/auth/user.props

echo "DATAHUB_VERSION = $DATAHUB_VERSION"
DATAHUB_TELEMETRY_ENABLED=false datahub docker quickstart --standalone_consumers --dump-logs-on-failure

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
describe('analytics', () => {
it('can go to a dataset and see analytics in Section Views', () => {
it('can go to a chart and see analytics in Section Views', () => {
cy.login();

cy.visit("/analytics");
cy.contains("documentation").should('not.exist');
cy.goToAnalytics();
cy.ensureTextNotPresent("dashboards");

cy.visit("/chart/urn:li:chart:(looker,baz1)");
cy.get("#rc-tabs-0-panel-Dashboards").click({ force: true });
cy.goToChart("urn:li:chart:(looker,cypress_baz1)");
cy.waitTextVisible("Baz Chart 1");
cy.openEntityTab("Dashboards");

cy.visit("/analytics");
cy.contains("documentation");
cy.goToAnalytics();
cy.waitTextVisible("dashboards");
});
})
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
describe("containers", () => {
it("can see elements inside the container", () => {
cy.login();
cy.visit(
"http://localhost:9002/container/urn:li:container:348c96555971d3f5c1ffd7dd2e7446cb"
);
cy.goToContainer("urn:li:container:348c96555971d3f5c1ffd7dd2e7446cb");

cy.contains("jaffle_shop");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
describe("domains", () => {
it("can see elements inside the domain", () => {
cy.login();
cy.visit(
"http://localhost:9002/domain/urn:li:domain:marketing/Entities?is_lineage_mode=false"
);
cy.goToDomain("urn:li:domain:marketing");

cy.contains("Marketing");
cy.contains("SampleCypressKafkaDataset");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@ describe("glossary", () => {
it("go to glossary page, create terms, term group", () => {

const urn = "urn:li:dataset:(urn:li:dataPlatform:hive,cypress_logging_events,PROD)";
const dataset_name = "cypress_logging_events";
anshbansal marked this conversation as resolved.
Show resolved Hide resolved
const glossaryTerm = "CypressGlosssaryTerm";
const glossaryTermGroup = "CypressGlosssaryGroup";
cy.login();
cy.goToGlossaryList();

cy.clickOptionWithText("Add Term");
cy.addViaModel(glossaryTerm);
cy.addViaModel(glossaryTerm, "Create Glossary Term");

cy.contains("Add Term Group").click();
cy.addViaModel(glossaryTermGroup);
cy.clickOptionWithText("Add Term Group");
cy.addViaModel(glossaryTermGroup, "Create Term Group");

cy.addTermToDataset(urn, glossaryTerm);
cy.addTermToDataset(urn, dataset_name, glossaryTerm);

cy.goToGlossaryList();
cy.clickOptionWithText(glossaryTerm);
cy.deleteFromDropdown();

cy.goToDataset(urn);
cy.goToDataset(urn, dataset_name);
cy.ensureTextNotPresent(glossaryTerm);

cy.goToGlossaryList();
Expand Down
1 change: 0 additions & 1 deletion smoke-test/tests/cypress/cypress/integration/home/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ describe('home', () => {
it('home page shows ', () => {
cy.login();
cy.visit('/');
cy.wait(5000);
cy.get('img[src="/assets/platforms/datahublogo.png"]').should('exist');
cy.get('[data-testid="entity-type-browse-card-DATASET"]').should('exist');
cy.get('[data-testid="entity-type-browse-card-DASHBOARD"]').should('exist');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,45 @@
describe("impact analysis", () => {
it("can see 1 hop of lineage by default", () => {
const startAtDataSetLineage = () => {
cy.login();
cy.visit(
"/dataset/urn:li:dataset:(urn:li:dataPlatform:kafka,SampleCypressKafkaDataset,PROD)/Lineage?is_lineage_mode=false"
cy.goToDataset(
"urn:li:dataset:(urn:li:dataPlatform:kafka,SampleCypressKafkaDataset,PROD)",
"SampleCypressKafkaDataset"
);
cy.openEntityTab("Lineage")
anshbansal marked this conversation as resolved.
Show resolved Hide resolved
}

// impact analysis can take a beat- don't want to time out here
cy.wait(5000);
describe("impact analysis", () => {
it("can see 1 hop of lineage by default", () => {
startAtDataSetLineage()

cy.contains("User Creations").should("not.exist");
cy.contains("User Deletions").should("not.exist");
cy.ensureTextNotPresent("User Creations");
anshbansal marked this conversation as resolved.
Show resolved Hide resolved
cy.ensureTextNotPresent("User Deletions");
});

it("can see lineage multiple hops away", () => {
cy.login();
cy.visit(
"/dataset/urn:li:dataset:(urn:li:dataPlatform:kafka,SampleCypressKafkaDataset,PROD)/Lineage?is_lineage_mode=false"
);
startAtDataSetLineage()
// click to show more relationships now that we default to 1 degree of dependency
cy.contains("3+").click({ force: true });

// impact analysis can take a beat- don't want to time out here
cy.wait(5000);
cy.clickOptionWithText("3+");

cy.contains("User Creations");
cy.contains("User Deletions");
});

it("can filter the lineage results as well", () => {
cy.login();
cy.visit(
"/dataset/urn:li:dataset:(urn:li:dataPlatform:kafka,SampleCypressKafkaDataset,PROD)/Lineage?is_lineage_mode=false"
);
startAtDataSetLineage()
// click to show more relationships now that we default to 1 degree of dependency
cy.contains("3+").click({ force: true });
cy.clickOptionWithText("3+");

cy.wait(5000);
cy.clickOptionWithText("Advanced");

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

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

// impact analysis can take a beat- don't want to time out here
cy.wait(5000);

cy.get('[data-testid="adv-search-add-filter-description"]').click({
force: true,
});
cy.clickOptionWithTestId('adv-search-add-filter-description');

cy.get('[data-testid="edit-text-input"]').type("fct_users_deleted");

cy.get('[data-testid="edit-text-done-btn"]').click({ force: true });
cy.clickOptionWithTestId('edit-text-done-btn');

cy.contains("User Creations").should("not.exist");
cy.contains("User Deletions");
cy.ensureTextNotPresent("User Creations");
cy.waitTextVisible("User Deletions");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const tryToSignUp = () => {
cy.enterTextInTestId("email", "[email protected]")
cy.enterTextInTestId("name", "Example Name")
cy.enterTextInTestId("password", "Example password")
cy.enterTextInTestId("confirmPassword", "Example password")

cy.mouseover("#title").click()
cy.waitTextVisible("Other").click()

cy.get("[type=submit]").click()
};

describe("add_user", () => {
it("go to user link and invite a user", () => {
cy.login()

cy.visit("/settings/identities/users");
cy.waitTextVisible("Invite Users");

cy.clickOptionWithText("Invite Users")

cy.waitTextVisible('signup?invite_token').then(($elem) => {
const inviteLink = $elem.text();
cy.logout();
cy.visit(inviteLink);
tryToSignUp();
cy.waitTextVisible("Accepted invite!")
}).then(() => {
cy.logout();
cy.visit("/signup?invite_token=bad_token");
tryToSignUp()
cy.waitTextVisible("Failed to log in! An unexpected error occurred.")
});
});
});

// Verify you can’t generate a reset password link for a non-native user (root, for example)
// Generate a reset password link for a native user
// Log out, then verify that using a bad reset token in the URL doesn’t allow you to reset password
Comment on lines +37 to +39
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets move this comment to above the method its describing

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are todos. I'll automate these this week.

// Use the correct reset link to reset native user credentials
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
describe("deprecation", () => {
it("go to dataset and check deprecation works", () => {
const urn = "urn:li:dataset:(urn:li:dataPlatform:hive,cypress_logging_events,PROD)";
const dataset_name = "cypress_logging_events";
anshbansal marked this conversation as resolved.
Show resolved Hide resolved
cy.login();

cy.goToDataset(urn);
cy.goToDataset(urn, dataset_name);
cy.openThreeDotDropdown();
cy.clickOptionWithText("Mark as deprecated");
cy.addViaModel("test deprecation");
cy.addViaModel("test deprecation", "Add Deprecation Details");

cy.goToDataset(urn);
cy.goToDataset(urn, dataset_name);
cy.contains("Deprecated");

cy.openThreeDotDropdown();
Expand Down
25 changes: 25 additions & 0 deletions smoke-test/tests/cypress/cypress/integration/mutations/domains.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const test_domain = "CypressDomainTest";

describe("add remove domain", () => {
it("create domain", () => {
cy.login();
cy.goToDomainList();
cy.clickOptionWithText("New Domain");
cy.addViaModel(test_domain, "Create new Domain")
cy.waitTextVisible("Created domain!")

cy.waitTextVisible(test_domain)

cy.waitTextVisible(test_domain)
.parents("[data-testid^='urn:li:domain:']")
.invoke('attr', 'data-testid')
.then((data_test_id) => {
cy.log(data_test_id)
})
})

// add asset to domain
// Search filter by domain
// Remove entity from domain
// Delete a domain - ensure that the dangling reference is deleted on the asset
Comment on lines +21 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if these are to-do's lets mark them as todos?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are todos. I'll automate these this week.

});
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ describe("mutations", () => {
before(() => {
// warm up elastic by issuing a `*` search
cy.login();
cy.visit("http://localhost:9002/search?query=%2A");
anshbansal marked this conversation as resolved.
Show resolved Hide resolved
cy.visit("/search?query=%2A");
cy.wait(5000);
});

it("can create and add a tag to dataset and visit new tag page", () => {
cy.deleteUrn("urn:li:tag:CypressTestAddTag");
cy.login();
cy.goToDataset("urn:li:dataset:(urn:li:dataPlatform:hive,cypress_logging_events,PROD)");
cy.contains("cypress_logging_events");
cy.goToDataset("urn:li:dataset:(urn:li:dataPlatform:hive,cypress_logging_events,PROD)", "cypress_logging_events");

cy.contains("Add Tag").click({ force: true });

Expand Down Expand Up @@ -62,6 +61,7 @@ describe("mutations", () => {
cy.login();
cy.addTermToDataset(
"urn:li:dataset:(urn:li:dataPlatform:hive,cypress_logging_events,PROD)",
"cypress_logging_events",
"CypressTerm"
)

Expand All @@ -76,11 +76,8 @@ describe("mutations", () => {
it("can add and remove tags from a dataset field", () => {
cy.login();
cy.viewport(2000, 800);
cy.goToDataset("urn:li:dataset:(urn:li:dataPlatform:hive,cypress_logging_events,PROD)");
cy.get('[data-testid="schema-field-event_name-tags"]').trigger(
"mouseover",
{ force: true }
);
cy.goToDataset("urn:li:dataset:(urn:li:dataPlatform:hive,cypress_logging_events,PROD)", "cypress_logging_events");
cy.mouseover('[data-testid="schema-field-event_name-tags"]');
cy.get('[data-testid="schema-field-event_name-tags"]').within(() =>
cy.contains("Add Tag").click()
);
Expand Down Expand Up @@ -136,7 +133,7 @@ describe("mutations", () => {
cy.login();
// make space for the glossary term column
cy.viewport(2000, 800);
cy.goToDataset("urn:li:dataset:(urn:li:dataPlatform:hive,cypress_logging_events,PROD)");
cy.goToDataset("urn:li:dataset:(urn:li:dataPlatform:hive,cypress_logging_events,PROD)", "cypress_logging_events");
cy.get('[data-testid="schema-field-event_name-terms"]').trigger(
"mouseover",
{ force: true }
Expand Down
Loading