mirror of
https://github.com/datahub-project/datahub.git
synced 2025-10-13 01:48:33 +00:00
test(policies): add cypress test for managing policies (#8554)
This commit is contained in:
parent
b8681a7129
commit
faa368c2be
@ -285,6 +285,7 @@ export default function PolicyActorForm({ policyType, actors, setActors }: Props
|
||||
users.
|
||||
</Typography.Paragraph>
|
||||
<Select
|
||||
data-testid="users"
|
||||
value={usersSelectValue}
|
||||
mode="multiple"
|
||||
filterOption={false}
|
||||
@ -306,6 +307,7 @@ export default function PolicyActorForm({ policyType, actors, setActors }: Props
|
||||
all groups.
|
||||
</Typography.Paragraph>
|
||||
<Select
|
||||
data-testid="groups"
|
||||
value={groupsSelectValue}
|
||||
mode="multiple"
|
||||
placeholder="Search for groups..."
|
||||
|
@ -374,6 +374,7 @@ export default function PolicyPrivilegeForm({
|
||||
<Form.Item label={<Typography.Text strong>Privileges</Typography.Text>}>
|
||||
<Typography.Paragraph>Select a set of privileges to permit.</Typography.Paragraph>
|
||||
<Select
|
||||
data-testid="privileges"
|
||||
value={privilegesSelectValue}
|
||||
mode="multiple"
|
||||
onSelect={(value: string) => onSelectPrivilege(value)}
|
||||
|
@ -42,15 +42,24 @@ export default function PolicyTypeForm({
|
||||
<Typography.Paragraph>A name for your new policy.</Typography.Paragraph>
|
||||
<Input
|
||||
placeholder="Your policy name"
|
||||
data-testid="policy-name"
|
||||
value={policyName}
|
||||
onChange={(event) => updatePolicyName(event.target.value)}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="policyType" label={<Typography.Text strong>Type</Typography.Text>}>
|
||||
<Typography.Paragraph>The type of policy you would like to create.</Typography.Paragraph>
|
||||
<Select defaultValue={policyType} onSelect={(value) => setPolicyType(value as PolicyType)}>
|
||||
<Select.Option value={PolicyType.Platform}>Platform</Select.Option>
|
||||
<Select.Option value={PolicyType.Metadata}>Metadata</Select.Option>
|
||||
<Select
|
||||
data-testid="policy-type"
|
||||
defaultValue={policyType}
|
||||
onSelect={(value) => setPolicyType(value as PolicyType)}
|
||||
>
|
||||
<Select.Option data-testid="platform" value={PolicyType.Platform}>
|
||||
Platform
|
||||
</Select.Option>
|
||||
<Select.Option data-testid="metadata" value={PolicyType.Metadata}>
|
||||
Metadata
|
||||
</Select.Option>
|
||||
</Select>
|
||||
<TypeDescriptionParagraph type="secondary">
|
||||
The <b>Platform</b> policy type allows you to assign top-level DataHub Platform privileges to users.
|
||||
@ -70,6 +79,7 @@ export default function PolicyTypeForm({
|
||||
<Typography.Paragraph>An optional description for your new policy.</Typography.Paragraph>
|
||||
<Input
|
||||
placeholder="Your policy description"
|
||||
data-testid="policy-description"
|
||||
value={policyDescription}
|
||||
onChange={(event) => setPolicyDescription(event.target.value)}
|
||||
/>
|
||||
|
@ -5,7 +5,7 @@ const test_domain_urn = `urn:li:domain:${test_domain_id}`
|
||||
|
||||
describe("add remove domain", () => {
|
||||
it("create domain", () => {
|
||||
cy.login();
|
||||
cy.loginWithCredentials();
|
||||
cy.goToDomainList();
|
||||
cy.clickOptionWithText("New Domain");
|
||||
cy.waitTextVisible("Create new Domain");
|
||||
@ -17,30 +17,22 @@ describe("add remove domain", () => {
|
||||
})
|
||||
|
||||
it("add entities to domain", () => {
|
||||
cy.login();
|
||||
cy.loginWithCredentials();
|
||||
cy.goToDomainList();
|
||||
cy.clickOptionWithText(test_domain);
|
||||
cy.waitTextVisible("Add assets")
|
||||
cy.clickOptionWithText("Add assets")
|
||||
cy.get(".ant-modal-content").within(() => {
|
||||
cy.get('[data-testid="search-input"]').click().invoke("val", "cypress_project.jaffle_shop.").type("customer")
|
||||
cy.contains("BigQuery")
|
||||
cy.contains("BigQuery", {timeout: 30000 })
|
||||
cy.get(".ant-checkbox-input").first().click()
|
||||
cy.get("#continueButton").click()
|
||||
})
|
||||
cy.waitTextVisible("Added assets to Domain!")
|
||||
})
|
||||
|
||||
it("search filter by domain", () => {
|
||||
cy.login();
|
||||
cy.goToStarSearchList()
|
||||
cy.waitTextVisible(test_domain)
|
||||
cy.get('[data-testid="facet-domains-' + test_domain_urn + '"]').click()
|
||||
cy.waitTextVisible("customers")
|
||||
})
|
||||
|
||||
it("remove entity from domain", () => {
|
||||
cy.login();
|
||||
cy.loginWithCredentials();
|
||||
cy.goToDomainList();
|
||||
cy.removeDomainFromDataset(
|
||||
"urn:li:dataset:(urn:li:dataPlatform:bigquery,cypress_project.jaffle_shop.customers,PROD)",
|
||||
@ -50,13 +42,12 @@ describe("add remove domain", () => {
|
||||
})
|
||||
|
||||
it("delete a domain and ensure dangling reference is deleted on entities", () => {
|
||||
cy.login();
|
||||
cy.loginWithCredentials();
|
||||
cy.goToDomainList();
|
||||
cy.get('[data-testid="dropdown-menu-' + test_domain_urn + '"]').click();
|
||||
cy.clickOptionWithText("Delete");
|
||||
cy.clickOptionWithText("Yes");
|
||||
cy.ensureTextNotPresent(test_domain)
|
||||
|
||||
cy.goToContainer("urn:li:container:348c96555971d3f5c1ffd7dd2e7446cb")
|
||||
cy.waitTextVisible("customers")
|
||||
cy.ensureTextNotPresent(test_domain)
|
||||
|
152
smoke-test/tests/cypress/cypress/e2e/settings/manage_policies.js
Normal file
152
smoke-test/tests/cypress/cypress/e2e/settings/manage_policies.js
Normal file
@ -0,0 +1,152 @@
|
||||
const test_id = Math.floor(Math.random() * 100000);
|
||||
const platform_policy_name = `Platform test policy ${test_id}`;
|
||||
const platform_policy_edited = `Platform test policy ${test_id} EDITED`;
|
||||
const metadata_policy_name = `Metadata test policy ${test_id}`;
|
||||
const metadata_policy_edited = `Metadata test policy ${test_id} EDITED`;
|
||||
|
||||
describe("create and manage platform and metadata policies", () => {
|
||||
|
||||
it("create platform policy", () => {
|
||||
cy.loginWithCredentials();
|
||||
cy.visit("/settings/permissions/policies");
|
||||
cy.waitTextVisible("Manage Permissions");
|
||||
cy.clickOptionWithText("Create new policy");
|
||||
cy.clickOptionWithTestId("policy-name")
|
||||
.focused()
|
||||
.type(platform_policy_name);
|
||||
cy.get('[data-testid="policy-type"] [title="Metadata"]').click();
|
||||
cy.clickOptionWithTestId("platform");
|
||||
cy.clickOptionWithTestId("policy-description")
|
||||
.focused()
|
||||
.type(`Platform policy description ${test_id}`);
|
||||
cy.get("#nextButton").click();
|
||||
cy.get('[data-testid="privileges"]').type("All");
|
||||
cy.clickOptionWithText("All Privileges").focused().blur();
|
||||
cy.get("#nextButton").click();
|
||||
cy.get('[data-testid="users"]').type("All");
|
||||
cy.get("[title='All Users']").click();
|
||||
cy.focused().blur();
|
||||
cy.get('[data-testid="groups"]').type("All");
|
||||
cy.get("[title='All Groups']").click();
|
||||
cy.focused().blur();
|
||||
cy.get("#saveButton").click();
|
||||
cy.waitTextVisible("Successfully saved policy.");
|
||||
cy.waitTextVisible(platform_policy_name);
|
||||
});
|
||||
|
||||
it("edit platform policy", () => {
|
||||
cy.loginWithCredentials();
|
||||
cy.visit("/settings/permissions/policies");
|
||||
cy.contains('tr', `${platform_policy_name}` )
|
||||
.contains('EDIT')
|
||||
.click();
|
||||
cy.clickOptionWithTestId("policy-name");
|
||||
cy.focused().clear().type(platform_policy_edited);
|
||||
cy.clickOptionWithTestId("policy-description");
|
||||
cy.focused().clear().type(`Platform policy description ${test_id} EDITED`);
|
||||
cy.get("#nextButton").click();
|
||||
cy.get("#nextButton").click();
|
||||
cy.get("#saveButton").click();
|
||||
cy.waitTextVisible("Successfully saved policy.");
|
||||
cy.waitTextVisible(platform_policy_edited);
|
||||
cy.waitTextVisible(`Platform policy description ${test_id} EDITED`);
|
||||
});
|
||||
|
||||
it("deactivate and activate platform policy", () => {
|
||||
cy.loginWithCredentials();
|
||||
cy.visit("/settings/permissions/policies");
|
||||
cy.contains('tr', `${platform_policy_edited}` )
|
||||
.contains('DEACTIVATE')
|
||||
.click();
|
||||
cy.waitTextVisible("Successfully deactivated policy.")
|
||||
cy.contains('tr', `${platform_policy_edited}` )
|
||||
.contains('INACTIVE')
|
||||
.should("be.visible");
|
||||
cy.contains('tr', `${platform_policy_edited}` )
|
||||
.contains('ACTIVATE')
|
||||
.click();
|
||||
cy.waitTextVisible("Successfully activated policy.")
|
||||
cy.contains('tr', `${platform_policy_edited}` )
|
||||
.contains('ACTIVE')
|
||||
.should("be.visible");
|
||||
cy.contains('tr', `${platform_policy_edited}` )
|
||||
.find("[data-icon='delete']")
|
||||
.click();
|
||||
cy.waitTextVisible(`Delete ${platform_policy_edited}`);
|
||||
cy.clickOptionWithText("Yes");
|
||||
cy.waitTextVisible("Successfully removed policy.");
|
||||
cy.ensureTextNotPresent(`${platform_policy_edited}`);
|
||||
|
||||
});
|
||||
|
||||
it("create metadata policy", () => {
|
||||
cy.loginWithCredentials();
|
||||
cy.visit("/settings/permissions/policies");
|
||||
cy.clickOptionWithText("Create new policy");
|
||||
cy.clickOptionWithTestId("policy-name")
|
||||
.focused()
|
||||
.type(metadata_policy_name);
|
||||
cy.get('[data-testid="policy-type"]').should('have.text', 'Metadata');
|
||||
cy.clickOptionWithTestId("policy-description")
|
||||
.focused()
|
||||
.type(`Metadata policy description ${test_id}`);
|
||||
cy.get("#nextButton").click();
|
||||
cy.get('[data-testid="privileges"]').type("All");
|
||||
cy.clickOptionWithText("All Privileges").focused().blur();
|
||||
cy.get("#nextButton").click();
|
||||
cy.get('[data-testid="users"]').type("All");
|
||||
cy.get("[title='All Users']").click();
|
||||
cy.focused().blur();
|
||||
cy.get('[data-testid="groups"]').type("All");
|
||||
cy.get("[title='All Groups']").click();
|
||||
cy.focused().blur();
|
||||
cy.get("#saveButton").click();
|
||||
cy.waitTextVisible("Successfully saved policy.");
|
||||
cy.waitTextVisible(metadata_policy_name);
|
||||
});
|
||||
|
||||
it("edit metadata policy", () => {
|
||||
cy.loginWithCredentials();
|
||||
cy.visit("/settings/permissions/policies");
|
||||
cy.contains('tr', `${metadata_policy_name}` )
|
||||
.contains('EDIT')
|
||||
.click();
|
||||
cy.clickOptionWithTestId("policy-name")
|
||||
cy.focused().clear().type(metadata_policy_edited);
|
||||
cy.clickOptionWithTestId("policy-description");
|
||||
cy.focused().clear().type(`Metadata policy description ${test_id} EDITED`);
|
||||
cy.get("#nextButton").click();
|
||||
cy.get("#nextButton").click();
|
||||
cy.get("#saveButton").click();
|
||||
cy.waitTextVisible("Successfully saved policy.");
|
||||
cy.waitTextVisible(metadata_policy_edited);
|
||||
cy.waitTextVisible(`Metadata policy description ${test_id} EDITED`);
|
||||
});
|
||||
|
||||
it("deactivate and activate metadata policy", () => {
|
||||
cy.loginWithCredentials();
|
||||
cy.visit("/settings/permissions/policies");
|
||||
cy.contains('tr', `${metadata_policy_edited}` )
|
||||
.contains('DEACTIVATE')
|
||||
.click();
|
||||
cy.waitTextVisible("Successfully deactivated policy.")
|
||||
cy.contains('tr', `${metadata_policy_edited}` )
|
||||
.contains('INACTIVE')
|
||||
.should("be.visible");
|
||||
cy.contains('tr', `${metadata_policy_edited}` )
|
||||
.contains('ACTIVATE')
|
||||
.click();
|
||||
cy.waitTextVisible("Successfully activated policy.")
|
||||
cy.contains('tr', `${metadata_policy_edited}` )
|
||||
.contains('ACTIVE')
|
||||
.should("be.visible");
|
||||
cy.contains('tr', `${metadata_policy_edited}` )
|
||||
.find("[data-icon='delete']")
|
||||
.click();
|
||||
cy.waitTextVisible(`Delete ${metadata_policy_edited}`);
|
||||
cy.clickOptionWithText("Yes");
|
||||
cy.waitTextVisible("Successfully removed policy.");
|
||||
cy.ensureTextNotPresent(`${metadata_policy_edited}`);
|
||||
});
|
||||
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user