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/>.
|
* 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';
|
import { Utils } from '../../../../utilities/utils';
|
||||||
|
|
||||||
export class TrashcanApi extends RepoApi {
|
export class TrashcanApi extends RepoApiNew {
|
||||||
permanentlyDelete(id: string): Promise<any> {
|
|
||||||
return this
|
constructor(username?, password?) {
|
||||||
.delete(`/deleted-nodes/${id}`)
|
super(username, password);
|
||||||
.catch(this.handleError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
restore(id: string) {
|
async permanentlyDelete(id: string) {
|
||||||
return this
|
await this.apiAuth();
|
||||||
.post(`/deleted-nodes/${id}/restore`)
|
return await this.alfrescoJsApi.core.nodesApi.purgeDeletedNode(id);
|
||||||
.catch(this.handleError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getDeletedNodes(): Promise<any> {
|
async restore(id: string) {
|
||||||
return this
|
await this.apiAuth();
|
||||||
.get(`/deleted-nodes?maxItems=1000`)
|
return await this.alfrescoJsApi.core.nodesApi.restoreNode(id);
|
||||||
.catch(this.handleError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emptyTrash(): Promise<any> {
|
async getDeletedNodes() {
|
||||||
return this.getDeletedNodes()
|
const opts = {
|
||||||
.then(resp => {
|
maxItems: 1000
|
||||||
return resp.data.list.entries.map(entries => entries.entry.id);
|
};
|
||||||
})
|
await this.apiAuth();
|
||||||
.then(ids => {
|
return await this.alfrescoJsApi.core.nodesApi.getDeletedNodes(opts);
|
||||||
return ids.reduce((previous, current) => (
|
|
||||||
previous.then(() => this.permanentlyDelete(current))
|
|
||||||
), Promise.resolve());
|
|
||||||
})
|
|
||||||
.catch(this.handleError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
waitForApi(data) {
|
async emptyTrash() {
|
||||||
const deletedFiles = () => {
|
const ids = (await this.getDeletedNodes()).list.entries.map(entries => entries.entry.id);
|
||||||
return this.getDeletedNodes()
|
|
||||||
.then(response => response.data.list.pagination.totalItems)
|
return await ids.reduce(async (previous, current) => {
|
||||||
.then(totalItems => {
|
await previous;
|
||||||
if ( totalItems < data.expect) {
|
return await this.permanentlyDelete(current);
|
||||||
return Promise.reject(totalItems);
|
}, Promise.resolve());
|
||||||
} else {
|
}
|
||||||
return Promise.resolve(totalItems);
|
|
||||||
}
|
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() {
|
get trashcan() {
|
||||||
return new TrashcanApi(this.auth, this.config);
|
return new TrashcanApi(this.auth.username, this.auth.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
get search() {
|
get search() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user