Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend e2e tests #760

Merged
merged 75 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
d3912ac
Added cypress config
marekdedic Dec 23, 2021
df7fb20
Added first frontend e2e test
marekdedic Dec 23, 2021
aa61031
Added coverage reporting
marekdedic Dec 25, 2021
f5693a8
Merge branch 'master' into frontend-e2e-tests
marekdedic Dec 25, 2021
5760a06
Switched to coverage-instrumenter-loader
marekdedic Dec 26, 2021
5346255
Configured cypress not to record a video
marekdedic Dec 26, 2021
74e3f83
Only collecting coverage from frontend files
marekdedic Dec 26, 2021
584d77c
Fixed linting of cypress files
marekdedic Dec 26, 2021
f188576
Added eslint-plugin-cypress
marekdedic Dec 26, 2021
872bc8f
Running scripts in parallel
marekdedic Dec 26, 2021
3e997d8
Added the ability to respond with an error
marekdedic Dec 30, 2021
6039d23
Configurable endpoint stubs
marekdedic Dec 30, 2021
0d39468
Complete walk through the app in FE tests
marekdedic Dec 31, 2021
eab8ffa
Fixed coverage not being reported for script part of components
marekdedic Jan 1, 2022
16b79c4
Covering the Moving component as well
marekdedic Jan 1, 2022
ee5bc11
Passing parameters to endpoint stubs
marekdedic Jan 1, 2022
7456a77
Split out stubEndpoints()
marekdedic Jan 1, 2022
79ca2c6
Renamed basic test
marekdedic Jan 1, 2022
bcb86fd
Added move() arguments assertion
marekdedic Jan 1, 2022
7f788c8
Added dir-selection test
marekdedic Jan 1, 2022
d5f048b
Removed spurious type reference
marekdedic Jan 1, 2022
2591c10
Added configuration test
marekdedic Jan 1, 2022
7ca2bdd
Added confirmation checks
marekdedic Jan 2, 2022
d213f5d
dir-selection -> source-destination-selection
marekdedic Jan 2, 2022
addc866
Added test with non-empty destination folder
marekdedic Jan 2, 2022
49bdfd5
Added tests for move errors
marekdedic Jan 2, 2022
fa002fb
Added test for frontend navigation
marekdedic Jan 3, 2022
ade3bb9
Added test for error in listSharedDrives
marekdedic Jan 4, 2022
76bb385
Added test for error in listFolders
marekdedic Jan 4, 2022
df1fc71
Fixed test names
marekdedic Jan 4, 2022
dd33816
Added test for move errors
marekdedic Jan 4, 2022
86db3be
Removed unused default
marekdedic Jan 4, 2022
de76c04
Simplified packyge.json
marekdedic Jan 4, 2022
f757c2d
Removed dead code
marekdedic Jan 4, 2022
30d34de
Changed CI test job to be only backend test job
marekdedic Jan 4, 2022
785c17f
Added frontend tests to CI
marekdedic Jan 4, 2022
80e30e1
Fixed frontend build
marekdedic Jan 4, 2022
1fe7957
Linting of cypress config files
marekdedic Jan 6, 2022
984a2ce
Merge branch 'master' into frontend-e2e-tests
marekdedic Jan 21, 2022
67239ad
Switched to codecov GH action in frontend tests as well, using flags
marekdedic Jan 21, 2022
309c105
Merge branch 'master' into frontend-e2e-tests
marekdedic May 21, 2022
b968c5b
Merge branch 'master' into frontend-e2e-tests
marekdedic Jul 27, 2022
09eb9e6
Merge branch 'master' into frontend-e2e-tests
marekdedic Aug 28, 2022
9ca3ca1
Updated frontend tests to reflect changes in master
marekdedic Aug 28, 2022
87c39a4
Added additional configuration test
marekdedic Aug 28, 2022
d0da08f
Updated API error test case
marekdedic Aug 28, 2022
eca11ab
Added back tests for unknown move error
marekdedic Aug 28, 2022
3224095
Added frontend test for equal source and destination folders
marekdedic Aug 28, 2022
407d406
Added frontent test for repeating after a timeout
marekdedic Aug 28, 2022
edb3ef1
Merge branch 'master' into frontend-e2e-tests
marekdedic Aug 28, 2022
9463a6b
npm install
marekdedic Aug 28, 2022
751cc5f
Switched to cypress v10
marekdedic Aug 28, 2022
b9dcc6e
Linting with cypress v10
marekdedic Aug 28, 2022
97bb913
Merge branch 'master' into frontend-e2e-tests
marekdedic Aug 30, 2022
f257afd
Removed obsolete comment
marekdedic Aug 30, 2022
53b5b84
Added tests for source selection errors
marekdedic Aug 30, 2022
3a8664f
Added tests for destination selection errors
marekdedic Aug 30, 2022
3091bf8
Merge branch 'master' into frontend-e2e-tests
marekdedic Oct 9, 2022
7e11d05
Switched back to upstream coverage-istanbul-loader
marekdedic Oct 9, 2022
4843c28
Merge branch 'master' into frontend-e2e-tests
marekdedic Feb 8, 2023
ac39018
Switched to webpack-plugin-istanbul
marekdedic Feb 8, 2023
7c3ebe6
Fixed eslintrc
marekdedic Feb 8, 2023
1e73f03
Fixed type change caused by svelte-i18n downgrade
marekdedic Feb 8, 2023
4621cb5
Added test webpack config to non-ts eslint list
marekdedic Feb 8, 2023
a05281b
Added @types/capress__code-coverage
marekdedic Feb 8, 2023
f0a5762
Ignoring missing types of cypress-get-table
marekdedic Feb 8, 2023
559e18f
Revert "Added @types/capress__code-coverage"
marekdedic Feb 8, 2023
c46405d
Eslint disable for @cypress/code-coverage
marekdedic Feb 8, 2023
0f2b56c
Fixed flaky test
marekdedic Feb 8, 2023
771ce55
Merge branch 'master' into frontend-e2e-tests
marekdedic Feb 8, 2023
e75e32a
NPM install
marekdedic Feb 8, 2023
d8d6973
Revert "Fixed flaky test"
marekdedic Feb 8, 2023
041afb7
300ms move delay in tests
marekdedic Feb 8, 2023
0d2dd7e
Revert "300ms move delay in tests"
marekdedic Feb 8, 2023
4d7e0da
Removed timing-sensitive checks
marekdedic Feb 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"parserOptions": {
"parser": "@typescript-eslint/parser",
"project": "./tsconfig.json",
"project": ["./tsconfig.json", "./cypress/tsconfig.json"],
"extraFileExtensions": [".svelte"]
},
"env": {
"browser": true,
"node": false
},
"plugins": ["deprecation", "jest", "simple-import-sort", "@typescript-eslint"],
"plugins": ["deprecation", "cypress", "jest", "simple-import-sort", "@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
Expand Down Expand Up @@ -109,6 +109,7 @@
"gulpfile.js",
"backend.webpack.config.js",
"frontend.webpack.config.js",
"test.frontend.webpack.config.js",
".eslintrc.js"
],
"rules": {
Expand Down Expand Up @@ -150,7 +151,10 @@
}
},
{
"files": ["__tests__/**/*.test.ts"],
"files": [
"__tests__/**/*.test.ts",
"__tests__/test-utils/gas-stubs.ts"
],
"extends": ["plugin:jest/recommended", "plugin:jest/style"],
"rules": {
"jest/consistent-test-it": ["error", { "withinDescribe": "test" }],
Expand All @@ -174,6 +178,18 @@
"jest/require-to-throw-message": "error",
"jest/unbound-method": "error"
}
},
{
"files": [
"__tests__/frontend/**/*.cy.ts",
"__tests__/test-utils/stubEndpoints.ts"
],
"extends": ["plugin:cypress/recommended"],
"rules": {
"cypress/no-force": "error",
"cypress/assertion-before-screenshot": "error",
"cypress/no-pause": "error"
}
}
],
"globals": {
Expand Down
38 changes: 35 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ jobs:
run: |
npm run lint

test:
name: "Test"
backend-test:
name: "Backend test"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
Expand All @@ -84,7 +84,39 @@ jobs:

- name: "Run tests"
run: |
npm test
npm run test:backend

- name: "Upload coverage results"
uses: codecov/[email protected]
with:
flags: backend

frontend-test:
name: "Frontend test"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/[email protected]

- name: "Cache NPM dependencies"
uses: actions/[email protected]
with:
path: "~/.npm"
key: npm-dependencies-${{ runner.os }}-${{ env.cache-version }}-${{ hashFiles('package.json') }}
restore-keys: |
npm-dependencies-${{ runner.os }}-${{ env.cache-version }}-${{ hashFiles('package.json') }}
npm-dependencies-${{ runner.os }}-${{ env.cache-version }}-
npm-dependencies-${{ runner.os }}-

- name: "Install NPM dependencies"
run: |
npm ci

- name: "Run tests"
run: |
npm run test:frontend

- name: "Upload coverage results"
uses: codecov/[email protected]
with:
flags: frontend
37 changes: 37 additions & 0 deletions __tests__/frontend/basic.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { stubEndpoints } from "../test-utils/stubEndpoints";

const stubs = stubEndpoints({
listFolders: (successHandler) => {
successHandler({ status: "success", response: [] });
},
listSharedDrives: (successHandler) => {
successHandler({ status: "success", response: [] });
},
move: (successHandler) => {
setTimeout(() => {
successHandler({ status: "success", response: { errors: [] } });
}, 100);
},
});

it("works with basic configuration", () => {
cy.visit("http://localhost:8080");
cy.contains("Shared drive mover");
cy.contains("Continue").click();
cy.contains("My Drive").click();
cy.contains("Continue").click();
cy.contains("My Drive").click();
cy.contains("Continue").click();
cy.contains('contents of the folder "My Drive" into the folder "My Drive"');
cy.contains("Move").click();
cy.contains("Done!");
cy.contains("Successfully moved").then(() => {
expect(stubs.move).to.have.been.calledOnceWith(
"root",
"root",
true,
true,
false
);
});
});
61 changes: 61 additions & 0 deletions __tests__/frontend/configuration.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { stubEndpoints } from "../test-utils/stubEndpoints";

const stubs = stubEndpoints({
listFolders: (successHandler) => {
successHandler({ status: "success", response: [] });
},
listSharedDrives: (successHandler) => {
successHandler({ status: "success", response: [] });
},
move: (successHandler) => {
setTimeout(() => {
successHandler({ status: "success", response: { errors: [] } });
}, 100);
},
});

it("works with copy configuration", () => {
cy.visit("http://localhost:8080");
cy.contains("Shared drive mover");
cy.contains("Copy comments").click();
cy.contains("Continue").click();
cy.contains("My Drive").click();
cy.contains("Continue").click();
cy.contains("My Drive").click();
cy.contains("Continue").click();
cy.contains('contents of the folder "My Drive" into the folder "My Drive"');
cy.contains("Move").click();
cy.contains("Done!");
cy.contains("Successfully moved").then(() => {
expect(stubs.move).to.have.been.calledOnceWith(
"root",
"root",
false,
true,
false
);
});
});

it("works with merge configuration", () => {
cy.visit("http://localhost:8080");
cy.contains("Shared drive mover");
cy.contains("Copy comments").click();
cy.contains("Continue").click();
cy.contains("My Drive").click();
cy.contains("Continue").click();
cy.contains("My Drive").click();
cy.contains("Continue").click();
cy.contains('contents of the folder "My Drive" into the folder "My Drive"');
cy.contains("Move").click();
cy.contains("Done!");
cy.contains("Successfully moved").then(() => {
expect(stubs.move).to.have.been.calledOnceWith(
"root",
"root",
false,
true,
false
);
});
});
29 changes: 29 additions & 0 deletions __tests__/frontend/destination-selection-api-error.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { stubEndpoints } from "../test-utils/stubEndpoints";

stubEndpoints({
listFolders: (successHandler) => {
setTimeout(() => {
successHandler({ status: "error", type: "DriveAPIError" });
}, 100);
},
listSharedDrives: (successHandler) => {
successHandler({
status: "success",
response: [
{ id: "ID_DRIVE_1", name: "DRIVE 1" },
{ id: "ID_DRIVE_2", name: "DRIVE 2" },
],
});
},
});

it("handles raw errors in source folder selection gracefully", () => {
cy.visit("http://localhost:8080");
cy.contains("Shared drive mover");
cy.contains("Continue").click();
cy.contains("DRIVE 1").click();
cy.contains("Continue").click();
cy.contains("DRIVE 2").dblclick();
cy.contains("An error occurred").should("be.visible");
cy.contains("An error occurred in Google Drive").should("be.visible");
});
29 changes: 29 additions & 0 deletions __tests__/frontend/destination-selection-unhandled-error.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { stubEndpoints } from "../test-utils/stubEndpoints";

stubEndpoints({
listFolders: (_, failureHandler) => {
setTimeout(() => {
failureHandler(new Error("ERROR MESSAGE"));
}, 100);
},
listSharedDrives: (successHandler) => {
successHandler({
status: "success",
response: [
{ id: "ID_DRIVE_1", name: "DRIVE 1" },
{ id: "ID_DRIVE_2", name: "DRIVE 2" },
],
});
},
});

it("handles raw errors in source folder selection gracefully", () => {
cy.visit("http://localhost:8080");
cy.contains("Shared drive mover");
cy.contains("Continue").click();
cy.contains("DRIVE 1").click();
cy.contains("Continue").click();
cy.contains("DRIVE 2").dblclick();
cy.contains("An error occurred").should("be.visible");
cy.contains("ERROR MESSAGE");
});
29 changes: 29 additions & 0 deletions __tests__/frontend/destination-selection-unknown-error.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { stubEndpoints } from "../test-utils/stubEndpoints";

stubEndpoints({
listFolders: (successHandler) => {
setTimeout(() => {
successHandler({ status: "error", type: "unknown" });
}, 100);
},
listSharedDrives: (successHandler) => {
successHandler({
status: "success",
response: [
{ id: "ID_DRIVE_1", name: "DRIVE 1" },
{ id: "ID_DRIVE_2", name: "DRIVE 2" },
],
});
},
});

it("handles raw errors in source folder selection gracefully", () => {
cy.visit("http://localhost:8080");
cy.contains("Shared drive mover");
cy.contains("Continue").click();
cy.contains("DRIVE 1").click();
cy.contains("Continue").click();
cy.contains("DRIVE 2").dblclick();
cy.contains("An error occurred").should("be.visible");
cy.contains("An unknown error occurred").should("be.visible");
});
30 changes: 30 additions & 0 deletions __tests__/frontend/move-api-error.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { stubEndpoints } from "../test-utils/stubEndpoints";

stubEndpoints({
listFolders: (successHandler) => {
successHandler({ status: "success", response: [] });
},
listSharedDrives: (successHandler) => {
successHandler({ status: "success", response: [] });
},
move: (successHandler) => {
setTimeout(() => {
successHandler({ status: "error", type: "DriveAPIError" });
}, 100);
},
});

it("works with an API error", () => {
cy.visit("http://localhost:8080");
cy.contains("Shared drive mover");
cy.contains("Continue").click();
cy.contains("My Drive").click();
cy.contains("Continue").click();
cy.contains("My Drive").click();
cy.contains("Continue").click();
cy.contains('contents of the folder "My Drive" into the folder "My Drive"');
cy.contains("Move").click();
cy.contains("Confirmation");
cy.contains("An error occurred").should("be.visible");
cy.contains("An error occurred in Google Drive").should("be.visible");
});
32 changes: 32 additions & 0 deletions __tests__/frontend/move-folders-equal-error.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { stubEndpoints } from "../test-utils/stubEndpoints";

stubEndpoints({
listFolders: (successHandler) => {
successHandler({ status: "success", response: [] });
},
listSharedDrives: (successHandler) => {
successHandler({ status: "success", response: [] });
},
move: (successHandler) => {
setTimeout(() => {
successHandler({ status: "error", type: "sourceEqualsDestination" });
}, 100);
},
});

it("works with source and destination folders being equal", () => {
cy.visit("http://localhost:8080");
cy.contains("Shared drive mover");
cy.contains("Continue").click();
cy.contains("My Drive").click();
cy.contains("Continue").click();
cy.contains("My Drive").click();
cy.contains("Continue").click();
cy.contains('contents of the folder "My Drive" into the folder "My Drive"');
cy.contains("Move").click();
cy.contains("Confirmation");
cy.contains("An error occurred").should("be.visible");
cy.contains("The source and destination folders must be different").should(
"be.visible"
);
});
Loading