mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -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) {
|
||||
|
@@ -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));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -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';
|
||||
|
83
lib/testing/src/lib/core/actions/search.service.ts
Normal file
83
lib/testing/src/lib/core/actions/search.service.ts
Normal 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"
|
||||
]
|
||||
}
|
||||
}`;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user