Skip to content
Snippets Groups Projects
Unverified Commit 593f8a36 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

Personal collections testing (with repro for #15343) (#15344)

* Add initial batch of tests for personal collections

* Add repro for #15343
parent 98b5cb7a
No related branches found
No related tags found
No related merge requests found
import { restore, popover, modal } from "__support__/cypress";
import { USERS } from "__support__/cypress_data";
describe("personal collections", () => {
beforeEach(() => {
restore();
cy.server();
});
describe("admin", () => {
beforeEach(() => {
cy.signInAsAdmin();
// Turn normal user into another admin
cy.request("PUT", "/api/user/2", {
is_superuser: true,
});
});
it("should be able to view their own as well as other users' personal collections (including other admins)", () => {
cy.visit("/collection/root");
cy.findByText("Your personal collection");
cy.findByText("Other users' personal collections").click();
cy.location("pathname").should("eq", "/collection/users");
cy.findByText(/All personal collections/i);
Object.values(USERS).forEach(user => {
const FULL_NAME = `${user.first_name} ${user.last_name}`;
cy.findByText(FULL_NAME);
});
});
it("shouldn't be able to change permission levels on or edit personal collections", () => {
cy.visit("/collection/root");
cy.findByText("Your personal collection").click();
cy.icon("lock").should("not.exist");
cy.icon("pencil").should("not.exist");
// Visit random user's personal collection
cy.visit("/collection/5");
cy.icon("lock").should("not.exist");
cy.icon("pencil").should("not.exist");
});
});
describe("all users", () => {
Object.keys(USERS).forEach(user => {
describe(`${user} user`, () => {
beforeEach(() => {
cy.signIn(user);
cy.visit("/collection/root");
cy.findByText("Your personal collection").click();
// Create initial collection inside the personal collection and navigate inside it
addNewCollection("Foo");
cy.get("[class*=CollectionSidebar]")
.as("sidebar")
.findByText("Foo")
.click();
});
it("should be able to edit collection(s) inside personal collection", () => {
// Create new collection inside previously added collection
addNewCollection("Bar");
cy.get("@sidebar")
.findByText("Bar")
.click();
cy.icon("pencil").click();
/**
* We're testing a few things here:
* 1. editing collection's title
* 2. editing collection's description and
* 3. moving that collection within personal collection
*/
cy.findByText("Edit this collection").click();
modal().within(() => {
cy.findByLabelText("Name") /* [1] */
.click()
.type("1");
cy.findByLabelText("Description") /* [2] */
.click()
.type("ex-bar");
cy.get(".AdminSelect").click();
});
popover()
.findByText("My personal collection") /* [3] */
.click();
cy.findByRole("button", { name: "Update" }).click();
// Clicking on "Foo" would've closed it and would hide its sub-collections (if there were any).
// By doing this, we're making sure "Bar" lives at the same level as "Foo"
cy.get("@sidebar")
.findByText("Foo")
.click();
cy.get("@sidebar").findByText("Bar1");
});
it.skip("should be able to archive collection(s) inside personal collection (metabase#15343)", () => {
cy.icon("pencil").click();
cy.findByText("Archive this collection").click();
modal()
.findByRole("button", { name: "Archive" })
.click();
cy.findByText("Archived collection");
cy.get("@sidebar")
.findByText("Foo")
.should("not.exist");
});
});
});
});
});
function addNewCollection(name) {
cy.icon("new_folder").click();
cy.findByLabelText("Name").type(name);
cy.findByText("Create").click();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment