cypress-mailisk 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress-mailisk",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Mailisk library for Cypress",
5
5
  "keywords": [
6
6
  "mailisk",
@@ -18,6 +18,19 @@ class MailiskCommands {
18
18
  return this.request.get('api/namespaces');
19
19
  }
20
20
 
21
+ _mailiskSearchAction(namespace, _options, urlParams, startTime, nextTimeout) {
22
+ return this.request
23
+ .get(`api/emails/${namespace}/inbox?${urlParams.toString()}`, { ..._options, timeout: nextTimeout })
24
+ .then((response) => {
25
+ if (response.total_count !== 0) {
26
+ return response;
27
+ }
28
+ const timeout = Math.max(_options.timeout - (Date.now() - startTime), 1);
29
+ cy.wait(Math.min(timeout, 9000));
30
+ return this._mailiskSearchAction(namespace, _options, urlParams, startTime, timeout);
31
+ });
32
+ }
33
+
21
34
  mailiskSearchInbox(namespace, params, options = {}) {
22
35
  let _params = { ...params };
23
36
 
@@ -44,7 +57,14 @@ class MailiskCommands {
44
57
  _options.timeout = 1000 * 60 * 5;
45
58
  }
46
59
 
47
- return this.request.get(`api/emails/${namespace}/inbox?${urlParams.toString()}`, _options);
60
+ // temporary workaround due cypress not supporting overriding maxRedirects
61
+ if (_params.wait) {
62
+ urlParams.delete('wait');
63
+ const startTime = Date.now();
64
+ return this._mailiskSearchAction(namespace, _options, urlParams, startTime, _options.timeout);
65
+ } else {
66
+ return this.request.get(`api/emails/${namespace}/inbox?${urlParams.toString()}`, _options);
67
+ }
48
68
  }
49
69
  }
50
70