-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added e2e tests for full text search
- Loading branch information
Showing
9 changed files
with
242 additions
and
9 deletions.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
tests/e2e/cucumber/features/smoke/fullTextSearch.ocis.feature
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,102 @@ | ||
Feature: Search | ||
As a user | ||
I want to search for resources | ||
So that I can find them quickly | ||
|
||
Background: | ||
Given "Admin" creates following users using API | ||
| id | | ||
| Alice | | ||
| Brian | | ||
And "Admin" sets the default folder for received shares to "Shares" | ||
And "Admin" disables share auto accepting | ||
And "Admin" assigns following roles to the users using API | ||
| id | role | | ||
| Brian | Space Admin | | ||
|
||
And "Alice" logs in | ||
And "Alice" creates the following folder in personal space using API | ||
| name | | ||
| folderToShare | | ||
And "Alice" uploads the following local file into personal space using API | ||
| localFile | to | | ||
| filesForUpload/textfile.txt | folderToShare/fileToShare.txt | | ||
And "Alice" shares the following resource using API | ||
| resource | recipient | type | role | | ||
| folderToShare | Brian | user | Can edit | | ||
|
||
And "Brian" logs in | ||
And "Brian" accepts the following share using API | ||
| name | | ||
| folderToShare | | ||
And "Brian" creates the following folder in personal space using API | ||
| name | | ||
| testFolder | | ||
And "Brian" uploads the following local file into personal space using API | ||
| localFile | to | | ||
| filesForUpload/textfile.txt | textfile.txt | | ||
| filesForUpload/textfile.txt | fileWithTag.txt | | ||
| filesForUpload/textfile.txt | withTag.txt | | ||
| filesForUpload/textfile.txt | testFolder/innerTextfile.txt | | ||
|
||
And "Brian" creates the following project spaces using API | ||
| name | id | | ||
| FullTextSearch | fulltextsearch.1 | | ||
And "Brian" creates the following folder in space "FullTextSearch" using API | ||
| name | | ||
| spaceFolder | | ||
And "Brian" creates the following file in space "FullTextSearch" using API | ||
| name | content | | ||
| spaceFolder/spaceTextfile.txt | This is test file. | | ||
|
||
And "Brian" opens the "files" app | ||
# And "Brian" adds the following tags for the following resources using API | ||
# | resource | tags | | ||
# | fileWithTag.txt | tag 1 | | ||
# | withTag.txt | tag 1 | | ||
And "Brian" adds the following tags for the following resources using the sidebar panel | ||
| resource | tags | | ||
| fileWithTag.txt | tag 1 | | ||
| withTag.txt | tag 1 | | ||
|
||
Scenario: Search for content of file | ||
And "Brian" opens the "files" app | ||
|
||
When "Brian" searches "" using the global search bar | ||
Then "Brian" should see the message "Search for files" on the webUI | ||
|
||
When "Brian" selects tag "tag 1" from the search result filter chip | ||
Then following resources should be displayed in the files list for user "Brian" | ||
| resource | | ||
| fileWithTag.txt | | ||
| withTag.txt | | ||
|
||
When "Brian" searches "file" using the global search bar | ||
Then following resources should be displayed in the files list for user "Brian" | ||
| resource | | ||
| fileWithTag.txt | | ||
|
||
When "Brian" clears tag filter | ||
Then following resources should be displayed in the files list for user "Brian" | ||
| resource | | ||
| textfile.txt | | ||
| fileWithTag.txt | | ||
| testFolder/innerTextfile.txt | | ||
| fileToShare.txt | | ||
| spaceFolder/spaceTextfile.txt | | ||
|
||
When "Brian" enables the option to search in file content | ||
And "Brian" searches "Cheers" using the global search bar | ||
Then following resources should be displayed in the files list for user "Brian" | ||
| resource | | ||
| textfile.txt | | ||
| testFolder/innerTextfile.txt | | ||
| fileToShare.txt | | ||
| fileWithTag.txt | | ||
| withTag.txt | | ||
|
||
When "Brian" opens the following file in texteditor | ||
| resource | | ||
| textfile.txt | | ||
Then "Brian" should see the message "No results found" on the webUI | ||
And "Brian" logs out |
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
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,43 @@ | ||
import { When, Then } from "@cucumber/cucumber"; | ||
import { World } from "../../environment"; | ||
import { objects } from '../../../support' | ||
import { expect } from '@playwright/test' | ||
|
||
When( | ||
'{string} searches {string} using the global search bar', | ||
async function (this: World, stepUser: string, keyword: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const searchObject = new objects.applicationFiles.Search({ page }) | ||
await searchObject.fullTextSearch({ keyword }) | ||
} | ||
) | ||
|
||
Then( | ||
'{string} should see the message {string} on the webUI', | ||
async function (this: World, stepUser: string, message: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const searchObject = new objects.applicationFiles.Search({ page }) | ||
const actualMessage = await searchObject.getSearchResultMessage() | ||
expect(actualMessage).toBe(message); | ||
} | ||
) | ||
|
||
When('{string} selects tag {string} from the search result filter chip', async function (this: World, stepUser: string, tag: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const searchObject = new objects.applicationFiles.Search({ page }) | ||
await searchObject.selectTagFilter({ tag }) | ||
}); | ||
|
||
When('{string} clears tag filter', async function (this: World, stepUser: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const searchObject = new objects.applicationFiles.Search({ page }) | ||
await searchObject.clearTagFilter() | ||
}); | ||
|
||
When(/^"([^"]*)" (enable|disable)s the option to search in file content?$/, async function (this: World, stepUser: string, enableOrDisable: string): Promise<void> { | ||
const { page } = this.actorsEnvironment.getActor({ key: stepUser }) | ||
const searchObject = new objects.applicationFiles.Search({ page }) | ||
await searchObject.toggleSearchInFileContent({ enableOrDisable }) | ||
}); | ||
|
||
|
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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {Page} from 'playwright' | ||
import util from 'util' | ||
|
||
const globalSearchInputSelector = '.oc-search-input' | ||
const searchResultMessageSelector = '//p[@class="oc-text-muted"]' | ||
const selectTagDropdownSelector = '.files-search-filter-tags' | ||
const tagFilterChipSelector = '//button[contains(@data-test-value,"%s")]' | ||
const clearTagFilterSelector = '//div[contains(@class,"files-search-filter-tags")]//button[contains(@class,"oc-filter-chip-clear")]' | ||
const enableSearchInFileContentSelector = '//div[contains(@class,"files-search-filter-full-text")]//button[contains(@class,"oc-filter-chip-button")]' | ||
const disableSearchInFileContentSelector = '//div[contains(@class,"files-search-filter-full-text")]//button[contains(@class,"oc-filter-chip-clear")]' | ||
export interface fullTextSearchArgs { | ||
keyword: string | ||
page: Page | ||
} | ||
export const fullTextSearch = async ( | ||
args: fullTextSearchArgs | ||
): Promise<void> => { | ||
const { page, keyword } = args | ||
await page.locator(globalSearchInputSelector).fill(keyword) | ||
await page.keyboard.press('Enter') | ||
} | ||
|
||
export const getSearchResultMessage = async ({ page }): Promise<string> => { | ||
return await page.locator(searchResultMessageSelector).innerText() | ||
} | ||
|
||
export const selectTagFilter = async ({ tag, page }): Promise<void> => { | ||
await page.locator(selectTagDropdownSelector).click() | ||
await page.locator(util.format(tagFilterChipSelector, tag)).click() | ||
} | ||
|
||
export const clearTagFilter = async ({ page }): Promise<void> => { | ||
await page.locator(clearTagFilterSelector).click() | ||
} | ||
|
||
export const toggleSearchInFileContent = async ({ enableOrDisable, page }): Promise<void> => { | ||
enableOrDisable === 'enable' ? await page.locator(enableSearchInFileContentSelector).click() : await page.locator(disableSearchInFileContentSelector).click() | ||
} |
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 {Page} from 'playwright' | ||
import * as po from "../search/actions"; | ||
|
||
export class Search { | ||
#page: Page | ||
|
||
constructor({page}: { page: Page }) { | ||
this.#page = page | ||
} | ||
|
||
async fullTextSearch(args: Omit<po.fullTextSearchArgs, 'page'>): Promise<void> { | ||
await po.fullTextSearch({...args, page: this.#page}) | ||
} | ||
|
||
async getSearchResultMessage(): Promise<string> { | ||
return await po.getSearchResultMessage({page: this.#page}) | ||
} | ||
|
||
async selectTagFilter({tag: string}): Promise<void> { | ||
await po.selectTagFilter({tag: string, page: this.#page}) | ||
} | ||
|
||
async clearTagFilter(): Promise<void> { | ||
await po.clearTagFilter({page: this.#page}) | ||
} | ||
|
||
async toggleSearchInFileContent({enableOrDisable: string}): Promise<void> { | ||
await po.toggleSearchInFileContent({ enableOrDisable: string, page: this.#page}) | ||
} | ||
} |