Skip to content

Commit

Permalink
15700 add tests for PokeAPI (airbytehq#15701)
Browse files Browse the repository at this point in the history
* add tests for PokeAPI

* Update connection.spec.ts

add body verification

* add page object model for update connection (poke api) test

* change structure with using POM

* Select sync mode dropdown with a data-testid (airbytehq#16053)

* Fix coments

* fix goToDestinationPage signature

* move fillEmail method

* change structure with using POM

* Fix coments

* Update connection.spec.ts

fix request url and schedule dropdown value

Co-authored-by: Alex Birdsall <ambirdsall@gmail.com>
  • Loading branch information
2 people authored and robbinhan committed Sep 29, 2022
1 parent 2339697 commit 692e689
Show file tree
Hide file tree
Showing 17 changed files with 352 additions and 107 deletions.
44 changes: 4 additions & 40 deletions airbyte-webapp-e2e-tests/cypress/commands/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,6 @@ export const submitButtonClick = () => {
cy.get("button[type=submit]").click();
}

export const fillEmail = (email: string) => {
cy.get("input[name=email]").type(email);
}

export const fillTestLocalJsonForm = (name: string) => {
cy.intercept("/api/v1/destination_definition_specifications/get").as("getDestinationSpecifications");

cy.get("div[data-testid='serviceType']").click();
cy.get("div").contains("Local JSON").click();

cy.wait("@getDestinationSpecifications");

cy.get("input[name=name]").clear().type(name);
cy.get("input[name='connectionConfiguration.destination_path']").type("/local");
}

export const openSourcePage = () => {
cy.intercept("/api/v1/sources/list").as("getSourcesList");
cy.visit("/source");
cy.wait("@getSourcesList");
}

export const openDestinationPage = () => {
cy.intercept("/api/v1/destinations/list").as("getDestinationsList");
cy.visit("/destination");
cy.wait("@getDestinationsList");
}

export const openNewSourceForm = () => {
openSourcePage();
cy.get("button[data-id='new-source'").click();
cy.url().should("include", `/source/new-source`);
}

export const openNewDestinationForm = () => {
openDestinationPage();
cy.get("button[data-id='new-destination'").click();
cy.url().should("include", `/destination/new-destination`);
}

export const updateField = (field: string, value: string) => {
cy.get("input[name='" + field + "']").clear().type(value);
}
Expand All @@ -61,3 +21,7 @@ export const clearApp = () => {
cy.clearLocalStorage();
cy.clearCookies();
}

export const fillEmail = (email: string) => {
cy.get("input[name=email]").type(email);
}
30 changes: 20 additions & 10 deletions airbyte-webapp-e2e-tests/cypress/commands/connection.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
import { submitButtonClick } from "./common";
import { createTestDestination } from "./destination";
import { createTestSource } from "./source";
import { createLocalJsonDestination } from "./destination";
import { createPokeApiSource, createPostgresSource } from "./source";
import { openAddSource } from "pages/destinationPage"
import { selectSchedule, setupDestinationNamespaceSourceFormat, enterConnectionName } from "pages/replicationPage"

export const createTestConnection = (sourceName: string, destinationName: string) => {
cy.intercept("/api/v1/sources/discover_schema").as("discoverSchema");
cy.intercept("/api/v1/web_backend/connections/create").as("createConnection");

createTestSource(sourceName);
createTestDestination(destinationName);
switch (true) {
case sourceName.includes('PokeAPI'):
createPokeApiSource(sourceName, "luxray")
break;
case sourceName.includes('Postgres'):
createPostgresSource(sourceName);
break;
default:
createPostgresSource(sourceName);
}

createLocalJsonDestination(destinationName, "/local");
cy.wait(5000);

cy.get("div[data-testid='select-source']").click();
openAddSource();
cy.get("div").contains(sourceName).click();

cy.wait("@discoverSchema");

cy.get("input[data-testid='connectionName']").type("Connection name");
cy.get("div[data-testid='scheduleData.basicSchedule']").click();
cy.get("div[data-testid='Manual']").click();
enterConnectionName("Connection name");
selectSchedule("Manual");

cy.get("div[data-testid='namespaceDefinition']").click();
cy.get("div[data-testid='namespaceDefinition-source']").click();
setupDestinationNamespaceSourceFormat();
submitButtonClick();

cy.wait("@createConnection");
Expand Down
42 changes: 42 additions & 0 deletions airbyte-webapp-e2e-tests/cypress/commands/connector.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { enterDestinationPath, selectServiceType, enterName, enterHost, enterPort, enterDatabase, enterUsername, enterPassword, enterPokemonName } from "pages/createConnectorPage"

export const fillPostgresForm = (name: string, host: string, port: string, database: string, username: string, password: string) => {
cy.intercept("/api/v1/source_definition_specifications/get").as(
"getSourceSpecifications"
);

selectServiceType("Postgres");

cy.wait("@getSourceSpecifications");

enterName(name);
enterHost(host);
enterPort(port);
enterDatabase(database);
enterUsername(username);
enterPassword(password);
};

export const fillPokeAPIForm = (name: string, pokeName: string) => {
cy.intercept("/api/v1/source_definition_specifications/get").as(
"getSourceSpecifications"
);

selectServiceType("PokeAPI");

cy.wait("@getSourceSpecifications");

enterName(name);
enterPokemonName(pokeName);
};

export const fillLocalJsonForm = (name: string, destinationPath: string) => {
cy.intercept("/api/v1/destination_definition_specifications/get").as("getDestinationSpecifications");

selectServiceType("Local JSON");

cy.wait("@getDestinationSpecifications");

enterName(name);
enterDestinationPath(destinationPath);
}
16 changes: 11 additions & 5 deletions airbyte-webapp-e2e-tests/cypress/commands/destination.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { deleteEntity, fillTestLocalJsonForm, openDestinationPage, openNewDestinationForm, openSettingForm, submitButtonClick, updateField } from "./common";
import { deleteEntity, openSettingForm, submitButtonClick, updateField } from "./common";
import { fillLocalJsonForm } from "./connector"
import { goToDestinationPage, openNewDestinationForm } from "pages/destinationPage"

export const createTestDestination = (name: string) => {
export const createLocalJsonDestination = (name: string, destinationPath: string) => {
cy.intercept("/api/v1/scheduler/destinations/check_connection").as("checkDestinationConnection");
cy.intercept("/api/v1/destinations/create").as("createDestination");

goToDestinationPage();
openNewDestinationForm();
fillTestLocalJsonForm(name);
fillLocalJsonForm(name, destinationPath);
submitButtonClick();

cy.wait(3000);
cy.wait("@checkDestinationConnection");
cy.wait("@createDestination");
}
Expand All @@ -16,7 +20,7 @@ export const updateDestination = (name: string, field: string, value: string) =>
cy.intercept("/api/v1/destinations/check_connection_for_update").as("checkDestinationUpdateConnection");
cy.intercept("/api/v1/destinations/update").as("updateDestination");

openDestinationPage();
goToDestinationPage();
openSettingForm(name);
updateField(field, value);
submitButtonClick();
Expand All @@ -26,7 +30,9 @@ export const updateDestination = (name: string, field: string, value: string) =>
}

export const deleteDestination = (name: string) => {
openDestinationPage();
cy.intercept("/api/v1/destinations/delete").as("deleteDestination");
goToDestinationPage();
openSettingForm(name);
deleteEntity();
cy.wait("@deleteDestination");
}
3 changes: 0 additions & 3 deletions airbyte-webapp-e2e-tests/cypress/commands/sidebar.ts

This file was deleted.

53 changes: 30 additions & 23 deletions airbyte-webapp-e2e-tests/cypress/commands/source.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
import { deleteEntity, openNewSourceForm, openSettingForm, openSourcePage, submitButtonClick, updateField } from "./common";

export const fillPgSourceForm = (name: string) => {
cy.intercept("/api/v1/source_definition_specifications/get").as(
"getSourceSpecifications"
);

cy.get("div[data-testid='serviceType']").click();
cy.get("div").contains("Postgres").click();

cy.wait("@getSourceSpecifications");

cy.get("input[name=name]").clear().type(name);
cy.get("input[name='connectionConfiguration.host']").type("localhost");
cy.get("input[name='connectionConfiguration.port']").type("{selectAll}{del}5433");
cy.get("input[name='connectionConfiguration.database']").type("airbyte_ci");
cy.get("input[name='connectionConfiguration.username']").type("postgres");
cy.get("input[name='connectionConfiguration.password']").type(
"secret_password"
import { deleteEntity, openSettingForm, submitButtonClick, updateField } from "./common";
import { goToSourcePage, openNewSourceForm} from "pages/sourcePage";
import { fillPostgresForm, fillPokeAPIForm } from "./connector"

export const createPostgresSource = (
name: string,
host: string = "localhost",
port: string = "{selectAll}{del}5433",
database: string = "airbyte_ci",
username: string = "postgres",
password: string = "secret_password"
) => {
cy.intercept("/api/v1/scheduler/sources/check_connection").as(
"checkSourceUpdateConnection"
);
cy.intercept("/api/v1/sources/create").as("createSource");

goToSourcePage();
openNewSourceForm();
fillPostgresForm(name, host, port, database, username, password);
submitButtonClick();

cy.wait("@checkSourceUpdateConnection");
cy.wait("@createSource");
};

export const createTestSource = (name: string) => {
export const createPokeApiSource = (name: string, pokeName: string) => {
cy.intercept("/api/v1/scheduler/sources/check_connection").as(
"checkSourceUpdateConnection"
);
cy.intercept("/api/v1/sources/create").as("createSource");

goToSourcePage();
openNewSourceForm();
fillPgSourceForm(name);
fillPokeAPIForm(name, pokeName);
submitButtonClick();

cy.wait("@checkSourceUpdateConnection");
Expand All @@ -40,7 +45,7 @@ export const updateSource = (name: string, field: string, value: string) => {
);
cy.intercept("/api/v1/sources/update").as("updateSource");

openSourcePage();
goToSourcePage();
openSettingForm(name);
updateField(field, value);
submitButtonClick();
Expand All @@ -50,7 +55,9 @@ export const updateSource = (name: string, field: string, value: string) => {
}

export const deleteSource = (name: string) => {
openSourcePage();
cy.intercept("/api/v1/sources/delete").as("deleteSource");
goToSourcePage();
openSettingForm(name);
deleteEntity();
cy.wait("@deleteSource");
}
Loading

0 comments on commit 692e689

Please sign in to comment.