@@ -32,42 +32,47 @@ class FileUpload {
3232 * Opens the file upload form.
3333 *
3434 * @param {number } [timeout] Wait timeout
35- * @returns {FileUpload } FileUpload object
3635 */
37- open ( timeout ) {
38- browser . url ( '/' )
39- this . fileinput . waitForExist ( { timeout } )
40- return this
36+ async open ( timeout ) {
37+ await browser . url ( '/' )
38+ await this . fileinput . waitForExist ( { timeout } )
4139 }
4240 /**
4341 * Uploads files.
4442 *
4543 * @param {Array<string> } files Files to upload
4644 * @param {number } [timeout] Wait timeout
47- * @returns {FileUpload } FileUpload object
4845 */
49- upload ( files , timeout ) {
50- this . fileinput . addValue ( files . join ( '\n' ) )
51- browser . waitUntil ( ( ) => ! this . processing . length , { timeout } )
52- this . start . click ( )
53- browser . waitUntil ( ( ) => ! ! this . downloads . length , { timeout } )
54- browser . waitUntil ( ( ) => ! this . uploads . length , { timeout } )
55- return this
46+ async upload ( files , timeout ) {
47+ await this . fileinput . addValue ( files . join ( '\n' ) )
48+ await browser . waitUntil ( async ( ) => ! ( await this . processing . length ) , {
49+ timeout
50+ } )
51+ await this . start . click ( )
52+ await browser . waitUntil ( async ( ) => ! ! ( await this . downloads . length ) , {
53+ timeout
54+ } )
55+ await browser . waitUntil ( async ( ) => ! ( await this . uploads . length ) , {
56+ timeout
57+ } )
5658 }
5759 /**
5860 * Deletes uploaded files.
5961 *
6062 * @param {number } [timeout] Wait timeout
61- * @returns {FileUpload } FileUpload object
6263 */
63- delete ( timeout ) {
64- this . toggle . click ( )
65- browser . waitUntil ( ( ) => this . downloads . length === this . checked . length , {
64+ async delete ( timeout ) {
65+ await this . toggle . click ( )
66+ await browser . waitUntil (
67+ async ( ) => ( await this . downloads . length ) === ( await this . checked . length ) ,
68+ {
69+ timeout
70+ }
71+ )
72+ await this . remove . click ( )
73+ await browser . waitUntil ( async ( ) => ! ( await this . downloads . length ) , {
6674 timeout
6775 } )
68- this . remove . click ( )
69- browser . waitUntil ( ( ) => ! this . downloads . length , { timeout } )
70- return this
7176 }
7277}
7378
0 commit comments