Skip to content

Commit

Permalink
feat: use 'fill' for textareas
Browse files Browse the repository at this point in the history
  • Loading branch information
aldeed committed Jul 6, 2020
1 parent 660136b commit 9795965
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/build-workflow/buildFillSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import {
Step,
} from '../types';
import { isChangeEvent, isInputEvent } from './event';
import { isInputTarget } from './target';
import { isInputTarget, isTextareaTarget } from './target';

const debug = Debug('qawolf:buildFillSteps');

const shouldFill = (event: ElementEvent): boolean => {
const { target } = event;
return isChangeEvent(event) &&
isInputTarget(target) &&
(isInputTarget(target) || isTextareaTarget(target)) &&
// Some inputs emit "change" with a value but really can't or shouldn't be
// "filled in" with that value. Checkbox and radio should work without filling
// because there will be click events. File isn't supported.
Expand Down
4 changes: 2 additions & 2 deletions src/build-workflow/buildPressSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
KeyEvent,
Step,
} from '../types';
import { isInputTarget } from './target';
import { isInputTarget, isTextareaTarget } from './target';

const debug = Debug('qawolf:buildPressSteps');

Expand Down Expand Up @@ -53,7 +53,7 @@ const KEYS_TO_TRACK_FOR_NON_INPUT = new Set([
*/
const shouldTrackKeyPress = (key: string, target: Doc): boolean => {
if (KEYS_TO_TRACK_ALWAYS.has(key)) return true;
if (!isInputTarget(target) && KEYS_TO_TRACK_FOR_NON_INPUT.has(key)) return true;
if (!isInputTarget(target) && !isTextareaTarget(target) && KEYS_TO_TRACK_FOR_NON_INPUT.has(key)) return true;
return false;
}

Expand Down
5 changes: 5 additions & 0 deletions src/build-workflow/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ export const isInputTarget = (target: Doc): boolean => {
const name = target.name || '';
return name.toLowerCase() === 'input';
}

export const isTextareaTarget = (target: Doc): boolean => {
const name = target.name || '';
return name.toLowerCase() === 'textarea';
}

0 comments on commit 9795965

Please sign in to comment.