mirror of
https://github.com/getredash/redash.git
synced 2025-12-19 17:37:19 -05:00
* 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>
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
/* global cy */
|
|
|
|
const { get } = Cypress._;
|
|
const RESIZE_HANDLE_SELECTOR = ".react-resizable-handle";
|
|
|
|
export function getWidgetTestId(widget) {
|
|
return `WidgetId${widget.id}`;
|
|
}
|
|
|
|
export function createQueryAndAddWidget(dashboardId, queryData = {}, widgetOptions = {}) {
|
|
return cy
|
|
.createQuery(queryData)
|
|
.then(query => {
|
|
const visualizationId = get(query, "visualizations.0.id");
|
|
assert.isDefined(visualizationId, "Query api call returns at least one visualization with id");
|
|
return cy.addWidget(dashboardId, visualizationId, widgetOptions);
|
|
})
|
|
.then(getWidgetTestId);
|
|
}
|
|
|
|
export function editDashboard() {
|
|
cy.getByTestId("DashboardMoreButton").click();
|
|
|
|
cy.getByTestId("DashboardMoreButtonMenu")
|
|
.contains("Edit")
|
|
.click();
|
|
}
|
|
|
|
export function shareDashboard() {
|
|
cy.clickThrough(
|
|
{ button: "Publish" },
|
|
`OpenShareForm
|
|
PublicAccessEnabled`
|
|
);
|
|
|
|
return cy.getByTestId("SecretAddress").invoke("val");
|
|
}
|
|
|
|
export function resizeBy(wrapper, offsetLeft = 0, offsetTop = 0) {
|
|
return wrapper.within(() => {
|
|
cy.get(RESIZE_HANDLE_SELECTOR).dragBy(offsetLeft, offsetTop, true);
|
|
});
|
|
}
|