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

add ui tests for search #1479

Merged
merged 14 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from 10 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
5 changes: 4 additions & 1 deletion packages/common-components/src/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export interface SearchBarProps {
loaderType?: LOADER
size?: "large" | "medium" | "small"
onChange: (e: ChangeEvent<HTMLInputElement>) => void
testId?: string
}

const SearchBar: React.FC<SearchBarProps> = ({
Expand All @@ -205,7 +206,8 @@ const SearchBar: React.FC<SearchBarProps> = ({
loaderType = LOADER.PulseLoader,
size = "large",
name,
onChange
onChange,
testId
}: SearchBarProps) => {
const classes = useStyles()
const spinnerSize = size === "large" ? 12 : size === "medium" ? 8 : 6
Expand All @@ -225,6 +227,7 @@ const SearchBar: React.FC<SearchBarProps> = ({
value={value}
placeholder={placeholder}
onChange={onChange}
data-testid={testId}
/>
<div className={clsx(classes.standardIcon, size, "right")}>
<Spinner
Expand Down
2 changes: 1 addition & 1 deletion packages/files-ui/cypress/fixtures/filesTestData.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const folderName = "Testing"
export const folderName = "Group"
export const folderPath = `/${folderName}`
1 change: 1 addition & 0 deletions packages/files-ui/cypress/support/page-objects/basePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export const basePage = {
appHeaderLabel: () => cy.get("[data-cy=files-app-header]", { timeout: 20000 }),
searchInput: () => cy.get("[data-testid=input_searchbar]"),
asnaith marked this conversation as resolved.
Show resolved Hide resolved
signOutDropdown: () => cy.get("[data-testid=menu-title-sign-out]"),
signOutMenuOption: () => cy.get("[data-cy=menu-sign-out]"),
// Mobile view only element
Expand Down
11 changes: 4 additions & 7 deletions packages/files-ui/cypress/support/page-objects/binPage.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { basePage } from "./basePage"
import { fileBrowser } from "./fileBrowser"

export const binPage = {
...basePage,
...fileBrowser,

// main file browser elements (bin view only)
// bin page specific file browser elements
recoverSelectedButton: () => cy.get("[data-testId=button-recover-selected-file]"),
deleteSelectedButton: () => cy.get("[data-testId=button-delete-selected-file]"),

// file browser row elements
fileItemRow: () => cy.get("[data-cy=file-item-row]", { timeout: 20000 }),
fileItemName: () => cy.get("[data-cy=file-item-name]"),
fileItemKebabButton: () => cy.get("[data-testid=menu-title-fileDropdown]"),

// menu elements (bin view only)
// kebab menu elements
recoverMenuOption: () => cy.get("[data-cy=menu-recover]"),
deleteMenuOption: () => cy.get("[data-cy=menu-delete]")
}
8 changes: 8 additions & 0 deletions packages/files-ui/cypress/support/page-objects/fileBrowser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const fileBrowser = {
fileItemKebabButton: () => cy.get("[data-testid=menu-title-fileDropdown]"),
fileItemName: () => cy.get("[data-cy=file-item-name]"),
fileItemRow: () => cy.get("[data-cy=file-item-row]", { timeout: 20000 }),
fileTable: () => cy.get("[data-testid=table-home]"),
folderBreadcrumb: () => cy.get("[data-cy=navigation-folder-breadcrumb]"),
noDataStateInfo: () => cy.get("[data-cy=data-state-no-files]")
}
12 changes: 4 additions & 8 deletions packages/files-ui/cypress/support/page-objects/homePage.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
import { basePage } from "./basePage"
import { fileBrowser } from "./fileBrowser"
import { fileUploadModal } from "./modals/fileUploadModal"

export const homePage = {
...basePage,
...fileBrowser,

// main file browser elements
// home page specific file browser elements
newFolderButton: () => cy.get("[data-cy=button-new-folder]"),
uploadButton: () => cy.get("[data-cy=button-upload-file]"),
moveSelectedButton: () => cy.get("[data-testId=button-move-selected-file]"),
deleteSelectedButton: () => cy.get("[data-testId=button-delete-selected-file]"),
uploadStatusToast: () => cy.get("[data-cy=upload-status-toast-message]", { timeout: 10000 }),

// file browser row elements
fileItemRow: () => cy.get("[data-cy=file-item-row]", { timeout: 20000 }),
fileTable: () => cy.get("[data-testid=table-home]"),
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=menu-title-fileDropdown]"),

// menu elements
// kebab menu elements
previewMenuOption: () => cy.get("[data-cy=menu-preview]"),
downloadMenuOption: () => cy.get("[data-cy=menu-download]"),
infoMenuOption: () => cy.get("[data-cy=menu-info]"),
Expand Down
10 changes: 10 additions & 0 deletions packages/files-ui/cypress/support/page-objects/searchPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { basePage } from "./basePage"
import { fileBrowser } from "./fileBrowser"

export const searchPage = {
...basePage,
...fileBrowser,

// kebab menu elements
viewFolderMenuOption: () => cy.get("[data-cy=menu-view-folder]")
}
2 changes: 1 addition & 1 deletion packages/files-ui/cypress/tests/file-management-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe("File management", () => {
.should("be.visible")
.click()
homePage.moveSelectedButton().click()
moveItemModal.folderList().contains("Testing").click()
moveItemModal.folderList().contains(`${folderName}`).click()
Tbaut marked this conversation as resolved.
Show resolved Hide resolved
moveItemModal.moveButton().safeClick()

// ensure there is only the folder in the Home directory
Expand Down
67 changes: 67 additions & 0 deletions packages/files-ui/cypress/tests/search-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { homePage } from "../support/page-objects/homePage"
import { folderName, folderPath } from "../fixtures/filesTestData"
import { searchPage } from "../support/page-objects/searchPage"
import { apiTestHelper } from "../support/utils/apiTestHelper"

describe("Search", () => {

context("desktop", () => {

it("can search for files and folders via name", () => {
cy.web3Login({ clearCSFBucket: true, clearTrashBucket: true })

// add file and folders
homePage.uploadFile("../fixtures/uploadedFiles/logo.png")
homePage.fileItemName().invoke("text").as("fileName")
apiTestHelper.createFolder(`/${folderName}A`)
asnaith marked this conversation as resolved.
Show resolved Hide resolved
apiTestHelper.createFolder(`/${folderName}B`)

// search for a specific folder, ensure 1 result is found
homePage.searchInput().type(`${folderName}A{enter}`)
searchPage.fileItemRow().should("be.visible")
.should("have.length", 1)
asnaith marked this conversation as resolved.
Show resolved Hide resolved
searchPage.fileItemName().should("contain.text", `${folderName}A`)
cy.go("back")

// perform a loose search for folders, ensure that 2 results are found
homePage.searchInput().type(`{selectall}{del}${folderName}{enter}`)
searchPage.fileItemRow().should("be.visible")
.should("have.length", 2)
asnaith marked this conversation as resolved.
Show resolved Hide resolved
searchPage.fileItemName().should("contain.text", `${folderName}A`)
searchPage.fileItemName().should("contain.text", `${folderName}B`)
cy.go("back")

// search for a specific file, ensure only 1 result is found
cy.get("@fileName").then(($fileName) => {
homePage.searchInput().type(`{selectall}{del}${$fileName}{enter}`)
searchPage.fileItemRow().should("be.visible")
.should("have.length", 1)
asnaith marked this conversation as resolved.
Show resolved Hide resolved
searchPage.fileItemName().should("contain.text", `${$fileName}`)
asnaith marked this conversation as resolved.
Show resolved Hide resolved
})
})

it("can see no data state when no search results are found", () => {
cy.web3Login({ clearCSFBucket: true, clearTrashBucket: true })
homePage.searchInput().type(`{selectall}{del}${folderName}C{enter}`)
searchPage.appHeaderLabel().should("have.text", "Search results")
searchPage.noDataStateInfo().should("be.visible")
asnaith marked this conversation as resolved.
Show resolved Hide resolved
.should("exist")
})

it("can view folder content from search result", () => {
cy.web3Login({ clearCSFBucket: true, clearTrashBucket: true })
apiTestHelper.createFolder(folderPath)
homePage.searchInput().type(`${folderName}{enter}`)

// view contents via menu option
searchPage.fileItemKebabButton().click()
searchPage.viewFolderMenuOption().click()
searchPage.folderBreadcrumb().should("have.text", `${folderName}`)
asnaith marked this conversation as resolved.
Show resolved Hide resolved
cy.go("back")

// view contents via double click
searchPage.fileItemRow().contains(`${folderName}`).dblclick()
searchPage.folderBreadcrumb().should("have.text", `${folderName}`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
searchPage.fileItemRow().contains(`${folderName}`).dblclick()
searchPage.folderBreadcrumb().should("have.text", `${folderName}`)
searchPage.fileItemRow().contains(folderName).dblclick()
searchPage.folderBreadcrumb().should("have.text", folderName)

})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ const FileSystemItem = ({
contents: (
<>
<EyeSvg className={classes.menuIcon} />
<span data-cy="view-folder">
<span data-cy="menu-view-folder">
<Trans>View folder</Trans>
</span>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,10 @@ const FilesList = ({ isShared = false }: Props) => {
items={sourceFiles}
previewType={browserView}
/>
<div className={classes.breadCrumbContainer}>
<div
className={classes.breadCrumbContainer}
data-cy="navigation-folder-breadcrumb"
>
{crumbs && moduleRootPath && (
<Breadcrumb
crumbs={crumbs}
Expand Down Expand Up @@ -827,6 +830,7 @@ const FilesList = ({ isShared = false }: Props) => {
classes.noFiles,
loadingCurrentPath && classes.fadeOutLoading
)}
data-cy="data-state-no-files"
>
<EmptySvg />
<Typography variant="h4"
Expand Down
1 change: 1 addition & 0 deletions packages/files-ui/src/Components/Modules/SearchModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ const SearchModule: React.FC<ISearchModule> = ({
onSearchChange(e.target.value)
}
placeholder={t`Search…`}
testId = "input_searchbar"
asnaith marked this conversation as resolved.
Show resolved Hide resolved
/>
</form>
{searchQuery && searchResults?.query ? (
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-26 18: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