Skip to content

Commit

Permalink
Ember 3.5 (#206)
Browse files Browse the repository at this point in the history
* added ember-cli-update

* ran update to 3.0.4

* ran codemods

* Finalized and all tests passing

* updated exportable helpers

* rm MODULE_REPORT.md

* Use yarn in travis.yml

* Remove commented debug code

* Remove double await

* remove ember-cli-update

* Cleanup helper and correctly wait for async

* re-remove ember-invoke-action

* Fix offsetFn in test

* useYarn: true in ember-try

* undo readme change

* ember-cli 3.5

* let 2.16 fail for now

* re-add node 4

* fix '
  • Loading branch information
jmar910 authored and Dhaulagiri committed Nov 16, 2018
1 parent 874d9d1 commit 051db59
Show file tree
Hide file tree
Showing 32 changed files with 3,142 additions and 2,896 deletions.
20 changes: 20 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
18 changes: 7 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,20 @@ module.exports = {
// node files
{
files: [
'.eslintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'index.js',
'testem.js',
'ember-cli-build.js',
'blueprints/*/index.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
],
excludedFiles: [
'addon/**',
'addon-test-support/**',
'app/**',
'addon/**'
'tests/dummy/app/**'
],
parserOptions: {
sourceType: 'script',
Expand All @@ -43,15 +48,6 @@ module.exports = {
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here
})
},

// test files
{
files: ['tests/**/*.js'],
excludedFiles: ['tests/dummy/**/*.js'],
env: {
embertest: true
}
}
]
};
22 changes: 11 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/dist/
/tmp/

# dependencies
/node_modules
/bower_components
/bower_components/
/node_modules/

# misc
/.sass-cache
/connect.lock
/coverage/*
/coverage/
/libpeerconnection.log
npm-debug.log*
yarn-error.log
testem.log
/npm-debug.log*
/testem.log
/yarn-error.log

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
44 changes: 26 additions & 18 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
/bower_components
# compiled output
/dist/
/tmp/

# dependencies
/bower_components/

# misc
/.bowerrc
/.editorconfig
/.ember-cli
/.eslintignore
/.eslintrc.js
/.gitignore
/.template-lintrc.js
/.travis.yml
/.watchmanconfig
/bower.json
/config/ember-try.js
/dist
/tests
/tmp
**/.gitkeep
.bowerrc
.editorconfig
.ember-cli
.eslintrc.js
.gitignore
.watchmanconfig
.travis.yml
bower.json
ember-cli-build.js
testem.js
/ember-cli-build.js
/testem.js
/tests/
/yarn.lock
.gitkeep

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
5 changes: 5 additions & 0 deletions .template-lintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
extends: 'recommended'
};
39 changes: 24 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,32 @@ env:
global:
# See https://git.io/vdao3 for details.
- JOBS=1
matrix:

jobs:
fail_fast: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary
- env: EMBER_TRY_SCENARIO=ember-lts-2.16

include:
# runs linting and tests with current locked deps

- stage: "Tests"
name: "Tests"
script:
- yarn run lint:hbs
- yarn run lint:js
- yarn test

# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.12
- EMBER_TRY_SCENARIO=ember-lts-2.16
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default

matrix:
fast_finish: true
allow_failures:
- stage: "Additional Tests"
env: EMBER_TRY_SCENARIO=ember-lts-2.16
- env: EMBER_TRY_SCENARIO=ember-lts-2.18
- env: EMBER_TRY_SCENARIO=ember-release
- env: EMBER_TRY_SCENARIO=ember-beta
- env: EMBER_TRY_SCENARIO=ember-canary
- env: EMBER_TRY_SCENARIO=ember-default-with-jquery

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
Expand All @@ -41,7 +53,4 @@ install:
- yarn install --no-lockfile --non-interactive

script:
- npm run lint:js
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO
6 changes: 3 additions & 3 deletions addon/components/sortable-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export default Component.extend({
*/
itemPosition: computed(function() {
let direction = this.get('direction');

return this.get(`sortedItems.firstObject.${direction}`) - this.get('sortedItems.firstObject.spacing');
const firstObject = this.get('sortedItems').objectAt(0)
return get(firstObject, direction) - get(firstObject, 'spacing');
}).volatile(),

/**
Expand All @@ -52,7 +52,6 @@ export default Component.extend({
sortedItems: computed(function() {
let items = a(this.get('items'));
let direction = this.get('direction');

return a(items.sortBy(direction));
}).volatile(),

Expand Down Expand Up @@ -90,6 +89,7 @@ export default Component.extend({
*/
update() {
let sortedItems = this.get('sortedItems');

// Position of the first element
let position = this._itemPosition;

Expand Down
115 changes: 48 additions & 67 deletions addon/helpers/drag.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { registerAsyncHelper } from '@ember/test';
import $ from 'jquery';
import { triggerEvent, settled } from '@ember/test-helpers'
import { assert } from '@ember/debug'

/**
Drags elements by an offset specified in pixels.
Expand All @@ -26,15 +27,9 @@ import $ from 'jquery';
@return {Promise}
*/

export function drag(app, mode, itemSelector, offsetFn, callbacks = {}) {
export async function drag(mode, itemSelector, offsetFn, callbacks = {}) {
let start, move, end, which;

const {
andThen,
findWithAssert,
wait
} = app.testHelpers;

if (mode === 'mouse') {
start = 'mousedown';
move = 'mousemove';
Expand All @@ -47,66 +42,52 @@ export function drag(app, mode, itemSelector, offsetFn, callbacks = {}) {
} else {
throw new Error(`Unsupported mode: '${mode}'`);
}
let item = $(itemSelector);
assert(`could not find item: ${itemSelector}`, !!item)

let itemOffset = item.offset();

let offset = offsetFn();

let itemElement = item.get(0);
let rect = itemElement.getBoundingClientRect();
let scale = itemElement.clientHeight / (rect.bottom - rect.top);
let halfwayX = itemOffset.left + (offset.dx * scale) / 2;
let halfwayY = itemOffset.top + (offset.dy * scale) / 2;
let targetX = itemOffset.left + offset.dx * scale;
let targetY = itemOffset.top + offset.dy * scale;

const getCoords = (x,y) => ({
pageX: x,
pageY: y,
clientX: x,
clientY: y,
changedTouches: [{ screenX: x, screenY: y }],
which
})

await triggerEvent(itemElement, start, getCoords(itemOffset.left, itemOffset.top));

if (callbacks.dragstart) {
await callbacks.dragstart;
}
await triggerEvent(itemElement, move, getCoords(itemOffset.left, itemOffset.top));

andThen(() => {
let item = findWithAssert(itemSelector);
let itemOffset = item.offset();
let offset = offsetFn();
let itemElement = item.get(0);
let rect = itemElement.getBoundingClientRect();
let scale = itemElement.clientHeight / (rect.bottom - rect.top);
let halfwayX = itemOffset.left + (offset.dx * scale) / 2;
let halfwayY = itemOffset.top + (offset.dy * scale) / 2;
let targetX = itemOffset.left + offset.dx * scale;
let targetY = itemOffset.top + offset.dy * scale;

triggerEvent(app, item, start, {
pageX: itemOffset.left,
pageY: itemOffset.top,
which
});

if (callbacks.dragstart) {
andThen(callbacks.dragstart);
}

triggerEvent(app, item, move, {
pageX: itemOffset.left,
pageY: itemOffset.top
});

if (callbacks.dragmove) {
andThen(callbacks.dragmove);
}

triggerEvent(app, item, move, {
pageX: halfwayX,
pageY: halfwayY
});

triggerEvent(app, item, move, {
pageX: targetX,
pageY: targetY
});

triggerEvent(app, item, end, {
pageX: targetX,
pageY: targetY
});

if (callbacks.dragend) {
andThen(callbacks.dragend);
}
});

return wait();
}
if (callbacks.dragmove) {
await callbacks.dragmove;
}

await triggerEvent(itemElement, move, getCoords(halfwayX, halfwayY));

await triggerEvent(itemElement, move, getCoords(targetX, targetY));

await triggerEvent(itemElement, end, getCoords(targetX, targetY));

if (callbacks.dragend) {
await callbacks.dragend
}

function triggerEvent(app, el, type, props) {
return app.testHelpers.andThen(() => {
let event = $.Event(type, props);
$(el).trigger(event);
});
return await settled();
}

export default registerAsyncHelper('drag', drag);
export default drag;
2 changes: 2 additions & 0 deletions addon/helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as reorder } from './reorder'
export { default as drag } from './drag'
Loading

0 comments on commit 051db59

Please sign in to comment.