Skip to content
Snippets Groups Projects
Unverified Commit 37c745d3 authored by Jessica DeWitt's avatar Jessica DeWitt Committed by GitHub
Browse files

Repro/filter without permissions (#12852)

* cypress tests so filter works for nodata user

* prettier

* sub in withSampleDataset

* Change Order to Products

* prettier and more with products
parent 63fd1a7f
No related merge requests found
import { signInAsAdmin, restore, openOrdersTable } from "__support__/cypress";
import {
signInAsAdmin,
restore,
openOrdersTable,
popover,
signIn,
withSampleDataset,
} from "__support__/cypress";
function filterByVendor() {
cy.findAllByText("VENDOR")
.first()
.click();
popover().within(() => {
cy.findByPlaceholderText("Search by Vendor").type("b");
cy.findByText("Balistreri-Muller").click();
cy.findByText("Add filter").click();
});
cy.get(".RunButton")
.first()
.click();
}
function filterByCategory() {
cy.findAllByText("CATEGORY")
.first()
.click();
popover().within(() => {
cy.findByText("Widget").click();
cy.findByText("Add filter").click();
});
cy.get(".RunButton")
.last()
.click();
}
describe("scenarios > question > view", () => {
before(restore);
......@@ -81,4 +114,121 @@ describe("scenarios > question > view", () => {
cy.contains("Showing 91 rows");
});
});
describe("apply filters without data permissions", () => {
before(() => {
// All users upgraded to collection view access
signInAsAdmin();
cy.visit("/admin/permissions/collections");
cy.get(".Icon-close")
.first()
.click();
cy.findByText("View collection").click();
cy.findByText("Save Changes").click();
cy.findByText("Yes").click();
// Native query saved in dasbhoard
cy.request("POST", "/api/dashboard", {
name: "Dashboard",
});
withSampleDataset(({ PRODUCTS }) => {
cy.request("POST", "/api/card", {
name: "Question",
dataset_query: {
type: "native",
native: {
query: "select * from products where {{category}} and {{vendor}}",
"template-tags": {
category: {
id: "6b8b10ef-0104-1047-1e5v-2492d5954555",
name: "category",
"display-name": "CATEGORY",
type: "dimension",
dimension: ["field-id", PRODUCTS.CATEGORY],
"widget-type": "id",
},
vendor: {
id: "6b8b10ef-0104-1047-1e5v-2492d5964545",
name: "vendor",
"display-name": "VENDOR",
type: "dimension",
dimension: ["field-id", PRODUCTS.VENDOR],
"widget-type": "id",
},
},
},
database: 1,
},
display: "table",
visualization_settings: {},
});
cy.request("POST", "/api/dashboard/2/cards", {
id: 2,
cardId: 4,
});
});
});
it("should give everyone view permissions", () => {});
it("should show filters by list for Category", () => {
cy.visit("/question/4");
cy.findAllByText("CATEGORY")
.first()
.click();
popover().within(() => {
cy.findByPlaceholderText("Search the list");
cy.findByPlaceholderText("Search by Category").should("not.exist");
});
});
it("should show filters by search for Vendor", () => {
cy.visit("/question/4");
cy.findAllByText("VENDOR")
.first()
.click();
popover().within(() => {
cy.findByPlaceholderText("Search by Vendor");
cy.findByText("Search the list").should("not.exist");
});
});
it.skip("should be able to filter Q by Category as no data user (from Q link)", () => {
// *** Test will fail until Issue #12654 is resolved
signIn("nodata");
cy.visit("/question/4");
// Filter by category and vendor
filterByCategory();
filterByVendor();
cy.findAllByText("Widget");
cy.findByText("Gizmo").should("not.exist");
});
it.skip("should be able to filter Q by Vendor as user (from Dashboard)", () => {
// *** Test will fail until Issue #12654 is resolved
// Navigate to Q from Dashboard
signIn("nodata");
cy.visit("/dashboard/2");
cy.findByText("Question").click();
// Filter by category and vendor
filterByCategory();
filterByVendor();
cy.get(".TableInteractive-cellWrapper--firstColumn").should(
"have.length",
2,
);
cy.get(".CardVisualization").within(() => {
cy.findByText("Widget");
cy.findByText("Balistreri-Muller");
cy.findByText("Gizmo").should("not.exist");
cy.findByText("McClure-Lockman").should("not.exist");
});
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment