Skip to content

Commit 8ea3e4f

Browse files
SofiiaZaitsevaambirdsall
authored andcommitted
15700 add tests for PokeAPI (airbytehq#15701)
* 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 <[email protected]>
1 parent aa4b4a7 commit 8ea3e4f

File tree

17 files changed

+352
-107
lines changed

17 files changed

+352
-107
lines changed

airbyte-webapp-e2e-tests/cypress/commands/common.ts

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,6 @@ export const submitButtonClick = () => {
22
cy.get("button[type=submit]").click();
33
}
44

5-
export const fillEmail = (email: string) => {
6-
cy.get("input[name=email]").type(email);
7-
}
8-
9-
export const fillTestLocalJsonForm = (name: string) => {
10-
cy.intercept("/api/v1/destination_definition_specifications/get").as("getDestinationSpecifications");
11-
12-
cy.get("div[data-testid='serviceType']").click();
13-
cy.get("div").contains("Local JSON").click();
14-
15-
cy.wait("@getDestinationSpecifications");
16-
17-
cy.get("input[name=name]").clear().type(name);
18-
cy.get("input[name='connectionConfiguration.destination_path']").type("/local");
19-
}
20-
21-
export const openSourcePage = () => {
22-
cy.intercept("/api/v1/sources/list").as("getSourcesList");
23-
cy.visit("/source");
24-
cy.wait("@getSourcesList");
25-
}
26-
27-
export const openDestinationPage = () => {
28-
cy.intercept("/api/v1/destinations/list").as("getDestinationsList");
29-
cy.visit("/destination");
30-
cy.wait("@getDestinationsList");
31-
}
32-
33-
export const openNewSourceForm = () => {
34-
openSourcePage();
35-
cy.get("button[data-id='new-source'").click();
36-
cy.url().should("include", `/source/new-source`);
37-
}
38-
39-
export const openNewDestinationForm = () => {
40-
openDestinationPage();
41-
cy.get("button[data-id='new-destination'").click();
42-
cy.url().should("include", `/destination/new-destination`);
43-
}
44-
455
export const updateField = (field: string, value: string) => {
466
cy.get("input[name='" + field + "']").clear().type(value);
477
}
@@ -61,3 +21,7 @@ export const clearApp = () => {
6121
cy.clearLocalStorage();
6222
cy.clearCookies();
6323
}
24+
25+
export const fillEmail = (email: string) => {
26+
cy.get("input[name=email]").type(email);
27+
}

airbyte-webapp-e2e-tests/cypress/commands/connection.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,36 @@
11
import { submitButtonClick } from "./common";
2-
import { createTestDestination } from "./destination";
3-
import { createTestSource } from "./source";
2+
import { createLocalJsonDestination } from "./destination";
3+
import { createPokeApiSource, createPostgresSource } from "./source";
4+
import { openAddSource } from "pages/destinationPage"
5+
import { selectSchedule, setupDestinationNamespaceSourceFormat, enterConnectionName } from "pages/replicationPage"
46

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

9-
createTestSource(sourceName);
10-
createTestDestination(destinationName);
11+
switch (true) {
12+
case sourceName.includes('PokeAPI'):
13+
createPokeApiSource(sourceName, "luxray")
14+
break;
15+
case sourceName.includes('Postgres'):
16+
createPostgresSource(sourceName);
17+
break;
18+
default:
19+
createPostgresSource(sourceName);
20+
}
21+
22+
createLocalJsonDestination(destinationName, "/local");
1123
cy.wait(5000);
1224

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

1628
cy.wait("@discoverSchema");
1729

18-
cy.get("input[data-testid='connectionName']").type("Connection name");
19-
cy.get("div[data-testid='scheduleData.basicSchedule']").click();
20-
cy.get("div[data-testid='Manual']").click();
30+
enterConnectionName("Connection name");
31+
selectSchedule("Manual");
2132

22-
cy.get("div[data-testid='namespaceDefinition']").click();
23-
cy.get("div[data-testid='namespaceDefinition-source']").click();
33+
setupDestinationNamespaceSourceFormat();
2434
submitButtonClick();
2535

2636
cy.wait("@createConnection");
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { enterDestinationPath, selectServiceType, enterName, enterHost, enterPort, enterDatabase, enterUsername, enterPassword, enterPokemonName } from "pages/createConnectorPage"
2+
3+
export const fillPostgresForm = (name: string, host: string, port: string, database: string, username: string, password: string) => {
4+
cy.intercept("/api/v1/source_definition_specifications/get").as(
5+
"getSourceSpecifications"
6+
);
7+
8+
selectServiceType("Postgres");
9+
10+
cy.wait("@getSourceSpecifications");
11+
12+
enterName(name);
13+
enterHost(host);
14+
enterPort(port);
15+
enterDatabase(database);
16+
enterUsername(username);
17+
enterPassword(password);
18+
};
19+
20+
export const fillPokeAPIForm = (name: string, pokeName: string) => {
21+
cy.intercept("/api/v1/source_definition_specifications/get").as(
22+
"getSourceSpecifications"
23+
);
24+
25+
selectServiceType("PokeAPI");
26+
27+
cy.wait("@getSourceSpecifications");
28+
29+
enterName(name);
30+
enterPokemonName(pokeName);
31+
};
32+
33+
export const fillLocalJsonForm = (name: string, destinationPath: string) => {
34+
cy.intercept("/api/v1/destination_definition_specifications/get").as("getDestinationSpecifications");
35+
36+
selectServiceType("Local JSON");
37+
38+
cy.wait("@getDestinationSpecifications");
39+
40+
enterName(name);
41+
enterDestinationPath(destinationPath);
42+
}
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
import { deleteEntity, fillTestLocalJsonForm, openDestinationPage, openNewDestinationForm, openSettingForm, submitButtonClick, updateField } from "./common";
1+
import { deleteEntity, openSettingForm, submitButtonClick, updateField } from "./common";
2+
import { fillLocalJsonForm } from "./connector"
3+
import { goToDestinationPage, openNewDestinationForm } from "pages/destinationPage"
24

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

9+
goToDestinationPage();
710
openNewDestinationForm();
8-
fillTestLocalJsonForm(name);
11+
fillLocalJsonForm(name, destinationPath);
912
submitButtonClick();
1013

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

19-
openDestinationPage();
23+
goToDestinationPage();
2024
openSettingForm(name);
2125
updateField(field, value);
2226
submitButtonClick();
@@ -26,7 +30,9 @@ export const updateDestination = (name: string, field: string, value: string) =>
2630
}
2731

2832
export const deleteDestination = (name: string) => {
29-
openDestinationPage();
33+
cy.intercept("/api/v1/destinations/delete").as("deleteDestination");
34+
goToDestinationPage();
3035
openSettingForm(name);
3136
deleteEntity();
37+
cy.wait("@deleteDestination");
3238
}

airbyte-webapp-e2e-tests/cypress/commands/sidebar.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
1-
import { deleteEntity, openNewSourceForm, openSettingForm, openSourcePage, submitButtonClick, updateField } from "./common";
2-
3-
export const fillPgSourceForm = (name: string) => {
4-
cy.intercept("/api/v1/source_definition_specifications/get").as(
5-
"getSourceSpecifications"
6-
);
7-
8-
cy.get("div[data-testid='serviceType']").click();
9-
cy.get("div").contains("Postgres").click();
10-
11-
cy.wait("@getSourceSpecifications");
12-
13-
cy.get("input[name=name]").clear().type(name);
14-
cy.get("input[name='connectionConfiguration.host']").type("localhost");
15-
cy.get("input[name='connectionConfiguration.port']").type("{selectAll}{del}5433");
16-
cy.get("input[name='connectionConfiguration.database']").type("airbyte_ci");
17-
cy.get("input[name='connectionConfiguration.username']").type("postgres");
18-
cy.get("input[name='connectionConfiguration.password']").type(
19-
"secret_password"
1+
import { deleteEntity, openSettingForm, submitButtonClick, updateField } from "./common";
2+
import { goToSourcePage, openNewSourceForm} from "pages/sourcePage";
3+
import { fillPostgresForm, fillPokeAPIForm } from "./connector"
4+
5+
export const createPostgresSource = (
6+
name: string,
7+
host: string = "localhost",
8+
port: string = "{selectAll}{del}5433",
9+
database: string = "airbyte_ci",
10+
username: string = "postgres",
11+
password: string = "secret_password"
12+
) => {
13+
cy.intercept("/api/v1/scheduler/sources/check_connection").as(
14+
"checkSourceUpdateConnection"
2015
);
16+
cy.intercept("/api/v1/sources/create").as("createSource");
17+
18+
goToSourcePage();
19+
openNewSourceForm();
20+
fillPostgresForm(name, host, port, database, username, password);
21+
submitButtonClick();
22+
23+
cy.wait("@checkSourceUpdateConnection");
24+
cy.wait("@createSource");
2125
};
2226

23-
export const createTestSource = (name: string) => {
27+
export const createPokeApiSource = (name: string, pokeName: string) => {
2428
cy.intercept("/api/v1/scheduler/sources/check_connection").as(
2529
"checkSourceUpdateConnection"
2630
);
2731
cy.intercept("/api/v1/sources/create").as("createSource");
2832

33+
goToSourcePage();
2934
openNewSourceForm();
30-
fillPgSourceForm(name);
35+
fillPokeAPIForm(name, pokeName);
3136
submitButtonClick();
3237

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

43-
openSourcePage();
48+
goToSourcePage();
4449
openSettingForm(name);
4550
updateField(field, value);
4651
submitButtonClick();
@@ -50,7 +55,9 @@ export const updateSource = (name: string, field: string, value: string) => {
5055
}
5156

5257
export const deleteSource = (name: string) => {
53-
openSourcePage();
58+
cy.intercept("/api/v1/sources/delete").as("deleteSource");
59+
goToSourcePage();
5460
openSettingForm(name);
5561
deleteEntity();
62+
cy.wait("@deleteSource");
5663
}

0 commit comments

Comments
 (0)