From ce464ec93da0edb88de9ef1d3abe48bd5f17f8b6 Mon Sep 17 00:00:00 2001 From: Ruslan Hrabovyi Date: Mon, 28 Dec 2020 00:29:11 +0200 Subject: [PATCH] fix adapters re-export there is a custom build flow to make the addon-test-support importable from the root of the package. This seems to be a bit more complicated to maintain then it could have been. Maybe exploring the Emberoider land could help us to simplify here. --- index.js | 35 ++++++++++++++++++------- tests/acceptance/rfc268-actions-test.js | 32 +++++++++++----------- tests/acceptance/rfc268-test.js | 34 ++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 25 deletions(-) create mode 100644 tests/acceptance/rfc268-test.js diff --git a/index.js b/index.js index 8a746eb6..2c8f8508 100644 --- a/index.js +++ b/index.js @@ -46,16 +46,33 @@ module.exports = { // `import { clickable } from 'ember-cli-page-object/test-support';` // // which is a default behavior in ember-cli - const reexportsTree = mergeTrees([ - 'index', - 'extend', - 'macros', - ].map(publicModuleName => - writeFile( - `/${this.moduleName()}/${publicModuleName}.js`, - `export * from '${this.moduleName()}/test-support/${publicModuleName}';` + const reexportsTree = mergeTrees( + [ + 'index', + 'extend', + 'macros', + 'adapter', + 'adapters', + ].map(publicModuleName => + writeFile( + `/${this.moduleName()}/${publicModuleName}.js`, + `export * from '${this.moduleName()}/test-support/${publicModuleName}';` + ) + ).concat( + [ + 'adapters/acceptance-native-events', + 'adapters/acceptance', + 'adapters/integration-native-events', + 'adapters/integration', + 'adapters/rfc268', + ].map(publicModuleName => + writeFile( + `/${this.moduleName()}/${publicModuleName}.js`, + `export { default } from '${this.moduleName()}/test-support/${publicModuleName}';` + ) + ) ) - )); + ); return mergeTrees([ testSupportTree, diff --git a/tests/acceptance/rfc268-actions-test.js b/tests/acceptance/rfc268-actions-test.js index 0b219c16..f6578758 100644 --- a/tests/acceptance/rfc268-actions-test.js +++ b/tests/acceptance/rfc268-actions-test.js @@ -1,28 +1,28 @@ import { module, test } from 'qunit'; import require from 'require'; -import PageObject from '../page-object'; +import { + clickable, + clickOnText, + collection, + create, + fillable, + isVisible, + value, + visitable +} from 'ember-cli-page-object'; import { alias } from 'ember-cli-page-object/macros'; -// intentionally not using our local extension in order to make -// sure, RFC268 works by default, w/o Adapter being set. -import { setupApplicationTest } from 'ember-qunit'; if (require.has('@ember/test-helpers')) { const { settled, waitUntil } = require('@ember/test-helpers'); + // intentionally not using our local extension in order to make + // sure, RFC268 works by default, w/o Adapter being set. + const { setupApplicationTest } = require('ember-qunit'); + module('Acceptance | actions [rfc268]', function(hooks) { setupApplicationTest(hooks); - let { - clickOnText, - clickable, - collection, - fillable, - isVisible, - value, - visitable - } = PageObject; - - let page = PageObject.create({ + let page = create({ visit: visitable('/calculator'), keys: { clickOn: clickOnText('.numbers'), @@ -233,7 +233,7 @@ if (require.has('@ember/test-helpers')) { }); test('fill in by attribute', async function(assert) { - let page = PageObject.create({ + let page = create({ visit: visitable('/inputs'), fillIn: fillable() }); diff --git a/tests/acceptance/rfc268-test.js b/tests/acceptance/rfc268-test.js new file mode 100644 index 00000000..58ba9c93 --- /dev/null +++ b/tests/acceptance/rfc268-test.js @@ -0,0 +1,34 @@ +import { module, test } from 'qunit'; +import require from 'require'; +import Rfc268Adapter from 'ember-cli-page-object/adapters/rfc268'; +import { setAdapter } from 'ember-cli-page-object/adapters'; +import { create, value, visitable } from 'ember-cli-page-object'; + +if (require.has('@ember/test-helpers')) { + // intentionally not using our local extension in order to make + // sure, RFC268 works by default, w/o Adapter being set. + const { setupApplicationTest } = require('ember-qunit'); + + module('Acceptance | rfc268', function(hooks) { + setupApplicationTest(hooks); + + hooks.beforeEach(function() { + setAdapter(new Rfc268Adapter); + }) + + hooks.afterEach(function() { + setAdapter(null); + }) + + let page = create({ + visit: visitable('/calculator'), + screen: value('.screen input'), + }); + + test('it works', async function(assert) { + await page.visit(); + + assert.equal(page.screen, ''); + }); + }); +}