@qawolf/build-workflow
Advanced tools
Comparing version 0.4.3 to 0.4.4
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const chrono_node_1 = require("chrono-node"); | ||
const lodash_1 = require("lodash"); | ||
const isDateInputEvent = (event) => { | ||
const inputEvent = event; | ||
return (event.action === "input" && inputEvent.value && chrono_node_1.parseDate(inputEvent.value)); | ||
}; | ||
exports.buildClickSteps = (events) => { | ||
@@ -21,4 +16,2 @@ const steps = []; | ||
continue; | ||
if (i + 1 < events.length && isDateInputEvent(events[i + 1])) | ||
continue; | ||
steps.push({ | ||
@@ -39,2 +32,4 @@ action: "click", | ||
continue; | ||
if (!event.isTrusted) | ||
continue; | ||
const nextEvent = i + 1 < events.length ? events[i + 1] : null; | ||
@@ -44,11 +39,9 @@ const lastInputToTarget = !nextEvent || event.target.xpath !== nextEvent.target.xpath; | ||
continue; | ||
if (event.isTrusted || isDateInputEvent(event)) { | ||
steps.push({ | ||
action: "input", | ||
index: i, | ||
pageId: event.pageId, | ||
target: event.target, | ||
value: event.value | ||
}); | ||
} | ||
steps.push({ | ||
action: "input", | ||
index: i, | ||
pageId: event.pageId, | ||
target: event.target, | ||
value: event.value | ||
}); | ||
} | ||
@@ -55,0 +48,0 @@ return steps; |
{ | ||
"name": "@qawolf/build-workflow", | ||
"description": "build qawolf workflow from events", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"license": "BSD-3.0", | ||
@@ -26,11 +26,10 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"chrono-node": "^1.3.11", | ||
"lodash": "^4.17.15" | ||
}, | ||
"devDependencies": { | ||
"@qawolf/fixtures": "1.8.0", | ||
"@qawolf/types": "^0.4.3", | ||
"@qawolf/fixtures": "1.9.0", | ||
"@qawolf/types": "^0.4.4", | ||
"jest": "^24.9.0" | ||
}, | ||
"gitHead": "0b18bbd752ba38f10abe9f8b4230856df70cc1de" | ||
"gitHead": "46e1d99d06c223f1fa8281e957856da4a7c152f1" | ||
} |
import { Event, InputEvent, ScrollEvent, Step } from "@qawolf/types"; | ||
import { parseDate } from "chrono-node"; | ||
import { concat, sortBy } from "lodash"; | ||
const isDateInputEvent = (event: Event) => { | ||
const inputEvent = event as InputEvent; | ||
return ( | ||
event.action === "input" && inputEvent.value && parseDate(inputEvent.value) | ||
); | ||
}; | ||
export const buildClickSteps = (events: Event[]): Step[] => { | ||
@@ -32,7 +24,2 @@ const steps: Step[] = []; | ||
// skip clicks before a date input | ||
// since we assume it triggers the date input event | ||
// ex. a date picker button | ||
if (i + 1 < events.length && isDateInputEvent(events[i + 1])) continue; | ||
steps.push({ | ||
@@ -59,2 +46,5 @@ action: "click", | ||
// ignore system initiated clicks | ||
if (!event.isTrusted) continue; | ||
const nextEvent = i + 1 < events.length ? events[i + 1] : null; | ||
@@ -66,13 +56,10 @@ const lastInputToTarget = | ||
// include user events and date input events | ||
if (event.isTrusted || isDateInputEvent(event)) { | ||
steps.push({ | ||
action: "input", | ||
// include event index so we can sort in buildSteps | ||
index: i, | ||
pageId: event.pageId, | ||
target: event.target, | ||
value: event.value | ||
}); | ||
} | ||
steps.push({ | ||
action: "input", | ||
// include event index so we can sort in buildSteps | ||
index: i, | ||
pageId: event.pageId, | ||
target: event.target, | ||
value: event.value | ||
}); | ||
} | ||
@@ -79,0 +66,0 @@ |
Sorry, the diff of this file is not supported yet
1
12439
14
222
- Removedchrono-node@^1.3.11
- Removedchrono-node@1.4.9(transitive)
- Removeddayjs@1.11.13(transitive)