Skip to content

Commit 39167a4

Browse files
timroesetsybaev
authored andcommitted
Use cypress dashboard and stabilize e2e tests (#10807)
* Record e2e tests to cypress dashboard * Make env variable accessible in script * Improve e2e_test script * Properly wait for server to be ready * Isolate test suites better * More test isolation * Revert baseUrl for development
1 parent b58cd31 commit 39167a4

File tree

11 files changed

+51
-9
lines changed

11 files changed

+51
-9
lines changed

.github/workflows/gradle.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ jobs:
407407
run: SUB_BUILD=PLATFORM ./gradlew --no-daemon assemble --scan
408408

409409
- name: Run End-to-End Frontend Tests
410+
env:
411+
CYPRESS_WEBAPP_KEY: ${{ secrets.CYPRESS_WEBAPP_KEY }}
410412
run: ./tools/bin/e2e_test.sh
411413
# In case of self-hosted EC2 errors, remove this block.
412414
stop-frontend-test-runner:

airbyte-webapp-e2e-tests/build.gradle

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@ node {
1313

1414
task e2etest(type: NpmTask) {
1515
dependsOn npmInstall
16-
17-
args = ['run', 'cypress:ci']
16+
// If the cypressWebappKey property has been set from the outside (see tools/bin/e2e_test.sh)
17+
// we'll record the cypress session, otherwise we're not recording
18+
def recordCypress = project.hasProperty('cypressWebappKey') && project.getProperty('cypressWebappKey')
19+
if (recordCypress) {
20+
environment = [CYPRESS_KEY: project.getProperty('cypressWebappKey')]
21+
args = ['run', 'cypress:ci:record']
22+
} else {
23+
args = ['run', 'cypress:ci']
24+
}
1825
inputs.files fileTree('cypress')
1926
inputs.file 'package.json'
2027
inputs.file 'package-lock.json'

airbyte-webapp-e2e-tests/cypress.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"projectId": "916nvw",
23
"baseUrl": "http://localhost:3000",
34
"testFiles": [
45
"base.spec.js",

airbyte-webapp-e2e-tests/cypress/integration/connection.spec.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
describe("Connection main actions", () => {
2+
beforeEach(() => {
3+
cy.initialSetupCompleted();
4+
});
5+
26
it("Create new connection", () => {
37
cy.createTestConnection("Test connection source cypress", "Test destination cypress");
48

59
cy.get("div").contains("Test connection source cypress").should("exist");
610
cy.get("div").contains("Test destination cypress").should("exist");
711
});
812

9-
it.only("Update connection", () => {
13+
it("Update connection", () => {
1014
cy.intercept("/api/v1/web_backend/connections/update").as("updateConnection");
1115

1216
cy.createTestConnection("Test update connection source cypress", "Test update connection destination cypress");

airbyte-webapp-e2e-tests/cypress/integration/destination.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
describe("Destination main actions", () => {
2+
beforeEach(() => {
3+
cy.initialSetupCompleted();
4+
});
5+
26
it("Create new destination", () => {
37
cy.createTestDestination("Test destination cypress");
48

airbyte-webapp-e2e-tests/cypress/integration/onboarding.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
describe("Preferences actions", () => {
2+
beforeEach(() => {
3+
cy.initialSetupCompleted(false);
4+
});
5+
26
it("Should redirect to onboarding after email is entered", () => {
37
cy.visit("/preferences");
48
cy.url().should("include", `/preferences`);

airbyte-webapp-e2e-tests/cypress/integration/source.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
describe("Source main actions", () => {
2+
beforeEach(() => {
3+
cy.initialSetupCompleted();
4+
});
5+
26
it("Create new source", () => {
37
cy.createTestSource("Test source cypress");
48

airbyte-webapp-e2e-tests/cypress/support/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ import "./sidebar";
33
import "./source";
44
import "./destination";
55
import "./connection";
6+
import "./workspaces";
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Cypress.Commands.add("initialSetupCompleted", (completed = true) => {
2+
// Modify the workspaces/list response to mark every workspace as "initialSetupComplete" to ensure we're not showing
3+
// the setup/preference page for any workspace if this method got called.
4+
cy.intercept("POST", "/api/v1/workspaces/list", (req) => {
5+
req.continue(res => {
6+
res.body.workspaces = res.body.workspaces.map(ws => ({ ...ws, initialSetupComplete: completed }));
7+
res.send(res.body);
8+
});
9+
});
10+
});

airbyte-webapp-e2e-tests/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "Airbyte e2e testing",
55
"scripts": {
66
"cypress:open": "cypress open",
7-
"cypress:ci": "CYPRESS_BASE_URL=http://localhost:8000 cypress run"
7+
"cypress:ci": "CYPRESS_BASE_URL=http://localhost:8000 cypress run",
8+
"cypress:ci:record": "CYPRESS_BASE_URL=http://localhost:8000 cypress run --record --key $CYPRESS_KEY"
89
},
910
"eslintConfig": {
1011
"env": {

0 commit comments

Comments
 (0)