From 8e20854371c00bd30cb873fa0c79605a1c73871f Mon Sep 17 00:00:00 2001 From: Ruslan Grabovyi Date: Sun, 29 Mar 2020 04:09:32 +0300 Subject: [PATCH] Cleanup execution contexts --- .../-private/execution_context/acceptance.js | 21 +---------- .../-private/execution_context/integration.js | 27 +------------- .../native-events-context.js | 20 ---------- .../-private/execution_context/rfc268.js | 37 ------------------- 4 files changed, 2 insertions(+), 103 deletions(-) diff --git a/addon-test-support/-private/execution_context/acceptance.js b/addon-test-support/-private/execution_context/acceptance.js index 62225b96..2783776d 100644 --- a/addon-test-support/-private/execution_context/acceptance.js +++ b/addon-test-support/-private/execution_context/acceptance.js @@ -1,14 +1,9 @@ import $ from '-jquery'; import { run } from '../action'; -import { findClosestValue } from '../helpers'; import { fillElement, assertFocusable } from './helpers'; -import { - ELEMENT_NOT_FOUND, - throwBetterError -} from '../better-errors'; export default function AcceptanceExecutionContext(pageObjectNode) { this.pageObjectNode = pageObjectNode; @@ -68,19 +63,5 @@ AcceptanceExecutionContext.prototype = { assertFocusable(element); $(element).blur(); - }, - - assertElementExists(selector, options) { - /* global find */ - let result = find(selector, options.testContainer || findClosestValue(this.pageObjectNode, 'testContainer')); - - if (result.length === 0) { - throwBetterError( - this.pageObjectNode, - options.pageObjectKey, - ELEMENT_NOT_FOUND, - { selector } - ); - } - }, + } }; diff --git a/addon-test-support/-private/execution_context/integration.js b/addon-test-support/-private/execution_context/integration.js index 8b1e8546..a782fddb 100644 --- a/addon-test-support/-private/execution_context/integration.js +++ b/addon-test-support/-private/execution_context/integration.js @@ -1,15 +1,10 @@ import $ from '-jquery'; import { run } from '@ember/runloop'; import { run as runAction } from '../action'; -import { findClosestValue } from '../helpers'; import { fillElement, assertFocusable } from './helpers'; -import { - ELEMENT_NOT_FOUND, - throwBetterError -} from '../better-errors'; import wait from 'ember-test-helpers/wait'; export default function IntegrationExecutionContext(pageObjectNode, testContext) { @@ -74,25 +69,5 @@ IntegrationExecutionContext.prototype = { assertFocusable(element); $(element).blur(); - }, - - assertElementExists(selector, options) { - let result; - let container = options.testContainer || findClosestValue(this.pageObjectNode, 'testContainer'); - - if (container) { - result = $(selector, container); - } else { - result = this.testContext.$(selector); - } - - if (result.length === 0) { - throwBetterError( - this.pageObjectNode, - options.pageObjectKey, - ELEMENT_NOT_FOUND, - { selector } - ); - } - }, + } }; diff --git a/addon-test-support/-private/execution_context/native-events-context.js b/addon-test-support/-private/execution_context/native-events-context.js index 31f4d9b0..279b0c68 100644 --- a/addon-test-support/-private/execution_context/native-events-context.js +++ b/addon-test-support/-private/execution_context/native-events-context.js @@ -9,15 +9,10 @@ import { } from 'ember-native-dom-helpers'; import { run } from '../action'; -import { findClosestValue } from '../helpers'; import { fillElement, assertFocusable } from './helpers'; -import { - ELEMENT_NOT_FOUND, - throwBetterError -} from '../better-errors'; const KEYBOARD_EVENT_TYPES = ['keydown', 'keypress', 'keyup']; @@ -81,20 +76,5 @@ ExecutionContext.prototype = { blur(element); }, - - assertElementExists(selector, options) { - let container = options.testContainer || findClosestValue(this.pageObjectNode, 'testContainer'); - - let result = this.$(selector, container); - - if (result.length === 0) { - throwBetterError( - this.pageObjectNode, - options.pageObjectKey, - ELEMENT_NOT_FOUND, - { selector } - ); - } - }, }; diff --git a/addon-test-support/-private/execution_context/rfc268.js b/addon-test-support/-private/execution_context/rfc268.js index 5e813bab..085f1d90 100644 --- a/addon-test-support/-private/execution_context/rfc268.js +++ b/addon-test-support/-private/execution_context/rfc268.js @@ -1,6 +1,4 @@ -import $ from '-jquery'; import { run } from '../action'; -import { findClosestValue } from '../helpers'; import { getRootElement, visit, @@ -11,10 +9,6 @@ import { focus, blur } from '../compatibility'; -import { - ELEMENT_NOT_FOUND, - throwBetterError -} from '../better-errors'; export default function ExecutionContext(pageObjectNode) { this.pageObjectNode = pageObjectNode; @@ -57,36 +51,5 @@ ExecutionContext.prototype = { blur(element) { return blur(element); - }, - - assertElementExists(selector, options) { - let result = this.getElements(selector, options); - - if (result.length === 0) { - throwBetterError( - this.pageObjectNode, - options.pageObjectKey, - ELEMENT_NOT_FOUND, - { selector } - ); - } - }, - - getElements(selector, options) { - let container = options.testContainer || findClosestValue(this.pageObjectNode, 'testContainer'); - - return $(selector, container || this.testContainer); - }, - - invokeHelper(selector, options, helper, ...args) { - let element = this.getElements(selector, options)[0]; - return helper(element, ...args).catch((e) => { - throwBetterError( - this.pageObjectNode, - options.pageObjectKey, - e.message || e.toString(), - { selector } - ); - }); } };