[ACA-2387] rebalance suites (#1107)

* rebalance suites

* try to fix flaky test

* fix more related tests

* fix retry

* reorganise some more suites

* move file to another suite
This commit is contained in:
Adina Parpalita
2019-05-15 11:47:52 +03:00
committed by Martin Muller
parent 39f528af67
commit 1c18f6c555
6 changed files with 64 additions and 32 deletions

View File

@@ -27,6 +27,7 @@ import { RepoApi } from '../repo-api';
import { NodeBodyCreate } from './node-body-create';
import { NodeContentTree, flattenNodeContentTree } from './node-content-tree';
import { NodesApi as AdfNodeApi, NodeBodyLock} from '@alfresco/js-api';
import { Utils } from '../../../../utilities/utils';
export class NodesApi extends RepoApi {
nodesApi = new AdfNodeApi(this.alfrescoJsApi);
@@ -264,6 +265,28 @@ export class NodesApi extends RepoApi {
return (await this.getLockType(nodeId)) === 'WRITE_LOCK';
}
async isFileLockedWriteWithRetry(nodeId: string, expect: boolean) {
const data = {
expect: expect,
retry: 5
};
let isLocked;
try {
const locked = async () => {
isLocked = (await this.getLockType(nodeId)) === 'WRITE_LOCK';
if ( isLocked !== data.expect ) {
return Promise.reject(isLocked);
} else {
return Promise.resolve(isLocked);
}
}
return await Utils.retryCall(locked, data.retry);
} catch (error) {
console.log('-----> catch isLockedWriteWithRetry: ', error);
}
return isLocked;
}
async isFileLockedByName(fileName: string, parentId: string) {
const id = await this.getNodeIdFromParent(fileName, parentId);
return await this.isFileLockedWrite(id);