Skip to content

Commit

Permalink
test(): Nested domains cypress test (#8879)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkorchak authored Oct 6, 2023
1 parent c0feceb commit b191abb
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 6 deletions.
5 changes: 4 additions & 1 deletion datahub-web-react/src/app/domain/CreateDomainModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ export default function CreateDomainModal({ onClose, onCreate }: Props) {
rules={[{ whitespace: true }, { min: 1, max: 500 }]}
hasFeedback
>
<Input.TextArea placeholder="A description for your domain" />
<Input.TextArea
placeholder="A description for your domain"
data-testid="create-domain-description"
/>
</FormItemNoMargin>
</FormItemWithMargin>
<Collapse ghost>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ export default function ManageDomainsPageV2() {
<OnboardingTour stepIds={[DOMAINS_INTRO_ID, DOMAINS_CREATE_DOMAIN_ID]} />
<Header>
<DomainsTitle />
<Button type="primary" id={DOMAINS_CREATE_DOMAIN_ID} onClick={() => setIsCreatingDomain(true)}>
<Button
type="primary"
id={DOMAINS_CREATE_DOMAIN_ID}
onClick={() => setIsCreatingDomain(true)}
data-testid="domains-new-domain-button"
>
<PlusOutlined /> New Domain
</Button>
</Header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default function DomainNode({ domain, numDomainChildren, domainUrnToHide,

return (
<>
<RowWrapper>
<RowWrapper data-testid="domain-list-item">
{hasDomainChildren && (
<ButtonWrapper>
<RotatingTriangle isOpen={isOpen && !isClosing} onClick={toggle} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function EntityDropdown(props: Props) {
disabled={isMoveDisabled(entityType, entityData, me.platformPrivileges)}
onClick={() => setIsMoveModalVisible(true)}
>
<MenuItem>
<MenuItem data-testid="entity-menu-move-button">
<FolderOpenOutlined /> &nbsp;Move
</MenuItem>
</StyledMenuItem>
Expand All @@ -223,7 +223,7 @@ function EntityDropdown(props: Props) {
: undefined
}
>
<MenuItem>
<MenuItem data-testid="entity-menu-delete-button">
<DeleteOutlined /> &nbsp;Delete
</MenuItem>
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ function MoveDomainModal(props: Props) {
return (
<Modal
title="Move"
data-testid="move-domain-modal"
visible
onCancel={onClose}
footer={
<>
<Button onClick={onClose} type="text">
Cancel
</Button>
<Button onClick={moveDomain}>Move</Button>
<Button onClick={moveDomain} data-testid="move-domain-modal-move-button">
Move
</Button>
</>
}
>
Expand Down
53 changes: 53 additions & 0 deletions smoke-test/tests/cypress/cypress/e2e/domains/nested_domains.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const domainName = "CypressNestedDomain";
const domainDescription = "CypressNestedDomainDescription";

describe("nested domains test", () => {

it("create a domain, move under parent, remove domain", () => {
// Create a new domain without a parent
cy.loginWithCredentials();
cy.goToDomainList();
cy.clickOptionWithTestId("domains-new-domain-button");
cy.get('[data-testid="create-domain-name"]').click().type(domainName);
cy.get('[data-testid="create-domain-description"]').click().type(domainDescription);
cy.clickOptionWithTestId("create-domain-button");
cy.waitTextVisible(domainName);

// Ensure the new domain has no parent in the navigation sidebar
cy.waitTextVisible(domainDescription);

// Move a domain from the root level to be under a parent domain
cy.clickOptionWithText(domainName);
cy.openThreeDotDropdown();
cy.clickOptionWithTestId("entity-menu-move-button");
cy.get('[data-testid="move-domain-modal"]').contains("Marketing").click({force: true});
cy.get('[data-testid="move-domain-modal"]').contains("Marketing").should("be.visible");
cy.clickOptionWithTestId("move-domain-modal-move-button").wait(5000);

// Wnsure domain is no longer on the sidebar navigator at the top level but shows up under the parent
cy.goToDomainList();
cy.ensureTextNotPresent(domainName);
cy.ensureTextNotPresent(domainDescription);
cy.waitTextVisible("1 sub-domain");

// Move a domain from under a parent domain to the root level
cy.get('[data-testid="domain-list-item"]').contains("Marketing").prev().click();
cy.clickOptionWithText(domainName);
cy.openThreeDotDropdown();
cy.clickOptionWithTestId("entity-menu-move-button");
cy.clickOptionWithTestId("move-domain-modal-move-button").wait(5000);
cy.goToDomainList();
cy.waitTextVisible(domainName);
cy.waitTextVisible(domainDescription);

// Delete a domain
cy.clickOptionWithText(domainName).wait(3000);
cy.openThreeDotDropdown();
cy.clickOptionWithTestId("entity-menu-delete-button");
cy.waitTextVisible("Are you sure you want to remove this Domain?");
cy.clickOptionWithText("Yes");
cy.waitTextVisible("Deleted Domain!");
cy.ensureTextNotPresent(domainName);
cy.ensureTextNotPresent(domainDescription);
});
});

0 comments on commit b191abb

Please sign in to comment.