mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACA-1640] use alfresco-js-api-node in e2e trashcanApi (#562)
This commit is contained in:
parent
8f36822847
commit
213c2deedc
@ -60,6 +60,6 @@ export class SearchApi extends RepoApiNew {
|
||||
}
|
||||
};
|
||||
|
||||
return Utils.retryCall(recentFiles);
|
||||
return await Utils.retryCall(recentFiles);
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,6 @@ export class SharedLinksApi extends RepoApiNew {
|
||||
}
|
||||
};
|
||||
|
||||
return Utils.retryCall(sharedFiles);
|
||||
return await Utils.retryCall(sharedFiles);
|
||||
}
|
||||
}
|
||||
|
72
e2e/utilities/repo-client/apis/trashcan/trashcan-api.ts
Executable file → Normal file
72
e2e/utilities/repo-client/apis/trashcan/trashcan-api.ts
Executable file → Normal file
@ -23,54 +23,52 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RepoApi } from '../repo-api';
|
||||
import { RepoApiNew } from '../repo-api-new';
|
||||
import { Utils } from '../../../../utilities/utils';
|
||||
|
||||
export class TrashcanApi extends RepoApi {
|
||||
permanentlyDelete(id: string): Promise<any> {
|
||||
return this
|
||||
.delete(`/deleted-nodes/${id}`)
|
||||
.catch(this.handleError);
|
||||
export class TrashcanApi extends RepoApiNew {
|
||||
|
||||
constructor(username?, password?) {
|
||||
super(username, password);
|
||||
}
|
||||
|
||||
restore(id: string) {
|
||||
return this
|
||||
.post(`/deleted-nodes/${id}/restore`)
|
||||
.catch(this.handleError);
|
||||
async permanentlyDelete(id: string) {
|
||||
await this.apiAuth();
|
||||
return await this.alfrescoJsApi.core.nodesApi.purgeDeletedNode(id);
|
||||
}
|
||||
|
||||
getDeletedNodes(): Promise<any> {
|
||||
return this
|
||||
.get(`/deleted-nodes?maxItems=1000`)
|
||||
.catch(this.handleError);
|
||||
async restore(id: string) {
|
||||
await this.apiAuth();
|
||||
return await this.alfrescoJsApi.core.nodesApi.restoreNode(id);
|
||||
}
|
||||
|
||||
emptyTrash(): Promise<any> {
|
||||
return this.getDeletedNodes()
|
||||
.then(resp => {
|
||||
return resp.data.list.entries.map(entries => entries.entry.id);
|
||||
})
|
||||
.then(ids => {
|
||||
return ids.reduce((previous, current) => (
|
||||
previous.then(() => this.permanentlyDelete(current))
|
||||
), Promise.resolve());
|
||||
})
|
||||
.catch(this.handleError);
|
||||
async getDeletedNodes() {
|
||||
const opts = {
|
||||
maxItems: 1000
|
||||
};
|
||||
await this.apiAuth();
|
||||
return await this.alfrescoJsApi.core.nodesApi.getDeletedNodes(opts);
|
||||
}
|
||||
|
||||
waitForApi(data) {
|
||||
const deletedFiles = () => {
|
||||
return this.getDeletedNodes()
|
||||
.then(response => response.data.list.pagination.totalItems)
|
||||
.then(totalItems => {
|
||||
if ( totalItems < data.expect) {
|
||||
return Promise.reject(totalItems);
|
||||
} else {
|
||||
return Promise.resolve(totalItems);
|
||||
}
|
||||
});
|
||||
async emptyTrash() {
|
||||
const ids = (await this.getDeletedNodes()).list.entries.map(entries => entries.entry.id);
|
||||
|
||||
return await ids.reduce(async (previous, current) => {
|
||||
await previous;
|
||||
return await this.permanentlyDelete(current);
|
||||
}, Promise.resolve());
|
||||
}
|
||||
|
||||
async waitForApi(data) {
|
||||
const deletedFiles = async () => {
|
||||
const totalItems = (await this.getDeletedNodes()).list.pagination.totalItems;
|
||||
if ( totalItems < data.expect) {
|
||||
return Promise.reject(totalItems);
|
||||
} else {
|
||||
return Promise.resolve(totalItems);
|
||||
}
|
||||
};
|
||||
|
||||
return Utils.retryCall(deletedFiles);
|
||||
return await Utils.retryCall(deletedFiles);
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ export class RepoClient {
|
||||
}
|
||||
|
||||
get trashcan() {
|
||||
return new TrashcanApi(this.auth, this.config);
|
||||
return new TrashcanApi(this.auth.username, this.auth.password);
|
||||
}
|
||||
|
||||
get search() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user