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

Cypress test for managing groups #8520

Merged
Show file tree
Hide file tree
Changes from all 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
116 changes: 116 additions & 0 deletions smoke-test/tests/cypress/cypress/e2e/settings/managing_groups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
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}`;

describe("create and manage group", () => {
it("add test user", () => {
cy.loginWithCredentials();
cy.visit("/settings/identities/users");
cy.waitTextVisible("Invite 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", username);
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(username);
})
});

it("create a group", () => {
cy.loginWithCredentials();
cy.visit("/settings/identities/groups")
cy.waitTextVisible("Create group");
cy.clickOptionWithText("Create group");
cy.waitTextVisible("Create new group");
cy.get("#name").type(group_name);
cy.get("#description").type("Test group description");
cy.contains("Advanced").click();
cy.waitTextVisible("Group Id");
cy.get("#groupId").type(test_id);
cy.get("#createGroupButton").click();
cy.waitTextVisible("Created group!");
cy.waitTextVisible(group_name);
});

it("add test user to a group", () => {
cy.loginWithCredentials();
cy.visit("/settings/identities/users");
cy.get(".ant-tabs-tab-btn").contains("Groups").click();
cy.clickOptionWithText(group_name);
cy.get(".ant-typography").contains(group_name).should("be.visible");
cy.get(".ant-tabs-tab").contains("Members").click();
cy.waitTextVisible("No members in this group yet.");
cy.clickOptionWithText("Add Member");
cy.contains("Search for users...").click({ force: true });
cy.focused().type(username);
cy.get(".ant-select-item-option").contains(username).click();
cy.focused().blur();
cy.contains(username).should("have.length", 1);
cy.get('[role="dialog"] button').contains("Add").click({ force: true });
cy.waitTextVisible("Group members added!");
cy.contains(username, {timeout: 10000}).should("be.visible");
});

it("update group info", () => {
cy.loginWithCredentials();
cy.visit("/settings/identities/groups");
cy.clickOptionWithText(group_name);
cy.contains(group_name).find('[aria-label="Edit"]').click();
cy.focused().clear().type(`Test group EDITED ${test_id}{enter}`);
cy.waitTextVisible("Name Updated");
cy.contains(`Test group EDITED ${test_id}`).should("be.visible");
cy.contains("Test group description").find('[aria-label="edit"]').click();
cy.focused().type(" EDITED{enter}");
cy.waitTextVisible("Changes saved.");
cy.contains("Test group description EDITED").should("be.visible");
cy.clickOptionWithText("Add Owners");
cy.contains("Search for users or groups...").click({ force: true });
cy.focused().type(Cypress.env('ADMIN_USERNAME'));
cy.get(".ant-select-item-option").contains(Cypress.env('ADMIN_USERNAME'), { matchCase: false }).click();
cy.focused().blur();
cy.contains(Cypress.env('ADMIN_USERNAME')).should("have.length", 1);
cy.get('[role="dialog"] button').contains("Done").click();
cy.waitTextVisible("Owners Added");
cy.contains(Cypress.env('ADMIN_USERNAME'), { matchCase: false }).should("be.visible");
cy.clickOptionWithText("Edit Group");
cy.waitTextVisible("Edit Profile");
cy.get("#email").type(`${test_id}@testemail.com`);
cy.get("#slack").type(`#${test_id}`);
cy.clickOptionWithText("Save Changes");
cy.waitTextVisible("Changes saved.");
cy.waitTextVisible(`${test_id}@testemail.com`);
cy.waitTextVisible(`#${test_id}`);
});

it("test user verify group participation", () => {
cy.loginWithCredentials(email,password);
cy.visit("/settings/identities/groups");
cy.hideOnboardingTour();
cy.clickOptionWithText(`Test group EDITED ${test_id}`);
cy.get(".ant-tabs-tab").contains("Members").click();
cy.waitTextVisible(username);
});

it("remove group", () => {
cy.loginWithCredentials();
cy.visit("/settings/identities/groups");
cy.get(`[href="/group/urn:li:corpGroup:${test_id}"]`).next().click();
cy.clickOptionWithText("Delete");
cy.clickOptionWithText("Yes");
cy.waitTextVisible("Deleted Group!");
cy.ensureTextNotPresent(`Test group EDITED ${test_id}`);
});

});
13 changes: 13 additions & 0 deletions smoke-test/tests/cypress/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ Cypress.Commands.add('login', () => {
});
})

Cypress.Commands.add("loginWithCredentials", (username, password) => {
cy.visit('/');
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice!!

if (username,password) {
cy.get('input[data-testid=username]').type(username);
cy.get('input[data-testid=password]').type(password);
} else {
cy.get('input[data-testid=username]').type(Cypress.env('ADMIN_USERNAME'));
cy.get('input[data-testid=password]').type(Cypress.env('ADMIN_PASSWORD'));
}
cy.contains('Sign In').click();
cy.contains('Welcome back');
});

Cypress.Commands.add('deleteUrn', (urn) => {
cy.request({ method: 'POST', url: 'http://localhost:8080/entities?action=delete', body: {
urn
Expand Down
Loading