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

Update file management ui tests #1113

Merged
merged 19 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
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
2 changes: 1 addition & 1 deletion packages/common-components/src/FileInput/FileInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const FileInput = ({
>
<span className={classes.itemText}>{file.name}</span>
<Button
data-testid={`file-list-close-button-${testId}`}
data-testid={`file-list-remove-button-${testId}`}
className={clsx(classes.crossIcon, classNames?.closeIcon)}
type="button"
onClick={(e) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/common-components/src/MenuDropdown/MenuDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const MenuDropdown = ({
className={clsx(classes.root, className)}
>
<section
data-testid={`drowpdown-title-${testId}`}
data-testid={`dropdown-title-${testId}`}
onClick={() => setOpen(!open)}
className={clsx(classes.title, classNames?.title, {
["open"]: open
Expand Down Expand Up @@ -241,7 +241,7 @@ const MenuDropdown = ({
>
{menuItems.map((item: IMenuItem, index: number) => (
<div
data-testid={`drowpdown-item-${testId}`}
data-testid={`dropdown-item-${testId}`}
key={`menu-${index}`}
className={clsx(classes.item, classNames?.item)}
onClick={() => {
Expand Down
1 change: 1 addition & 0 deletions packages/files-ui/cypress.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"integrationFolder": "cypress/tests",
"pageLoadTimeout": 10000,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm are you sure, this is effectively reducing the page timeout afaiu, the default is 60s, (60000) according to https://docs.cypress.io/guides/references/configuration#Timeouts

Copy link
Member Author

Choose a reason for hiding this comment

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

@Tbaut Oh good catch, thank you. I'd misread.

After making the change I ran the test 100 times and didn't see a page load error so I thought that had solved the issue but I'd actually lowered it and got lucky.

I've reverted this change now. I think it's fine to keep the timeout as the default, if it's longer than 60 seconds it is probably a genuine problem and not a test related issue.

"video": false
}
41 changes: 39 additions & 2 deletions packages/files-ui/cypress/support/page-objects/homePage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,44 @@
import { basePage } from "./basePage"

export const homePage = {
...basePage
// TODO: Andrew - add declarations for unique elements #1085
...basePage,

// main browser elements
uploadButton: () => cy.get("[data-cy=upload-modal-button]"),
uploadFileForm: () => cy.get("[data-cy=upload-file-form] input"),

// file browser row elements
fileItemRow: () => cy.get("[data-cy=file-item-row]", { timeout: 20000 }),
fileItemName: () => cy.get("[data-cy=file-item-name]"),
fileRenameInput: () => cy.get("[data-cy=rename-form] input"),
fileRenameSubmitButton: () => cy.get("[data-cy=rename-submit-button]"),
fileRenameErrorLabel: () => cy.get("[data-cy=rename-form] span.minimal.error"),
fileItemKebabButton: () => cy.get("[data-testid=dropdown-title-fileDropdown]"),

// upload modal elements
startUploadButton: () => cy.get("[data-cy=upload-ok-button]"),
uploadCancelButton: () => cy.get("[data-cy=upload-cancel-button"),
fileListRemoveButton: () => cy.get("[data-testid=file-list-remove-button-fileUpload]"),
fileUploadList: () => cy.get("[data-testid=file-list-fileUpload] li"),
fileUploadDropzone : () => cy.get("[data-testid=file-input-dropzone-fileUpload]"),

// menu elements
previewMenuOption: () => cy.get("[data-cy=menu-preview]"),
downloadMenuOption: () => cy.get("[data-cy=menu-download]"),
infoMenuOption: () => cy.get("[data-cy=menu-info]"),
renameMenuOption: () => cy.get("[data-cy=menu-rename]"),
moveMenuOption: () => cy.get("[data-cy=menu-move]"),
deleteMenuOption: () => cy.get("[data-cy=menu-delete]"),

// helpers and convenience functions
uploadFile(filePath: string) {
this.uploadButton().click()
this.uploadFileForm().attachFile(filePath)
this.fileUploadList().should("have.length", 1)
this.startUploadButton().click()
this.uploadFileForm().should("not.exist")
}
}



asnaith marked this conversation as resolved.
Show resolved Hide resolved
87 changes: 52 additions & 35 deletions packages/files-ui/cypress/tests/file-management-spec.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,70 @@
import { homePage } from "../support/page-objects/homePage"

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

context("desktop", () => {

it("can add files and cancel", () => {
cy.web3Login()
cy.get("[data-cy=upload-modal-button]").click()
cy.get("[data-cy=upload-file-form] input").attachFile("../fixtures/uploadedFiles/text-file.txt")
cy.get("[data-testid=file-list-fileUpload] li").should("have.length", 1)
cy.get("[data-cy=upload-cancel-button").click()
cy.get("[data-cy=files-app-header").should("be.visible")

// upload a file and see it in the file list
homePage.uploadButton().click()
homePage.uploadFileForm().attachFile("../fixtures/uploadedFiles/text-file.txt")
homePage.fileUploadList().should("have.length", 1)

// cancel and ensure that the upload modal is dismissed
homePage.uploadCancelButton().click()
homePage.uploadCancelButton().should("not.exist")
homePage.uploadFileForm().should("not.exist")
})

it("can add/remove files and upload", () => {
it("can add/remove multiple files and upload", () => {
cy.web3Login({ clearCSFBucket: true })
cy.get("[data-cy=upload-modal-button]").click()
cy.get("[data-cy=upload-file-form] input").attachFile("../fixtures/uploadedFiles/text-file.txt")
cy.get("[data-testid=file-list-fileUpload] li").should("have.length", 1)
cy.get("[data-cy=upload-file-form] input").attachFile("../fixtures/uploadedFiles/logo.png")
cy.get("[data-testid=file-list-fileUpload] li").should("have.length", 2)
cy.get("[data-testid=file-list-close-button-fileUpload]").first().click()
cy.get("[data-testid=file-list-fileUpload] li").should("have.length", 1)
cy.get("[data-cy=upload-file-form] input").attachFile("../fixtures/uploadedFiles/text-file.txt")
cy.get("[data-testid=file-list-fileUpload] li").should("have.length", 2)
cy.get("[data-cy=upload-ok-button]").click()
cy.get("[data-cy=files-app-header]").should("be.visible")
cy.get("[data-cy=file-item-row]").should("have.length", 2)

// attach 2 files to the file list
homePage.uploadButton().click()
homePage.uploadFileForm().attachFile("../fixtures/uploadedFiles/text-file.txt")
homePage.fileUploadList().should("have.length", 1)
homePage.uploadFileForm().attachFile("../fixtures/uploadedFiles/logo.png")
homePage.fileUploadList().should("have.length", 2)

// remove 1 file from the list and ensure 1 remains
homePage.fileListRemoveButton().first().click()
homePage.fileUploadList().should("have.length", 1)

// attach an additional file to the file list and upload
homePage.uploadFileForm().attachFile("../fixtures/uploadedFiles/text-file.txt")
homePage.fileUploadList().should("have.length", 2)
homePage.startUploadButton().click()
homePage.uploadFileForm().should("not.exist")
homePage.fileItemRow().should("have.length", 2)
})

it("can rename a file with error handling", () => {
const newName = "awesome new name"

cy.web3Login({ clearCSFBucket: true })
cy.get("[data-cy=upload-modal-button]").click()
cy.get("[data-cy=upload-file-form] input").attachFile("../fixtures/uploadedFiles/text-file.txt")
cy.get("[data-cy=upload-ok-button]").click()
cy.get("[data-cy=files-app-header]").should("be.visible")

cy.get("[data-testid=drowpdown-title-fileDropdown]").first().click()
cy.get("[data-cy=menu-rename]").click()
cy.get("[data-cy=rename-form] input").type("{selectall}{del}")
cy.get("[data-cy=rename-form] span.minimal.error").should("be.visible")
cy.get("[data-cy=rename-form] input").type(`${newName}{enter}`)
cy.get("[data-cy=file-item-name]").contains(newName)

cy.get("[data-testid=drowpdown-title-fileDropdown]").first().click()
cy.get("[data-cy=menu-rename]").click()
cy.get("[data-cy=rename-form] input").type("{selectall}{del}{esc}")
cy.get("[data-cy=rename-form] input").should("not.exist")
cy.get("[data-cy=file-item-name]").contains(newName)

// upload a file
homePage.uploadFile("../fixtures/uploadedFiles/text-file.txt")
homePage.fileItemRow().should("have.length", 1)

// ensure an error is displayed if the edited name is blank
homePage.fileItemKebabButton().first().click()
homePage.renameMenuOption().click()
homePage.fileRenameInput().type("{selectall}{del}")
homePage.fileRenameErrorLabel().should("be.visible")

// rename a file
homePage.fileRenameInput().type(`${newName}{enter}`)
homePage.fileItemName().contains(newName)

// ensure the original name persists if the rename submission is blank
homePage.fileItemKebabButton().first().click()
homePage.renameMenuOption().click()
homePage.fileRenameInput().type("{selectall}{del}{esc}")
homePage.fileRenameInput().should("not.exist")
homePage.fileItemName().contains(newName)
})
})
})
2 changes: 1 addition & 1 deletion packages/files-ui/cypress/tests/main-navigation-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("Main Navigation", () => {

it("can see data storage summary info", () => {
navigationMenu.spaceUsedLabel().should("contain.text", "of 20 GB used")
navigationMenu.spaceUsedProgressBar().should("be.visible").should
navigationMenu.spaceUsedProgressBar().should("be.visible")
})

it.skip("can navigate to block survey via send feedback button", () => {
Expand Down