1
0
Fork 0
mirror of synced 2024-06-03 02:55:14 +12:00
budibase/packages/builder/cypress/integration/datasources/rest.spec.js
Mitch-Budibase daca40850c New Tests and Changes based on updated test environment
-Changes made to reflect the new layouts of the test env
--e.g. Changes to the app grid, changes to UI screens
-Updated commands
--New commands added & some updated
-New tests
--Revert App
--AutoScreensUI
--Change app icon and colour
--Data source testing

In particular to data source testing
-I have a file for mySQL, PostgreSQL, Oracle, and REST.
--enabled better regression testing for each

Other changes made for:
-QueryLevelTransformers tests
-Table tests
-Renaming applications
-Automations
-Multi-option datastype

New env file added too
2021-12-24 10:38:03 +00:00

40 lines
1.5 KiB
JavaScript

context("REST Datasource Testing", () => {
before(() => {
cy.login()
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', 'request to http://random/%20text? failed, reason: getaddrinfo ENOTFOUND random')
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)
})
})