forked from tsai/budibase
41 changed files with 705 additions and 319 deletions
@ -1,43 +1,45 @@ |
|||||
import filterTests from "../../support/filterTests" |
import filterTests from "../../support/filterTests" |
||||
|
|
||||
filterTests(['smoke', 'all'], () => { |
filterTests(["smoke", "all"], () => { |
||||
context("REST Datasource Testing", () => { |
context("REST Datasource Testing", () => { |
||||
before(() => { |
before(() => { |
||||
cy.login() |
cy.login() |
||||
cy.createTestApp() |
cy.createTestApp() |
||||
}) |
|
||||
|
|
||||
const datasource = "REST" |
|
||||
const restUrl = "https://api.openbrewerydb.org/breweries" |
|
||||
|
|
||||
it("Should add REST data source with incorrect API", () => { |
|
||||
// Select REST data source
|
|
||||
cy.selectExternalDatasource(datasource) |
|
||||
// Enter incorrect api & attempt to send query
|
|
||||
cy.wait(500) |
|
||||
cy.get(".spectrum-Button").contains("Add query").click({ force: true }) |
|
||||
cy.intercept('**/preview').as('queryError') |
|
||||
cy.get("input").clear().type("random text") |
|
||||
cy.get(".spectrum-Button").contains("Send").click({ force: true }) |
|
||||
// Intercept Request after button click & apply assertions
|
|
||||
cy.wait("@queryError") |
|
||||
cy.get("@queryError").its('response.body') |
|
||||
.should('have.property', 'message', 'Invalid URL: http://random text?') |
|
||||
cy.get("@queryError").its('response.body') |
|
||||
.should('have.property', 'status', 400) |
|
||||
}) |
|
||||
|
|
||||
it("should add and configure a REST datasource", () => { |
|
||||
// Select REST datasource and create query
|
|
||||
cy.selectExternalDatasource(datasource) |
|
||||
cy.wait(500) |
|
||||
// createRestQuery confirms query creation
|
|
||||
cy.createRestQuery("GET", restUrl) |
|
||||
// Confirm status code response within REST datasource
|
|
||||
cy.get(".spectrum-FieldLabel") |
|
||||
.contains("Status") |
|
||||
.children() |
|
||||
.should('contain', 200) |
|
||||
}) |
|
||||
}) |
}) |
||||
|
|
||||
|
const datasource = "REST" |
||||
|
const restUrl = "https://api.openbrewerydb.org/breweries" |
||||
|
|
||||
|
it("Should add REST data source with incorrect API", () => { |
||||
|
// Select REST data source
|
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
// Enter incorrect api & attempt to send query
|
||||
|
cy.wait(500) |
||||
|
cy.get(".spectrum-Button").contains("Add query").click({ force: true }) |
||||
|
cy.intercept("**/preview").as("queryError") |
||||
|
cy.get("input").clear().type("random text") |
||||
|
cy.get(".spectrum-Button").contains("Send").click({ force: true }) |
||||
|
// Intercept Request after button click & apply assertions
|
||||
|
cy.wait("@queryError") |
||||
|
cy.get("@queryError") |
||||
|
.its("response.body") |
||||
|
.should("have.property", "message", "Invalid URL: http://random text?") |
||||
|
cy.get("@queryError") |
||||
|
.its("response.body") |
||||
|
.should("have.property", "status", 400) |
||||
|
}) |
||||
|
|
||||
|
it("should add and configure a REST datasource", () => { |
||||
|
// Select REST datasource and create query
|
||||
|
cy.selectExternalDatasource(datasource) |
||||
|
cy.wait(500) |
||||
|
// createRestQuery confirms query creation
|
||||
|
cy.createRestQuery("GET", restUrl, "/breweries") |
||||
|
// Confirm status code response within REST datasource
|
||||
|
cy.get(".spectrum-FieldLabel") |
||||
|
.contains("Status") |
||||
|
.children() |
||||
|
.should("contain", 200) |
||||
|
}) |
||||
|
}) |
||||
}) |
}) |
||||
|
|||||
@ -0,0 +1,64 @@ |
|||||
|
<script> |
||||
|
import { |
||||
|
Select, |
||||
|
Toggle, |
||||
|
DatePicker, |
||||
|
Multiselect, |
||||
|
TextArea, |
||||
|
} from "@budibase/bbui" |
||||
|
import LinkedRowSelector from "components/common/LinkedRowSelector.svelte" |
||||
|
import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte" |
||||
|
import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte" |
||||
|
|
||||
|
export let onChange |
||||
|
export let field |
||||
|
export let schema |
||||
|
export let value |
||||
|
export let bindings |
||||
|
|
||||
|
function schemaHasOptions(schema) { |
||||
|
return !!schema.constraints?.inclusion?.length |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
{#if schemaHasOptions(schema) && schema.type !== "array"} |
||||
|
<Select |
||||
|
on:change={e => onChange(e, field)} |
||||
|
label={field} |
||||
|
value={value[field]} |
||||
|
options={schema.constraints.inclusion} |
||||
|
/> |
||||
|
{:else if schema.type === "datetime"} |
||||
|
<DatePicker |
||||
|
label={field} |
||||
|
value={value[field]} |
||||
|
on:change={e => onChange(e, field)} |
||||
|
/> |
||||
|
{:else if schema.type === "boolean"} |
||||
|
<Toggle |
||||
|
text={field} |
||||
|
value={value[field]} |
||||
|
on:change={e => onChange(e, field)} |
||||
|
/> |
||||
|
{:else if schema.type === "array"} |
||||
|
<Multiselect |
||||
|
bind:value={value[field]} |
||||
|
label={field} |
||||
|
options={schema.constraints.inclusion} |
||||
|
/> |
||||
|
{:else if schema.type === "longform"} |
||||
|
<TextArea label={field} bind:value={value[field]} /> |
||||
|
{:else if schema.type === "link"} |
||||
|
<LinkedRowSelector bind:linkedRows={value[field]} {schema} /> |
||||
|
{:else if schema.type === "string" || schema.type === "number"} |
||||
|
<DrawerBindableInput |
||||
|
panel={AutomationBindingPanel} |
||||
|
value={value[field]} |
||||
|
on:change={e => onChange(e, field)} |
||||
|
label={field} |
||||
|
type="string" |
||||
|
{bindings} |
||||
|
fillWidth={true} |
||||
|
allowJS={true} |
||||
|
/> |
||||
|
{/if} |
||||
@ -0,0 +1,8 @@ |
|||||
|
<script> |
||||
|
import Provider from "./Provider.svelte" |
||||
|
import { rowSelectionStore } from "stores" |
||||
|
</script> |
||||
|
|
||||
|
<Provider key="rowSelection" data={$rowSelectionStore}> |
||||
|
<slot /> |
||||
|
</Provider> |
||||
@ -0,0 +1,22 @@ |
|||||
|
import { writable } from "svelte/store" |
||||
|
|
||||
|
const createRowSelectionStore = () => { |
||||
|
const store = writable({}) |
||||
|
|
||||
|
function updateSelection(componentId, selectedRows) { |
||||
|
store.update(state => { |
||||
|
state[componentId] = [...selectedRows] |
||||
|
return state |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
return { |
||||
|
subscribe: store.subscribe, |
||||
|
set: store.set, |
||||
|
actions: { |
||||
|
updateSelection, |
||||
|
}, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export const rowSelectionStore = createRowSelectionStore() |
||||
Loading…
Reference in new issue