Skip to content

Commit

Permalink
Cleanup execution contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0gr committed Mar 29, 2020
1 parent eb1087c commit 8e20854
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 103 deletions.
21 changes: 1 addition & 20 deletions addon-test-support/-private/execution_context/acceptance.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 }
);
}
},
}
};
27 changes: 1 addition & 26 deletions addon-test-support/-private/execution_context/integration.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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 }
);
}
},
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down Expand Up @@ -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 }
);
}
},
};

37 changes: 0 additions & 37 deletions addon-test-support/-private/execution_context/rfc268.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import $ from '-jquery';
import { run } from '../action';
import { findClosestValue } from '../helpers';
import {
getRootElement,
visit,
Expand All @@ -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;
Expand Down Expand Up @@ -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 }
);
});
}
};

0 comments on commit 8e20854

Please sign in to comment.