-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #760 from skaut/frontend-e2e-tests
Frontend e2e tests
- Loading branch information
Showing
31 changed files
with
18,402 additions
and
25,297 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
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 |
---|---|---|
|
@@ -61,8 +61,8 @@ jobs: | |
run: | | ||
npm run lint | ||
test: | ||
name: "Test" | ||
backend-test: | ||
name: "Backend test" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout" | ||
|
@@ -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 |
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,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 | ||
); | ||
}); | ||
}); |
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,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 | ||
); | ||
}); | ||
}); |
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,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
29
__tests__/frontend/destination-selection-unhandled-error.cy.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,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
29
__tests__/frontend/destination-selection-unknown-error.cy.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,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"); | ||
}); |
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 { 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"); | ||
}); |
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,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" | ||
); | ||
}); |
Oops, something went wrong.