Files
redash/client/cypress/integration/settings/settings_tabs_spec.js
Omer Lachish de052ff02b Cypress touch-ups (#5109)
* allow non-sequential IDs for DataSources in Cypress tests

* refactor redash-api to a set of Cypress commands

* support mounting Redash endpoints in Cypress routes

* fix some parameter specs by waiting for schema to load

* extract baseUrl from cypress.json

* Restyled by prettier (#5110)

Co-authored-by: Restyled.io <commits@restyled.io>

Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
Co-authored-by: Restyled.io <commits@restyled.io>
2020-08-19 21:00:06 +03:00

59 lines
1.6 KiB
JavaScript

describe("Settings Tabs", () => {
const regularUser = {
name: "Example User",
email: "user@redash.io",
password: "password",
};
const userTabs = ["Users", "Groups", "Query Snippets", "Account"];
const adminTabs = ["Data Sources", "Alert Destinations", "General"];
const expectSettingsTabsToBe = expectedTabs =>
cy.getByTestId("SettingsScreenItem").then($list => {
const listedPages = $list.toArray().map(el => el.text);
expect(listedPages).to.have.members(expectedTabs);
});
before(() => {
cy.login().then(() => cy.createUser(regularUser));
});
describe("For admin user", () => {
beforeEach(() => {
cy.logout();
cy.login();
cy.visit("/");
});
it("settings link should lead to Data Sources settings", () => {
cy.getByTestId("SettingsLink")
.should("exist")
.should("have.attr", "href", "data_sources");
});
it("all tabs should be available", () => {
cy.getByTestId("SettingsLink").click();
expectSettingsTabsToBe([...userTabs, ...adminTabs]);
});
});
describe("For regular user", () => {
beforeEach(() => {
cy.logout();
cy.login(regularUser.email, regularUser.password);
cy.visit("/");
});
it("settings link should lead to Users settings", () => {
cy.getByTestId("SettingsLink")
.should("exist")
.should("have.attr", "href", "users");
});
it("limited set of settings tabs should be available", () => {
cy.getByTestId("SettingsLink").click();
expectSettingsTabsToBe(userTabs);
});
});
});