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

Extend ui tests coverage to include file moving and permanent deletion #1451

Merged
merged 11 commits into from
Aug 19, 2021
1 change: 1 addition & 0 deletions packages/files-ui/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Cypress.Commands.add("safeClick", { prevSubject: "element" }, $element => {
return cy
.wrap($element)
.should("be.visible")
.should("be.enabled")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fyi just a small mod to add even more safety to the safeClick(). I noticed it eradicated some false failures that I saw whilst running one of the new tests hundreds of times.

.pipe(click)
.should($el => expect($el).to.not.be.visible)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const moveItemModal = {
body: () => cy.get("[data-testId=modal-container-modal-move-file]"),
cancelButton: () => cy.get("[data-cy=button-cancel-move]"),
errorLabel: () => cy.get("[data-cy=label-move-file-error-message]"),
folderList: () => cy.get("[data-cy=tree-folder-list]"),
moveButton: () => cy.get("[data-cy=button-move-file]")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const recoverItemModal = {
body: () => cy.get("[data-testId=modal-container-modal-recover-file]"),
cancelButton: () => cy.get("[data-cy=button-cancel-recovery]"),
errorLabel: () => cy.get("[data-cy=label-move-file-error-message]"),
folderList: () => cy.get("[data-cy=tree-folder-list]"),
recoverButton: () => cy.get("[data-cy=button-recover-file]")
}
92 changes: 83 additions & 9 deletions packages/files-ui/cypress/tests/file-management-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import "cypress-pipe"
import { createFolderModal } from "../support/page-objects/modals/createFolderModal"
import { deleteFileModal } from "../support/page-objects/modals/deleteFileModal"
import { fileUploadModal } from "../support/page-objects/modals/fileUploadModal"
import { recoverFileModal } from "../support/page-objects/modals/recoverFileModal"
import { moveItemModal } from "../support/page-objects/modals/moveItemModal"
import { recoverItemModal } from "../support/page-objects/modals/recoverItemModal"

describe("File management", () => {

Expand Down Expand Up @@ -41,6 +42,55 @@ describe("File management", () => {
fileUploadModal.body().should("not.exist")
})

it("can move a file in and out of a folder", () => {
cy.web3Login({ clearCSFBucket: true })

// upload a file and save it's name as a cypress alias
homePage.uploadFile("../fixtures/uploadedFiles/text-file.txt")
homePage.fileItemRow().should("have.length", 1)
homePage.fileItemName().invoke("text").as("fileName")

// create a folder
homePage.createFolder(folderName)
homePage.fileItemRow().should("have.length", 2)

cy.get("@fileName").then(($fileName) => {
// select the file and move it to the folder
homePage.fileItemName().contains(`${$fileName}`)
.should("be.visible")
.click()
homePage.moveSelectedButton().click()
moveItemModal.folderList().contains("Testing").click()
moveItemModal.moveButton().safeClick()

// ensure there is only the folder in the Home directory
homePage.fileItemRow().should("have.length", 1)
homePage.fileItemName().should("contain.text", folderName)

// open the folder and confirm the file was moved inside
homePage.fileItemName().contains(folderName)
.should("be.visible")
.dblclick()
homePage.fileItemRow().should("have.length", 1)
homePage.fileItemName().should("contain.text", $fileName)

// move the file back to the home root
homePage.fileItemName().contains(`${$fileName}`)
.should("be.visible")
.click()
homePage.moveSelectedButton().click()
moveItemModal.folderList().contains("Home").click()
moveItemModal.moveButton().safeClick()

// ensure the home root now has the folder and file
navigationMenu.homeNavButton().click()
homePage.fileItemRow().should("have.length", 2)
homePage.fileItemName().should("contain.text", folderName)
homePage.fileItemName().should("contain.text", $fileName)
})
})


it("can add/remove multiple files and upload", () => {
cy.web3Login({ clearCSFBucket: true })

Expand Down Expand Up @@ -100,7 +150,7 @@ describe("File management", () => {
homePage.fileRenameInput().should("have.value", newName)
})

it("can delete and recover a file", () => {
it("can delete, recover and permanently delete a file", () => {
cy.web3Login({ clearCSFBucket: true, clearTrashBucket: true })

// upload a file
Expand Down Expand Up @@ -133,9 +183,9 @@ describe("File management", () => {
// recover the file via the menu option
binPage.fileItemKebabButton().first().click()
binPage.recoverMenuOption().click()
recoverFileModal.folderList().should("exist")
recoverFileModal.folderList().contains("Home").click()
recoverFileModal.recoverButton().click()
recoverItemModal.folderList().should("exist")
recoverItemModal.folderList().contains("Home").click()
recoverItemModal.recoverButton().click()
binPage.fileItemRow().should("not.exist")

// ensure recovered file is correct
Expand All @@ -149,9 +199,21 @@ describe("File management", () => {
cy.get("@recoveredFile").then(($recoveredFile) => {
cy.get("@binFile").should("equals", $recoveredFile)
})

// permanently delete the file
homePage.fileItemKebabButton().first().click()
homePage.deleteMenuOption().click().pause()
deleteFileModal.confirmButton().safeClick()
navigationMenu.binNavButton().click()
binPage.fileItemKebabButton().first().click()
binPage.deleteMenuOption().click()
deleteFileModal.confirmButton().safeClick()
binPage.fileItemRow().should("not.exist")
navigationMenu.homeNavButton().click()
homePage.fileItemRow().should("not.exist")
})

it("can delete and recover a folder", () => {
it("can delete, recover and permanently delete a folder", () => {
cy.web3Login({ clearCSFBucket: true, clearTrashBucket: true })

// create a folder
Expand All @@ -174,15 +236,27 @@ describe("File management", () => {
// recover folder via the menu option
binPage.fileItemKebabButton().first().click()
binPage.recoverMenuOption().click()
recoverFileModal.folderList().should("exist")
recoverFileModal.folderList().contains("Home").click()
recoverFileModal.recoverButton().click()
recoverItemModal.folderList().should("exist")
recoverItemModal.folderList().contains("Home").click()
recoverItemModal.recoverButton().click()
binPage.fileItemRow().should("not.exist")

// ensure recovered folder is correct
navigationMenu.homeNavButton().click()
binPage.fileItemRow().should("have.length", 1)
homePage.fileItemName().should("have.text", folderName)

// permanently delete the folder
homePage.fileItemKebabButton().first().click()
homePage.deleteMenuOption().click()
deleteFileModal.confirmButton().safeClick()
navigationMenu.binNavButton().click()
binPage.fileItemKebabButton().first().click()
binPage.deleteMenuOption().click()
deleteFileModal.confirmButton().safeClick()
binPage.fileItemRow().should("not.exist")
navigationMenu.homeNavButton().click()
homePage.fileItemRow().should("not.exist")
})

it("cannot create a folder with an invalid name", () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/files-ui/src/locales/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ msgstr ""
"POT-Creation-Date: 2021-04-23 11:05+0200\n"
"PO-Revision-Date: 2021-08-06 03:33+0000\n"
"Last-Translator: J. Lavoie <j.lavoie@net-c.ca>\n"
"Language-Team: French <https://hosted.weblate.org/projects/chainsafe-files/"
"chainsafe-files-user-interface/fr/>\n"
"Language-Team: French <https://hosted.weblate.org/projects/chainsafe-files/chainsafe-files-user-interface/fr/>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
Expand Down