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

#14052 Repro: Cannot save to sub-collection when access to its parent is revoked [ci skip] (#14619)


* Make a common `describe` block for the related issues

* Use `signIn()` function

* Assert that the "Parent" collection is not visible

* Update repro for #14114 with the negative assertion

Co-authored-by: default avatarflamber <1447303+flamber@users.noreply.github.com>
parent eb1a318e
Branches
Tags
No related merge requests found
......@@ -3,11 +3,13 @@ import {
signInAsAdmin,
setupLocalHostEmail,
signInAsNormalUser,
signIn,
signOut,
modal,
popover,
USERS,
USER_GROUPS,
openOrdersTable,
} from "__support__/cypress";
// Ported from initial_collection.e2e.spec.js
......@@ -292,46 +294,69 @@ describe("scenarios > collection_defaults", () => {
signInAsAdmin();
});
it("should see a child collection in a sidebar even with revoked access to its parent (metabase#14114)", () => {
// Create Parent collection within `Our analytics`
cy.request("POST", "/api/collection", {
name: "Parent",
color: "#509EE3",
parent_id: null,
}).then(({ body: { id: PARENT_COLLECTION_ID } }) => {
// Create Child collection within Parent collection
describe("nested collections with revoked parent access", () => {
beforeEach(() => {
// Create Parent collection within `Our analytics`
cy.request("POST", "/api/collection", {
name: "Child",
name: "Parent",
color: "#509EE3",
parent_id: PARENT_COLLECTION_ID,
}).then(({ body: { id: CHILD_COLLECTION_ID } }) => {
// Fetch collection permission graph
cy.request("GET", "/api/collection/graph").then(
({ body: { groups, revision } }) => {
// Give `Data` group permission to "curate" Child collection only
// Access to everything else is revoked by default - that's why we chose `Data` group
groups[DATA_GROUP][CHILD_COLLECTION_ID] = "write";
// We're chaining these 2 requestes in order to match shema (passing it from GET to PUT)
// Similar to what we did in `sandboxes.cy.spec.js` with the permission graph
cy.request("PUT", "/api/collection/graph", {
// Pass previously mutated `groups` object
groups,
revision,
});
},
);
parent_id: null,
}).then(({ body: { id: PARENT_COLLECTION_ID } }) => {
// Create Child collection within Parent collection
cy.request("POST", "/api/collection", {
name: "Child",
color: "#509EE3",
parent_id: PARENT_COLLECTION_ID,
}).then(({ body: { id: CHILD_COLLECTION_ID } }) => {
// Fetch collection permission graph
cy.request("GET", "/api/collection/graph").then(
({ body: { groups, revision } }) => {
// Give `Data` group permission to "curate" Child collection only
// Access to everything else is revoked by default - that's why we chose `Data` group
groups[DATA_GROUP][CHILD_COLLECTION_ID] = "write";
// We're chaining these 2 requestes in order to match shema (passing it from GET to PUT)
// Similar to what we did in `sandboxes.cy.spec.js` with the permission graph
cy.request("PUT", "/api/collection/graph", {
// Pass previously mutated `groups` object
groups,
revision,
});
},
);
});
});
signOut();
signIn("nocollection");
});
signOut();
cy.log("**--Sign in as `nocollection` user--**");
cy.request("POST", "/api/session", nocollection);
it("should see a child collection in a sidebar even with revoked access to its parent (metabase#14114)", () => {
cy.visit("/");
cy.findByText("Child");
cy.findByText("Parent").should("not.exist");
cy.findByText("Browse all items").click();
cy.findByText("Child");
cy.findByText("Parent").should("not.exist");
});
cy.visit("/");
cy.findByText("Child");
cy.findByText("Browse all items").click();
cy.findByText("Child");
it.skip("should be able to choose a child collection when saving a question (metabase#14052)", () => {
const { first_name, last_name } = nocollection;
openOrdersTable();
cy.findByText("Save").click();
// Click to choose which collection should this question be saved to
cy.findByText(
`${first_name} ${last_name}'s Personal Collection`,
).click();
popover().within(() => {
cy.findByText(/Our analytics/i);
cy.findByText(/My personal collection/i);
cy.findByText("Parent").should("not.exist");
cy.log("**Reported failing from v0.34.3**");
cy.findByText("Child");
});
});
});
it.skip("sub-collection should be available in save and move modals (#14122)", () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment