Files
redash/client/cypress/integration/embed/share_embed_spec.js
Levko Kravets a682265e13 Migrate router and <app-view> to React (#4525)
* Migrate router and <app-view> to React: skeleton

* Update layout on route change

* Start moving page routes from angular to react

* Move page routes to react except of public dashboard and visualization embed)

* Move public dashboard and visualization embed routes to React

* Replace $route/$routeParams usages

* Some cleanup

* Replace AngularJS $location service with implementation based on history library

* Minor fix to how ApplicationView handles route change

* Explicitly use global layout for each page instead of handling related stuff in ApplicationArea component

* Error handling

* Remove AngularJS and related dependencies

* Move Parameter factory method to a separate file

* Fix CSS (replace custom components with classes)

* Fix: keep other url parts when updating location partially; refine code

* Fix tests

* Make router work in multi-org mode (respect <base> tag)

* Optimzation: don't resolve route if path didn't change

* Fix search input in header; error handling improvement (handle more errors in pages; global error handler for unhandled errors; dialog dismiss 'unhandled rejection' errors)

* Fix page keys; fix navigateTo calls (third parameter not available)

* Use relative links

* Router: ignore location REPLACE events, resolve only on PUSH/POP

* Fix tests

* Remove unused jQuery reference

* Show error from backend when creating Destination

* Remove route.resolve where not necessary (used constant values)

* New Query page: keep state on saving, reload when creating another new query

* Use currentRoute.key instead of hard-coded keys for page components

* Tidy up Router

* Tidy up location service

* Fix tests

* Don't add parameters changes to browser's history

* Fix test (improved fix)

Co-authored-by: Gabriel Dutra <nesk.frz@gmail.com>
2020-01-20 20:56:37 +02:00

96 lines
3.1 KiB
JavaScript

import { createQuery } from "../../support/redash-api";
describe("Embedded Queries", () => {
beforeEach(() => {
cy.login();
});
it("can be shared without parameters", () => {
createQuery({ query: "select name from users order by name" }).then(query => {
cy.visit(`/queries/${query.id}/source`);
cy.getByTestId("ExecuteButton").click();
cy.getByTestId("QueryPageVisualizationTabs", { timeout: 10000 }).should("exist");
cy.clickThrough(`
QueryControlDropdownButton
ShowEmbedDialogButton
`);
cy.getByTestId("EmbedIframe")
.invoke("text")
.then(embedUrl => {
cy.logout();
cy.visit(embedUrl);
cy.getByTestId("VisualizationEmbed", { timeout: 10000 }).should("exist");
cy.getByTestId("TimeAgo", { timeout: 10000 }).should("exist");
cy.getByTestId("TableVisualization").should("exist");
cy.percySnapshot("Successfully Embedded Non-Parameterized Query");
});
});
});
it("can be shared with safe parameters", () => {
cy.visit("/queries/new");
cy.getByTestId("QueryEditor")
.get(".ace_text-input")
.type("SELECT name, slug FROM organizations WHERE id='{{}{{}id}}'{esc}", { force: true });
cy.getByTestId("TextParamInput").type("1");
cy.getByTestId("ParameterApplyButton").click();
cy.clickThrough(`
ParameterSettings-id
ParameterTypeSelect
NumberParameterTypeOption
SaveParameterSettings
SaveButton
`);
// Add a little waiting - page is not updated fast enough
cy.wait(500); // eslint-disable-line cypress/no-unnecessary-waiting
cy.location("search").should("eq", "?p_id=1");
cy.clickThrough(`
QueryControlDropdownButton
ShowEmbedDialogButton
`);
cy.getByTestId("EmbedIframe")
.invoke("text")
.then(embedUrl => {
cy.logout();
cy.visit(embedUrl);
cy.getByTestId("VisualizationEmbed", { timeout: 10000 }).should("exist");
cy.getByTestId("TimeAgo", { timeout: 10000 }).should("exist");
cy.getByTestId("TableVisualization").should("exist");
cy.percySnapshot("Successfully Embedded Parameterized Query");
});
});
it("cannot be shared with unsafe parameters", () => {
cy.visit("/queries/new");
cy.getByTestId("QueryEditor")
.get(".ace_text-input")
.type("SELECT name, slug FROM organizations WHERE name='{{}{{}name}}'{esc}", { force: true });
cy.getByTestId("TextParamInput").type("Redash");
cy.getByTestId("ParameterApplyButton").click();
cy.clickThrough(`
ParameterSettings-name
ParameterTypeSelect
TextParameterTypeOption
SaveParameterSettings
SaveButton
`);
// Add a little waiting - page is not updated fast enough
cy.wait(500); // eslint-disable-line cypress/no-unnecessary-waiting
cy.location("search").should("eq", "?p_name=Redash");
cy.clickThrough(`
QueryControlDropdownButton
ShowEmbedDialogButton
`);
cy.getByTestId("EmbedIframe").should("not.exist");
cy.getByTestId("EmbedErrorAlert").should("exist");
});
});