-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connector builder: E2e tests (#21122)
* wip * wip * e2e tests for connector builder server * rename function * clean up * clean up a bit more * fix path * fix and add documentation * more documentation * stabilze * review comments
- Loading branch information
Joe Reuter
authored
Jan 10, 2023
1 parent
f921d8c
commit f61a790
Showing
14 changed files
with
266 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
airbyte-webapp-e2e-tests/cypress/commands/connectorBuilder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { | ||
addStream, | ||
configureOffsetPagination, | ||
enterName, | ||
enterRecordSelector, | ||
enterStreamName, | ||
enterTestInputs, | ||
enterUrlBase, | ||
enterUrlPath, | ||
goToTestPage, | ||
goToView, | ||
openTestInputs, | ||
selectAuthMethod, | ||
submitForm, | ||
togglePagination | ||
} from "pages/connectorBuilderPage"; | ||
|
||
export const configureGlobals = () => { | ||
goToView("global"); | ||
enterName("Dummy API"); | ||
enterUrlBase("http://dummy_api:6767/"); | ||
} | ||
|
||
export const configureStream = () => { | ||
addStream(); | ||
enterStreamName("Items"); | ||
enterUrlPath("items/"); | ||
submitForm(); | ||
enterRecordSelector("items"); | ||
} | ||
|
||
export const configureAuth = () => { | ||
goToView("global"); | ||
selectAuthMethod("Bearer"); | ||
openTestInputs(); | ||
enterTestInputs({ apiKey: "theauthkey" }) | ||
submitForm(); | ||
} | ||
|
||
export const configurePagination = () => { | ||
goToView("0"); | ||
togglePagination(); | ||
configureOffsetPagination("2", "header", "offset"); | ||
} | ||
|
||
const testPanelContains = (str: string) => { | ||
cy.get("pre").contains(str).should("exist"); | ||
} | ||
|
||
export const assertTestReadAuthFailure = () => { | ||
testPanelContains('"error": "Bad credentials"'); | ||
}; | ||
|
||
export const assertTestReadItems = () => { | ||
testPanelContains('"name": "abc"'); | ||
testPanelContains('"name": "def"'); | ||
}; | ||
|
||
export const assertMultiPageReadItems = () => { | ||
goToTestPage(1); | ||
assertTestReadItems(); | ||
|
||
goToTestPage(2); | ||
testPanelContains('"name": "xxx"'); | ||
testPanelContains('"name": "yyy"'); | ||
|
||
goToTestPage(3); | ||
testPanelContains('[]'); | ||
}; |
30 changes: 30 additions & 0 deletions
30
airbyte-webapp-e2e-tests/cypress/integration/connectorBuilder.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { goToConnectorBuilderPage, testStream } from "pages/connectorBuilderPage"; | ||
import { assertTestReadItems, assertTestReadAuthFailure, configureAuth, configureGlobals, configureStream, configurePagination, assertMultiPageReadItems } from "commands/connectorBuilder"; | ||
|
||
describe("Connector builder", () => { | ||
before(() => { | ||
goToConnectorBuilderPage(); | ||
}); | ||
|
||
it("Configure basic connector", () => { | ||
configureGlobals(); | ||
configureStream(); | ||
}); | ||
|
||
it("Fail on missing auth", () => { | ||
testStream(); | ||
assertTestReadAuthFailure(); | ||
}); | ||
|
||
it("Succeed on provided auth", () => { | ||
configureAuth(); | ||
testStream(); | ||
assertTestReadItems(); | ||
}); | ||
|
||
it("Pagination", () => { | ||
configurePagination(); | ||
testStream(); | ||
assertMultiPageReadItems(); | ||
}); | ||
}); |
91 changes: 91 additions & 0 deletions
91
airbyte-webapp-e2e-tests/cypress/pages/connectorBuilderPage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
const nameInput = "input[name='global.connectorName']"; | ||
const urlBaseInput = "input[name='global.urlBase']"; | ||
const addStreamButton = "button[data-testid='add-stream']"; | ||
const apiKeyInput = "input[name='connectionConfiguration.api_key']"; | ||
const toggleInput = "input[data-testid='toggle']"; | ||
const streamNameInput = "input[name='streamName']"; | ||
const streamUrlPath = "input[name='urlPath']"; | ||
const recordSelectorInput = "[data-testid='tag-input'] input"; | ||
const authType = "[data-testid='global.authenticator.type']"; | ||
const testInputsButton = "[data-testid='test-inputs']"; | ||
const limitInput = "[name='streams[0].paginator.strategy.page_size']"; | ||
const injectOffsetInto = "[data-testid$='paginator.pageTokenOption.inject_into']"; | ||
const injectOffsetFieldName = "[name='streams[0].paginator.pageTokenOption.field_name']"; | ||
const testPageItem = "[data-testid='test-pages'] li"; | ||
const submit = "button[type='submit']" | ||
const testStreamButton = "button[data-testid='read-stream']"; | ||
|
||
export const goToConnectorBuilderPage = () => { | ||
cy.visit("/connector-builder"); | ||
cy.wait(3000); | ||
}; | ||
|
||
export const enterName = (name: string) => { | ||
cy.get(nameInput).type(name); | ||
}; | ||
|
||
export const enterUrlBase = (urlBase: string) => { | ||
cy.get(urlBaseInput).type(urlBase); | ||
}; | ||
|
||
export const enterRecordSelector = (recordSelector: string) => { | ||
cy.get(recordSelectorInput).first().type(recordSelector, { force: true }).type("{enter}", { force: true }); | ||
}; | ||
|
||
const selectFromDropdown = (selector: string, value: string) => { | ||
cy.get(`${selector} .react-select__dropdown-indicator`).last().click({ force: true }); | ||
|
||
cy.get(`.react-select__option`).contains(value).click(); | ||
} | ||
|
||
export const selectAuthMethod = (value: string) => { | ||
selectFromDropdown(authType, value); | ||
}; | ||
|
||
export const goToView = (view: string) => { | ||
cy.get(`button[data-testid=navbutton-${view}]`).click(); | ||
} | ||
|
||
export const openTestInputs = () => { | ||
cy.get(testInputsButton).click(); | ||
} | ||
|
||
export const enterTestInputs = ({ apiKey }: { apiKey: string }) => { | ||
cy.get(apiKeyInput).type(apiKey); | ||
} | ||
|
||
export const goToTestPage = (page: number) => { | ||
cy.get(testPageItem).contains(page).click(); | ||
} | ||
|
||
export const togglePagination = () => { | ||
cy.get(toggleInput).first().click({ force: true }); | ||
} | ||
|
||
export const configureOffsetPagination = (limit: string, into: string, fieldName: string) => { | ||
cy.get(limitInput).type(limit); | ||
selectFromDropdown(injectOffsetInto, into); | ||
cy.get(injectOffsetFieldName).type(fieldName); | ||
} | ||
|
||
export const addStream = () => { | ||
cy.get(addStreamButton).click(); | ||
}; | ||
|
||
export const enterStreamName = (streamName: string) => { | ||
cy.get(streamNameInput).type(streamName); | ||
}; | ||
|
||
export const enterUrlPath = (urlPath: string) => { | ||
cy.get(streamUrlPath).type(urlPath); | ||
}; | ||
|
||
export const submitForm = () => { | ||
cy.get(submit).click(); | ||
}; | ||
|
||
export const testStream = () => { | ||
// wait for debounced form | ||
cy.wait(500); | ||
cy.get(testStreamButton).click(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Script starting a basic webserver returning mocked data over an authenticated API to test the connector builder UI and connector builder server in an | ||
// end to end fashion. | ||
|
||
// Start with `npm run createdummyapi` | ||
|
||
const http = require('http'); | ||
|
||
const items = [{ name: "abc" }, { name: "def" }, { name: "xxx" }, { name: "yyy" }]; | ||
|
||
const requestListener = function (req, res) { | ||
if (req.headers["authorization"] !== "Bearer theauthkey") { | ||
res.writeHead(403); res.end(JSON.stringify({ error: "Bad credentials" })); return; | ||
} | ||
if (req.url !== "/items") { | ||
res.writeHead(404); res.end(JSON.stringify({ error: "Not found" })); return; | ||
} | ||
// Add more dummy logic in here | ||
res.setHeader("Content-Type", "application/json"); | ||
res.writeHead(200); | ||
res.end(JSON.stringify({ items: [...items].splice(req.headers["offset"] ? Number(req.headers["offset"]) : 0, 2) })); | ||
} | ||
|
||
const server = http.createServer(requestListener); | ||
server.listen(6767); | ||
|
||
process.on('SIGINT', function () { | ||
process.exit() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.