[ADF-5236] C246534 Failing (#6138)

* [ADF-5236]fix C246534 Failing

* * improved e2e

* * spell check

* * fix

* revert chnages

* * minor improvements

* * fix lint

* * query improvements
This commit is contained in:
dhrn
2020-09-24 14:45:22 +05:30
committed by GitHub
parent d485aee674
commit 80a3618ca8
7 changed files with 141 additions and 23 deletions

View File

@@ -156,6 +156,7 @@ export class ContentNodeSelectorDialogPage {
async searchAndSelectResult(searchText: string, name: string) {
await this.typeIntoNodeSelectorSearchField(searchText);
await this.contentListPage().dataTablePage().waitTillContentLoaded();
await this.contentListPage().dataTablePage().waitForFirstRow();
try {
await this.contentListPage().dataTablePage().checkRowContentIsDisplayed(name);
} catch (e) {

View File

@@ -122,4 +122,22 @@ export class ApiService {
.catch((err) => reject(err));
});
}
async performECMOperation(path: string, method: string, queryParams: any, postBody: any): Promise<any> {
return new Promise((resolve, reject) => {
const uri = this.config.hostEcm + path;
const pathParams = {}, formParams = {};
const contentTypes = ['application/json'];
const accepts = ['application/json'];
const headerParams = {
Authorization: 'bearer ' + this.apiService.oauth2Auth.token
};
this.apiService.contentClient
.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody, contentTypes, accepts, Object)
.then((data) => resolve(data))
.catch((err) => reject(err));
});
}
}

View File

@@ -22,3 +22,4 @@ export * from './users.actions';
export * from './api';
export * from './api.util';
export * from './e2e-request-api.helper';
export * from './search.service';

View File

@@ -0,0 +1,83 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ApiService } from './api.service';
import { ResultSetPaging } from '@alfresco/js-api';
import { Logger } from '../utils/logger';
import { ApiUtil } from './api.util';
export class SearchService {
apiService: ApiService;
constructor(apiService: ApiService) {
this.apiService = apiService;
}
async isSearchable(name: string): Promise<any> {
const query = this.createSearchQuery(name);
const predicate = (result: ResultSetPaging) => {
return result.list && result.list.entries.length > 0 && !!result.list.entries.find(({ entry }) => entry.name === name);
};
const apiCall = async () => {
try {
const path = '/alfresco/api/-default-/public/search/versions/1/search';
const method = 'POST';
const queryParams = {},
postBody = JSON.parse(query);
return this.apiService.performECMOperation(path, method, queryParams, postBody);
} catch (error) {
Logger.error('Failed to search folder');
}
};
return ApiUtil.waitForApi(apiCall, predicate);
}
private createSearchQuery(name: string) {
return `{
"query": {
"query": "${name}*"
},
"include": [
"path",
"allowableOperations",
"properties"
],
"paging": {
"maxItems": 20,
"skipCount": 0
},
"filterQueries": [
{
"query": "TYPE:'cm:folder' OR TYPE:'cm:content'"
},
{
"query": "NOT cm:creator:System"
}
],
"scope": {
"locations": [
"nodes"
]
}
}`;
}
}