Skip to content

Commit

Permalink
feat(build): refactor cypress tests, add some tests for invite users,…
Browse files Browse the repository at this point in the history
… domain creation (#6259)
  • Loading branch information
anshbansal authored Nov 3, 2022
1 parent 6011b03 commit 4d3c25b
Show file tree
Hide file tree
Showing 18 changed files with 256 additions and 106 deletions.
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
2 changes: 1 addition & 1 deletion datahub-web-react/src/app/identity/user/UserListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function UserListItem({ user, canManageUserCredentials, selectRol
const userStatusColor = userStatus && getUserStatusColor(userStatus);

return (
<List.Item>
<List.Item data-testid={user.urn}>
<UserItemContainer>
<Link to={entityRegistry.getEntityUrl(EntityType.CorpUser, user.urn)}>
<UserHeaderContainer>
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
51 changes: 31 additions & 20 deletions smoke-test/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,34 @@ def _ensure_dataset_present(
return res_data


@tenacity.retry(
stop=tenacity.stop_after_attempt(sleep_times), wait=tenacity.wait_fixed(sleep_sec)
)
def _ensure_group_not_present(
urn: str,
frontend_session
) -> Any:
json = {
"query": """query corpGroup($urn: String!) {\n
corpGroup(urn: $urn) {\n
urn\n
properties {\n
displayName\n
}\n
}\n
}""",
"variables": {"urn": urn},
}
response = frontend_session.post(f"{get_frontend_url()}/api/v2/graphql", json=json)
response.raise_for_status()
res_data = response.json()

assert res_data
assert res_data["data"]
assert res_data["data"]["corpGroup"]
assert res_data["data"]["corpGroup"]["properties"] is None


@pytest.mark.dependency(depends=["test_healthchecks"])
def test_ingestion_via_rest(wait_for_healthchecks):
ingest_file_via_rest(bootstrap_sample_data)
Expand Down Expand Up @@ -1042,35 +1070,18 @@ def test_remove_user(frontend_session):
]
)
def test_remove_group(frontend_session):
group_urn = "urn:li:corpGroup:bfoo"

json = {
"query": """mutation removeGroup($urn: String!) {\n
removeGroup(urn: $urn) }""",
"variables": {"urn": "urn:li:corpGroup:bfoo"},
"variables": {"urn": group_urn},
}

response = frontend_session.post(f"{get_frontend_url()}/api/v2/graphql", json=json)
response.raise_for_status()

json = {
"query": """query corpGroup($urn: String!) {\n
corpGroup(urn: $urn) {\n
urn\n
properties {\n
displayName\n
}\n
}\n
}""",
"variables": {"urn": "urn:li:corpGroup:bfoo"},
}
response = frontend_session.post(f"{get_frontend_url()}/api/v2/graphql", json=json)
response.raise_for_status()
res_data = response.json()

assert res_data
assert res_data["data"]
assert res_data["data"]["corpGroup"]
assert res_data["data"]["corpGroup"]["properties"] is None
_ensure_group_not_present(group_urn, frontend_session)


@pytest.mark.dependency(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
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.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.wait(1000);
cy.contains("Section Views across Entity Types").scrollIntoView({
ensureScrollable: false
})
cy.wait(1000);
cy.waitTextPresent("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 datasetName = "cypress_logging_events";
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, datasetName, glossaryTerm);

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

cy.goToDataset(urn);
cy.goToDataset(urn, datasetName);
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,59 +1,46 @@
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")
}

// 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");
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");
});

it("can view column level impact analysis and turn it off", () => {
Expand Down
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
// 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 datasetName = "cypress_logging_events";
cy.login();

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

cy.goToDataset(urn);
cy.goToDataset(urn, datasetName);
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
});
Loading

0 comments on commit 4d3c25b

Please sign in to comment.