Skip to content

Commit

Permalink
fix adapters re-export
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ro0gr committed Jan 6, 2021
1 parent 9467368 commit 7263154
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 25 deletions.
35 changes: 26 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 16 additions & 16 deletions tests/acceptance/rfc268-actions-test.js
Original file line number Diff line number Diff line change
@@ -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'),
Expand Down Expand Up @@ -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()
});
Expand Down
34 changes: 34 additions & 0 deletions tests/acceptance/rfc268-test.js
Original file line number Diff line number Diff line change
@@ -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, '');
});
});
}

0 comments on commit 7263154

Please sign in to comment.