-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
steps_file.js
28 lines (22 loc) · 1.1 KB
/
steps_file.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// in this file you can append custom step methods to 'I' object
const assert = require('assert')
module.exports = function () {
return actor({
assertUpload: async function () {
// Upload and wait until file is uploaded
this.attachFile('input[name=file]', 'test_image.jpeg');
this.waitForElement('#file-upload-list li:nth-child(2)', 40);
const text = await this.grabTextFrom('#file-upload-list li:nth-child(2)')
assert.ok(typeof text === 'string', 'Invalid response: not text')
assert.ok(text.indexOf('Uploaded: ') >= -1, 'Invalid response: missing Uploaded text');
// Clean the url
const uploadedFile = text
.replace('Uploaded: ', '')
.trim()
.replace('upload/', '')
const response = await this.sendGetRequest(`/check/${uploadedFile}`);
assert.strictEqual(response.status, 200, 'File was not uploaded')
assert.strictEqual(response.data, 'c5ebe8da4df8f4242a6fc09344a07d06ea138242', 'SHA1 does not match')
}
});
}