Skip to content

Commit

Permalink
WEBUI-1392: Update Functional Test Feature: Search
Browse files Browse the repository at this point in the history
  • Loading branch information
rahuljain-dev committed Dec 19, 2023
1 parent be3f75f commit 24d8ea0
Show file tree
Hide file tree
Showing 13 changed files with 374 additions and 239 deletions.
22 changes: 11 additions & 11 deletions ftest/features/search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ Feature: Search
| coverage | Europe/Portugal | 5 |
#| size | Between 100 KB and 1 MB | 1 | disabled until scroll works in shadow dom

Scenario: Default Saved Search
When I click the "defaultSearch" button
And I perform a coverage search for Europe/France on defaultSearch
Then I edit the results columns to show "Subjects"
And I save my search as "Local Search"
And I share my "defaultSearch" search with JSmith
When I logout
And I login as "JSmith"
And I click the "defaultSearch" button
Then I can view my saved search "Local Search" on "defaultSearch"

Scenario: Navigate to Default Saved Search by ID
Given I have a saved search named "Portugal", for the "default_search" page provider, with the following parameters
| key | value |
Expand Down Expand Up @@ -109,3 +98,14 @@ Feature: Search
When I click the "assetsSearch" button
And I perform a fulltext search for picture on assetsSearch
Then I can see 3 search results

Scenario: Default Saved Search
When I click the "defaultSearch" button
And I perform a coverage search for Europe/France on defaultSearch
Then I edit the results columns to show "Subjects"
And I save my search as "Local Search"
And I share my "defaultSearch" search with JSmith
When I logout
And I login as "JSmith"
And I click the "defaultSearch" button
Then I can view my saved search "Local Search" on "defaultSearch"
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Then('I can navigate to {word} pill', async function(pill) {
const ele = await this.ui.browser.el.$(`nuxeo-page-item[name='${pill.toLowerCase()}']`);
await ele.waitForVisible();
await ele.click();
await this.ui.browser.waitForVisible(`#nxContent [name='${pill.toLowerCase()}']`);
const pillTab = await this.ui.browser.el.$(`#nxContent [name='${pill.toLowerCase()}']`);
await pillTab.waitForVisible();
});

Then('I cannot see to {word} pill', async function(pill) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { Then, When } from '../../node_modules/@cucumber/cucumber';
let currentDocType;
let selectedTabName;

When('I click the Create Document button', function() {
this.ui.createButton.waitForVisible();
this.ui.createButton.click();
When('I click the Create Document button', async function() {
const button = await this.ui.createButton;
await button.waitForVisible();
await button.click();
});

Then('I click the Create button to finish the import', function() {
Expand Down Expand Up @@ -44,29 +45,37 @@ Then('I upload the following files on the tab content page:', function(table) {
return docs.reduce((current, next) => current.then(next), Promise.resolve([]));
});

When('I select {word} from the Document Type menu', function(docType) {
this.ui.createDialog.waitForVisible();
const button = this.ui.createDialog.documentCreate.getDoctypeButton(docType);
button.waitForVisible();
button.click();
When('I select {word} from the Document Type menu', async function(docType) {
const dialog = await this.ui.createDialog;
await dialog.waitForVisible();
const button = await this.ui.createDialog.documentCreate.getDoctypeButton(docType);
await button.waitForVisible();
await button.click();
currentDocType = docType;
});

When('I create a document with the following properties:', function(table) {
this.ui.createDialog.documentCreate.waitForVisible();
this.ui.createDialog.documentCreate.layout(currentDocType).fillMultipleValues(table);
this.ui.createDialog.documentCreate.layout(currentDocType).getField('title').should.not.be.empty;
const title = this.ui.createDialog.documentCreate.layout(currentDocType).getFieldValue('title');
this.ui.createDialog.createButton.waitForVisible();
this.ui.createDialog.createButton.click();
this.ui.browser.waitForNotVisible('iron-overlay-backdrop');
this.ui.browser.hasTitle(title).should.be.true;
When('I create a document with the following properties:', async function(table) {
await this.ui.createDialog.documentCreate.waitForVisible();
const layout = await this.ui.createDialog.documentCreate.layout(currentDocType);
await layout.fillMultipleValues(table);
const field = await layout.getField('title');
field.should.not.be.empty;
const title = await layout.getFieldValue('title');
const button = await this.ui.createDialog.createButton;
await button.waitForVisible();
await button.click();
await this.ui.browser.waitForNotVisible('iron-overlay-backdrop');
const hasTitle = await this.ui.browser.hasTitle(title);
hasTitle.should.be.true;
this.doc = { type: currentDocType, title };
});

Then('I see the {word} page', function(docType) {
this.ui.browser.waitForNotVisible('iron-overlay-backdrop');
this.ui.browser.documentPage(docType).view.waitForVisible();
Then('I see the {word} page', async function(docType) {
const ele = await this.ui.browser;
await ele.waitForNotVisible('iron-overlay-backdrop');
const docPage = await ele.documentPage(docType);
const docPageView = await docPage.view;
await docPageView.waitForVisible();
});

Then(/^I can see that a document of the type (.+) and title (.+) is created$/, function(docType, title) {
Expand Down
195 changes: 115 additions & 80 deletions packages/nuxeo-web-ui-ftest/features/step_definitions/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,114 +111,149 @@ When('I browse to the saved search', function() {
url(`#!/doc/${this.savedSearch.id}`);
});

Then('I can see that my saved search "{word}" on "{word}" is selected', function(savedSearchName, searchName) {
this.ui.searchForm(searchName).menuButton.waitForVisible();
const el = this.ui.searchForm(searchName).getSavedSearch(savedSearchName);
el.waitForExist().should.be.true;
el.getAttribute('class').should.equal('iron-selected');
Then('I can see that my saved search "{word}" on "{word}" is selected', async function(savedSearchName, searchName) {
const searchForm = await this.ui.searchForm(searchName);
const menuButton = await searchForm.menuButton;
await menuButton.waitForVisible();
const savedSearch = await this.ui.searchForm(searchName).getSavedSearch(savedSearchName);
const savedSearchExist = await savedSearch.waitForExist();
savedSearchExist.should.be.true;
const attr = await savedSearch.getAttribute('class');
attr.should.equal('iron-selected');
});

When(/^I clear the (.+) search on (.+)$/, function(searchType, searchName) {
const searchForm = this.ui.searchForm(searchName);
searchForm.waitForVisible();
searchForm.search(searchType);
When(/^I clear the (.+) search on (.+)$/, async function(searchType, searchName) {
const searchForm = await this.ui.searchForm(searchName);
await searchForm.waitForVisible();
await searchForm.search(searchType);
});

When(/^I perform a (.+) search for (.+) on (.+)$/, function(searchType, searchTerm, searchName) {
const searchForm = this.ui.searchForm(searchName);
searchForm.waitForVisible();
searchForm.search(searchType, searchTerm);
When(/^I perform a (.+) search for (.+) on (.+)$/, async function(searchType, searchTerm, searchName) {
const searchForm = await this.ui.searchForm(searchName);
await searchForm.waitForVisible();
await searchForm.search(searchType, searchTerm);
});

When('I switch to filter view', function() {
this.ui.filterView.click();
});

Then(/^I can see (\d+) search results$/, function(numberOfResults) {
const { displayMode } = this.ui.results;
Then(/^I can see (\d+) search results$/, async function(numberOfResults) {
const uiResult = await this.ui.results;
const displayMode = await uiResult.displayMode;
if (numberOfResults === 0) {
driver.waitUntil(
() => this.ui.results.resultsCount(displayMode) === 0,
`Expecting to get ${numberOfResults} results but found ${this.ui.results.resultsCount(displayMode)}`,
);
this.ui.results.noResults.waitForVisible().should.be.true;
const outResult2 = await uiResult.resultsCount(displayMode);
if (outResult2 !== numberOfResults) {
throw Error(`Expecting to get ${numberOfResults} results but found ${outResult2}`);
}
const emptyResult = await uiResult.noResults;
const emptyResultVisible = await emptyResult.waitForVisible();
emptyResultVisible.should.be.true;
} else {
this.ui.results.resultsCountLabel.waitForVisible();
driver.waitUntil(
() =>
parseInt(this.ui.results.resultsCountLabel.getText(), 10) === numberOfResults &&
this.ui.results.resultsCount(displayMode) === numberOfResults,
`Expecting to get ${numberOfResults} results but found ${this.ui.results.resultsCount(displayMode)}`,
);
const outLabel = await uiResult.resultsCountLabel;
await outLabel.waitForVisible();
const outText = await outLabel.getText();
const outResult = parseInt(outText, 10);
if (outResult !== numberOfResults) {
throw Error(`Expecting to get ${numberOfResults} results but found ${outResult}`);
}
const outResult2 = await uiResult.resultsCount(displayMode);
if (outResult2 !== numberOfResults) {
throw Error(`Expecting to get ${numberOfResults} results but found ${outResult}`);
}
}
});

Then(/^I can see more than (\d+) search results$/, function(minNumberOfResults) {
const { displayMode } = this.ui.results;
driver.waitUntil(
() => this.ui.results.resultsCount(displayMode) > minNumberOfResults,
`Expecting to get more than ${minNumberOfResults} results but found ${this.ui.results.resultsCount(displayMode)}`,
);
Then(/^I can see more than (\d+) search results$/, async function(minNumberOfResults) {
const results = await this.ui.results;
const displayMode = await results.displayMode;
const output = await results.resultsCount(displayMode);
if (output > minNumberOfResults) {
return true;
}
throw Error(`Expecting to get more than ${minNumberOfResults} but found ${output}`);
});

Then('I edit the results columns to show {string}', function(heading) {
this.ui.results.actions.waitForVisible();
if (this.ui.results.displayMode !== 'table' && this.ui.results.toggleTableView.isVisible()) {
this.ui.results.toggleTableView.click();
Then('I edit the results columns to show {string}', async function(heading) {
const result = await this.ui.results;
const actions = await result.actions;
await actions.waitForVisible();
const dispMode = await result.displayMode;
const togTableview = await result.toggleTableView;
if ((await dispMode) !== 'table' && (await togTableview.isVisible())) {
await togTableview.click();
}
this.ui.results.toggleColumnSettings.waitForVisible();
this.ui.results.toggleColumnSettings.click();
this.ui.results.getColumnCheckbox(heading).waitForExist();
this.ui.results.checkColumnCheckbox(heading);
this.ui.results.columnsCloseButton.click();
this.ui.results.getResultsColumn(heading).waitForExist().should.be.true;
});

Then(/^I save my search as "(.+)"$/, function(searchName) {
this.ui.searchResults.saveSearchAsButton.waitForVisible();
this.ui.searchResults.saveSearchAsButton.click();
this.ui.searchResults.enterInput(searchName);
this.ui.searchResults.confirmSaveSearchButton.click();
});

Then(/^I share my "(.+)" search with (.+)/, function(searchName, username) {
this.ui.searchResults.savedSearchActionButton.waitForVisible();
this.ui.searchResults.savedSearchActionButton.click();
this.ui.searchResults.shareAction.waitForVisible();
this.ui.searchResults.shareAction.click();
this.ui.searchForm(searchName).permissionsView.newPermissionButton.waitForVisible();
this.ui.searchForm(searchName).permissionsView.newPermissionButton.click();
this.ui.searchForm(searchName).permissionsView.setPermissions(username, {
const toggleSettings = await result.toggleColumnSettings;
await toggleSettings.waitForVisible();
await toggleSettings.click();
const columnCheckbox = await result.getColumnCheckbox(heading);
await columnCheckbox.waitForExist();
await result.checkColumnCheckbox(heading);
const button = await result.columnsCloseButton;
await button.click();
const resultsColumn = await result.getResultsColumn(heading);
const isColumnExist = await resultsColumn.waitForExist();
isColumnExist.should.be.true;
});

Then(/^I save my search as "(.+)"$/, async function(searchName) {
const saveAsButton = await this.ui.searchResults.saveSearchAsButton;
await saveAsButton.waitForVisible();
await saveAsButton.click();
await this.ui.searchResults.enterInput(searchName);
const confirmSaveButton = await this.ui.searchResults.confirmSaveSearchButton;
await confirmSaveButton.click();
});

Then(/^I share my "(.+)" search with (.+)/, async function(searchName, username) {
const savedSearchButton = await this.ui.searchResults.savedSearchActionButton;
await savedSearchButton.waitForVisible();
await savedSearchButton.click();
const shareActionButton = await this.ui.searchResults.shareAction;
await shareActionButton.waitForVisible();
await shareActionButton.click();
const searchForm = await this.ui.searchForm(searchName);
const PremissionButton = await searchForm.permissionsView.newPermissionButton;
await PremissionButton.waitForVisible();
await PremissionButton.click();
await searchForm.permissionsView.setPermissions(username, {
permission: 'Read',
timeFrame: 'permanent',
notify: false,
});
this.ui.searchForm(searchName).permissionsView.createPermissionButton.waitForVisible();
this.ui.searchForm(searchName).permissionsView.createPermissionButton.click();
this.ui
.searchForm(searchName)
.permissionsView.permission('Read', username, 'permanent')
.waitForVisible();
const createPermissionButton = await searchForm.permissionsView.createPermissionButton;
await createPermissionButton.waitForVisible();
await createPermissionButton.click();
const permissionVisible = await searchForm.permissionsView.permission('Read', username, 'permanent');
permissionVisible.should.be.true;
});

Then(/^I can view my saved search "(.+)" on "(.+)"$/, function(savedSearchName, searchName) {
this.ui.searchForm(searchName).menuButton.waitForVisible();
this.ui.searchForm(searchName).menuButton.click();
this.ui
.searchForm(searchName)
.getSavedSearch(savedSearchName)
.waitForExist().should.be.true;
Then(/^I can view my saved search "(.+)" on "(.+)"$/, async function(savedSearchName, searchName) {
const searchForm = await this.ui.searchForm(searchName);
const menuButton = await searchForm.menuButton;
await menuButton.waitForVisible();
await menuButton.click();
const savedSearch = await searchForm.getSavedSearch(savedSearchName);
const savedSearchExist = await savedSearch.waitForExist();
savedSearchExist.should.be.true;
});

When(/^I click the QuickSearch button$/, function() {
this.ui.searchButton.waitForVisible();
this.ui.searchButton.click();
When(/^I click the QuickSearch button$/, async function() {
const button = await this.ui.searchButton;
await button.waitForVisible();
await button.click();
});

When(/^I perform a QuickSearch for (.+)/, function(searchTerm) {
return this.ui.quickSearch.enterInput(searchTerm);
When(/^I perform a QuickSearch for (.+)/, async function(searchTerm) {
const quickSearch = await this.ui.quickSearch;
await quickSearch.enterInput(searchTerm);
});

Then(/^I can see (\d+) QuickSearch results$/, function(numberOfResults) {
driver.waitUntil(() => this.ui.quickSearch.quickSearchResultsCount() === numberOfResults);
Then(/^I can see (\d+) QuickSearch results$/, async function(numberOfResults) {
const quickSearch = await this.ui.quickSearch;
await driver.pause(1000);
const result = await quickSearch.quickSearchResultsCount();
if (result !== numberOfResults) {
throw Error(`Expecting to get ${numberOfResults} results but found ${result}`);
}
});
Loading

0 comments on commit 24d8ea0

Please sign in to comment.