diff --git a/smoke-test/tests/cypress/cypress/e2e/mutations/dataset_ownership.js b/smoke-test/tests/cypress/cypress/e2e/mutations/dataset_ownership.js new file mode 100644 index 0000000000000..fcc0566f3f6ce --- /dev/null +++ b/smoke-test/tests/cypress/cypress/e2e/mutations/dataset_ownership.js @@ -0,0 +1,64 @@ +const test_id = Math.floor(Math.random() * 100000); +const username = `Example Name ${test_id}`; +const email = `example${test_id}@example.com`; +const password = "Example password"; +const group_name = `Test group ${test_id}`; + +const addOwner = (owner, type, elementId) => { + cy.clickOptionWithText("Add Owners"); + cy.contains("Search for users or groups...").click({ force: true }); + cy.focused().type(owner); + cy.clickOptionWithText(owner); + cy.focused().blur(); + cy.waitTextVisible(owner); + cy.get('[role="dialog"]').contains("Technical Owner").click(); + cy.get('[role="listbox"]').parent().contains(type).click(); + cy.get('[role="dialog"]').contains(type).should("be.visible"); + cy.clickOptionWithText("Done"); + cy.waitTextVisible("Owners Added"); + cy.waitTextVisible(type); + cy.waitTextVisible(owner).wait(3000); + cy.clickOptionWithText(owner); + cy.waitTextVisible("SampleCypressHiveDataset"); + cy.goToDataset("urn:li:dataset:(urn:li:dataPlatform:hive,SampleCypressHiveDataset,PROD)", "SampleCypressHiveDataset"); + cy.get(elementId).next().click(); + cy.clickOptionWithText("Yes"); + cy.waitTextVisible("Owner Removed"); + cy.ensureTextNotPresent(owner); + cy.ensureTextNotPresent(type); +} + +describe("add, remove ownership for dataset", () => { + it("create test user and test group, add user to a group", () => { + cy.loginWithCredentials(); + cy.createUser(username, password, email); + cy.createGroup(group_name, "Test group description", test_id); + cy.addGroupMember(group_name, `/group/urn:li:corpGroup:${test_id}/assets`, username); + }); + + it("open test dataset page, add and remove user ownership(test every type)", () => { + cy.loginWithCredentials(); + cy.goToDataset("urn:li:dataset:(urn:li:dataPlatform:hive,SampleCypressHiveDataset,PROD)", "SampleCypressHiveDataset"); + //business owner + addOwner(username, "Business Owner", `[href="/user/urn:li:corpuser:example${test_id}@example.com"]`); + //data steward + addOwner(username, "Data Steward", `[href="/user/urn:li:corpuser:example${test_id}@example.com"]`); + //none + addOwner(username, "None", `[href="/user/urn:li:corpuser:example${test_id}@example.com"]`); + //technical owner + addOwner(username, "Technical Owner", `[href="/user/urn:li:corpuser:example${test_id}@example.com"]`); + }); + + it("open test dataset page, add and remove group ownership(test every type)", () => { + cy.loginWithCredentials(); + cy.goToDataset("urn:li:dataset:(urn:li:dataPlatform:hive,SampleCypressHiveDataset,PROD)", "SampleCypressHiveDataset"); + //business owner + addOwner(group_name, "Business Owner", `[href="/group/urn:li:corpGroup:${test_id}"]`); + //data steward + addOwner(group_name, "Data Steward", `[href="/group/urn:li:corpGroup:${test_id}"]`); + //none + addOwner(group_name, "None", `[href="/group/urn:li:corpGroup:${test_id}"]`); + //technical owner + addOwner(group_name, "Technical Owner", `[href="/group/urn:li:corpGroup:${test_id}"]`); + }); +}); \ No newline at end of file diff --git a/smoke-test/tests/cypress/cypress/support/commands.js b/smoke-test/tests/cypress/cypress/support/commands.js index 80c05079daa0a..8bfe7305c001f 100644 --- a/smoke-test/tests/cypress/cypress/support/commands.js +++ b/smoke-test/tests/cypress/cypress/support/commands.js @@ -271,6 +271,59 @@ Cypress.Commands.add("mouseover", (selector) => { ); }) +Cypress.Commands.add("createUser", (name, password, email) => { + cy.visit("/settings/identities/users"); + cy.clickOptionWithText("Invite Users"); + cy.waitTextVisible(/signup\?invite_token=\w{32}/).then(($elem) => { + const inviteLink = $elem.text(); + cy.visit("/settings/identities/users"); + cy.logout(); + cy.visit(inviteLink); + cy.enterTextInTestId("email", email); + cy.enterTextInTestId("name", name); + cy.enterTextInTestId("password", password); + cy.enterTextInTestId("confirmPassword", password); + cy.mouseover("#title").click(); + cy.waitTextVisible("Other").click(); + cy.get("[type=submit]").click(); + cy.waitTextVisible("Welcome to DataHub"); + cy.hideOnboardingTour(); + cy.waitTextVisible(name); + cy.logout() + cy.loginWithCredentials(); + }) +}) + +Cypress.Commands.add("createGroup", (name, description, group_id) => { + cy.visit("/settings/identities/groups") + cy.clickOptionWithText("Create group"); + cy.waitTextVisible("Create new group"); + cy.get("#name").type(name); + cy.get("#description").type(description); + cy.contains("Advanced").click(); + cy.waitTextVisible("Group Id"); + cy.get("#groupId").type(group_id); + cy.get("#createGroupButton").click(); + cy.waitTextVisible("Created group!"); + cy.waitTextVisible(name); +}) + +Cypress.Commands.add("addGroupMember", (group_name, group_urn, member_name) => { + cy.visit(group_urn) + cy.clickOptionWithText(group_name); + cy.contains(group_name).should("be.visible"); + cy.get('[role="tab"]').contains("Members").click(); + cy.clickOptionWithText("Add Member"); + cy.contains("Search for users...").click({ force: true }); + cy.focused().type(member_name); + cy.contains(member_name).click(); + cy.focused().blur(); + cy.contains(member_name).should("have.length", 1); + cy.get('[role="dialog"] button').contains("Add").click({ force: true }); + cy.waitTextVisible("Group members added!"); + cy.contains(member_name, {timeout: 10000}).should("be.visible"); +}) + // // // -- This is a child command --