✨ back: e2e userapi random file destination name option
This commit is contained in:
committed by
Anton Shepilov
parent
193f2ee3fe
commit
185ec5ac5c
@@ -149,9 +149,10 @@ export default class UserApi {
|
||||
return helpers;
|
||||
}
|
||||
|
||||
async uploadRandomFile() {
|
||||
async uploadRandomFile(overridenDestinationFilename?: string) {
|
||||
return await this.uploadFile(
|
||||
UserApi.ALL_FILES[Math.floor(Math.random() * UserApi.ALL_FILES.length)],
|
||||
overridenDestinationFilename,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -170,10 +171,10 @@ export default class UserApi {
|
||||
});
|
||||
}
|
||||
|
||||
async uploadFile(filename: string) {
|
||||
logger.info(`Upload ${filename} for the user: ${this.user.id}`);
|
||||
async uploadFile(filename: string, overridenDestinationFilename?: string) {
|
||||
logger.info(`Upload ${filename} for the user: ${this.user.id} as ${JSON.stringify(overridenDestinationFilename)}`);
|
||||
const fullPath = `${__dirname}/assets/${filename}`;
|
||||
const filesUploadRaw = await this.injectUploadRequest(fs.createReadStream(fullPath));
|
||||
const filesUploadRaw = await this.injectUploadRequest(fs.createReadStream(fullPath), overridenDestinationFilename);
|
||||
|
||||
if (filesUploadRaw.statusCode == 200) {
|
||||
const filesUpload: ResourceUpdateResponse<File> = deserialize<ResourceUpdateResponse<File>>(
|
||||
@@ -227,8 +228,8 @@ export default class UserApi {
|
||||
return this.uploadEicarTestFile(filename).then(f => this.createDocumentFromFile(f, parent_id));
|
||||
}
|
||||
|
||||
async uploadRandomFileAndCreateDocument(parent_id = "root") {
|
||||
return this.uploadRandomFile().then(f => this.createDocumentFromFile(f, parent_id));
|
||||
async uploadRandomFileAndCreateDocument(parent_id = "root", overridenDestinationFilename?: string) {
|
||||
return this.uploadRandomFile(overridenDestinationFilename).then(f => this.createDocumentFromFile(f, parent_id));
|
||||
}
|
||||
|
||||
async uploadAllFilesAndCreateDocuments(parent_id = "root") {
|
||||
|
||||
Reference in New Issue
Block a user