2022-01-21 13:43:27 +01:00
|
|
|
import filterTests from "../../support/filterTests"
|
|
|
|
|
2022-02-25 17:24:36 +01:00
|
|
|
filterTests(["smoke", "all"], () => {
|
|
|
|
context("REST Datasource Testing", () => {
|
|
|
|
before(() => {
|
|
|
|
cy.login()
|
|
|
|
cy.createTestApp()
|
2021-12-24 11:38:03 +01:00
|
|
|
})
|
2022-02-25 17:24:36 +01:00
|
|
|
|
|
|
|
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
|
2022-09-06 10:50:02 +02:00
|
|
|
cy.get(".query-buttons", { timeout: 1000 }).contains("Add query").click({ force: true })
|
2022-02-25 17:24:36 +01:00
|
|
|
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")
|
2022-03-29 11:38:56 +02:00
|
|
|
.should("have.property", "message", "Invalid URL: http://random text?")
|
2022-02-25 17:24:36 +01:00
|
|
|
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
|
2022-06-17 18:41:07 +02:00
|
|
|
cy.get(".stats", { timeout: 1000 }).within(() => {
|
2022-03-10 14:46:30 +01:00
|
|
|
cy.get(".spectrum-FieldLabel")
|
|
|
|
.eq(0)
|
2022-02-25 17:24:36 +01:00
|
|
|
.should("contain", 200)
|
2022-03-10 14:46:30 +01:00
|
|
|
})
|
2022-02-25 17:24:36 +01:00
|
|
|
})
|
|
|
|
})
|
2021-12-24 11:40:57 +01:00
|
|
|
})
|