suitest-js-api 3.4.2 → 3.4.3

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.
@@ -1,6 +1,5 @@
1
1
  const {omit, compose, isNil} = require('ramda');
2
2
  const SuitestError = require('../../lib/utils/SuitestError');
3
- const util = require('util');
4
3
 
5
4
  // Import utils
6
5
  const makeChain = require('../utils/makeChain');
@@ -16,18 +16,13 @@ const {
16
16
  gettersComposer,
17
17
  makeToJSONComposer,
18
18
  } = require('../composers');
19
- const {
20
- processServerResponse,
21
- getRequestType,
22
- } = require('../utils/socketChainHelper');
19
+ const {getRequestType} = require('../utils/socketChainHelper');
23
20
  const {
24
21
  applyTimeout,
25
22
  applyNegation,
26
23
  } = require('../utils/chainUtils');
27
24
 
28
25
  const locationFactory = (classInstance) => {
29
- const {logger} = classInstance;
30
-
31
26
  const toJSON = data => {
32
27
  const type = getRequestType(data);
33
28
  const subject = {type: 'location'};
@@ -51,8 +46,8 @@ const locationFactory = (classInstance) => {
51
46
  };
52
47
 
53
48
  // Build Composers
54
- const toStringComposer = makeToStringComposer(toString, toJSON);
55
- const thenComposer = makeThenComposer(toJSON, processServerResponse(logger, classInstance.getConfig().logLevel));
49
+ const toStringComposer = makeToStringComposer(toJSON);
50
+ const thenComposer = makeThenComposer(toJSON);
56
51
  const toJSONComposer = makeToJSONComposer(toJSON);
57
52
 
58
53
  /**
@@ -1,6 +1,5 @@
1
1
  // Import helpers and composers
2
2
  const makeChain = require('../utils/makeChain');
3
- const {processJsonMessageForToString} = require('../utils/chainUtils');
4
3
  const {
5
4
  abandonComposer,
6
5
  makeToStringComposer,
@@ -10,17 +9,11 @@ const {
10
9
  gettersComposer,
11
10
  makeToJSONComposer,
12
11
  } = require('../composers');
13
- const {
14
- openURL,
15
- invalidInputMessage,
16
- } = require('../texts');
17
- const {processServerResponse, getRequestType} = require('../utils/socketChainHelper');
12
+ const {invalidInputMessage} = require('../texts');
13
+ const {getRequestType} = require('../utils/socketChainHelper');
18
14
  const {validate, validators} = require('../validation');
19
15
 
20
16
  const openUrlFactory = (classInstance) => {
21
- const {logger} = classInstance;
22
- const toString = (jsonMessage) => openURL(processJsonMessageForToString(jsonMessage).url);
23
-
24
17
  const toJSON = data => ({
25
18
  type: getRequestType(data, false),
26
19
  request: {
@@ -30,8 +23,8 @@ const openUrlFactory = (classInstance) => {
30
23
  });
31
24
 
32
25
  // Build Composers
33
- const toStringComposer = makeToStringComposer(toString, toJSON);
34
- const thenComposer = makeThenComposer(toJSON, processServerResponse(logger, classInstance.getConfig().logLevel));
26
+ const toStringComposer = makeToStringComposer(toJSON);
27
+ const thenComposer = makeThenComposer(toJSON);
35
28
  const toJSONComposer = makeToJSONComposer(toJSON);
36
29
 
37
30
  /**
@@ -20,6 +20,8 @@ const {
20
20
  const {getRequestType} = require('../utils/socketChainHelper');
21
21
  const {getMatchExpression, applyTimeout} = require('../utils/chainUtils');
22
22
  const {SUBJ_COMPARATOR} = require('../constants/comparator');
23
+ const SuitestError = require('../utils/SuitestError');
24
+ const {psVideoMalformed} = require('../texts');
23
25
 
24
26
  const playstationVideoFactory = (classInstance) => {
25
27
  const toJSON = data => {
@@ -28,9 +30,11 @@ const playstationVideoFactory = (classInstance) => {
28
30
  const subject = {
29
31
  type: 'psVideo',
30
32
  };
33
+ let videoLineMalformed = true;
31
34
 
32
35
  // query
33
36
  if (type === 'query') {
37
+ videoLineMalformed = false;
34
38
  socketMessage.subject = {
35
39
  type: 'elementProps',
36
40
  selector: {psVideo: true},
@@ -39,6 +43,7 @@ const playstationVideoFactory = (classInstance) => {
39
43
 
40
44
  // element subject
41
45
  if (data.comparator) {
46
+ videoLineMalformed = false;
42
47
  socketMessage.request = applyTimeout({
43
48
  type: 'assert',
44
49
  condition: {subject},
@@ -53,6 +58,9 @@ const playstationVideoFactory = (classInstance) => {
53
58
  socketMessage.request.condition.expression = getMatchExpression(data);
54
59
  }
55
60
  }
61
+ if (videoLineMalformed) {
62
+ throw new SuitestError(psVideoMalformed(), SuitestError.INVALID_INPUT);
63
+ }
56
64
 
57
65
  return socketMessage;
58
66
  };
@@ -1,6 +1,6 @@
1
1
  // Import utils
2
2
  const makeChain = require('../utils/makeChain');
3
-
3
+ const SuitestError = require('../../lib/utils/SuitestError');
4
4
  // Import chain composers
5
5
  const {
6
6
  notComposer,
@@ -27,6 +27,7 @@ const {
27
27
  SUBJ_COMPARATOR: SUBJ_COMPARATOR_M,
28
28
  } = require('../mappings');
29
29
  const {elementWithComparatorToJSON} = require('../utils/chainUtils');
30
+ const {videoMalformed} = require('../texts');
30
31
 
31
32
  const videoFactory = (classInstance) => {
32
33
  const toJSON = data => {
@@ -35,9 +36,11 @@ const videoFactory = (classInstance) => {
35
36
  const subject = {
36
37
  type: 'video',
37
38
  };
39
+ let videoLineMalformed = true;
38
40
 
39
41
  // query
40
42
  if (type === 'query') {
43
+ videoLineMalformed = false;
41
44
  socketMessage.subject = {
42
45
  type: 'elementProps',
43
46
  selector: {video: true},
@@ -46,14 +49,19 @@ const videoFactory = (classInstance) => {
46
49
 
47
50
  // video subject
48
51
  if (data.comparator) {
52
+ videoLineMalformed = false;
49
53
  socketMessage.request = elementWithComparatorToJSON(data, subject, classInstance.config.defaultTimeout);
50
54
  }
51
55
 
56
+ if (videoLineMalformed) {
57
+ throw new SuitestError(videoMalformed(), SuitestError.INVALID_INPUT);
58
+ }
59
+
52
60
  return socketMessage;
53
61
  };
54
62
 
55
63
  // Build Composers
56
- const toStringComposer = makeToStringComposer(toString, toJSON);
64
+ const toStringComposer = makeToStringComposer(toJSON);
57
65
  const thenComposer = makeThenComposer(toJSON);
58
66
  const toJSONComposer = makeToJSONComposer(toJSON);
59
67
 
package/lib/texts.js CHANGED
@@ -72,6 +72,8 @@ module.exports = {
72
72
  applicationCommandMalformed: () => 'Invalid input - application command is malformed',
73
73
  incorrectElementIndex: () => 'the "index" supplied to the .element() selector should be > 0',
74
74
  assertElementMalformed: () => 'Assert element line is malformed',
75
+ videoMalformed: () => 'Video line is malformed',
76
+ psVideoMalformed: () => 'PlayStation Video line is malformed',
75
77
 
76
78
  positionIsMalformed: () => 'position command is malformed',
77
79
  relativePositionIsMalformed: () => 'relative position is malformed',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suitest-js-api",
3
- "version": "3.4.2",
3
+ "version": "3.4.3",
4
4
  "main": "index.js",
5
5
  "repository": "git@github.com:SuitestAutomation/suitest-js-api.git",
6
6
  "author": "Suitest <hello@suite.st>",