Skip to content

Commit

Permalink
Merge pull request #30 from mvdwg/start-and-end-animations
Browse files Browse the repository at this point in the history
Start and end animations
  • Loading branch information
san650 authored Feb 1, 2017
2 parents a82f031 + 701979a commit ab24a51
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 18 deletions.
20 changes: 20 additions & 0 deletions addon/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,29 @@ function scrollToElement($element) {
}, SCROLL_SPEED);
}

function finish() {
$('body').fadeOut(3000).fadeIn(0);
return sleep(3000);
}

function osd(text, timeout) {
timeout = timeout || 3000;

$('<div>', {
text,
class: 'tsOSD'
})
.appendTo($('body'))
.animate({
opacity: 1
}, timeout, function() { $(this).remove(); });
}

export default {
pointer,
movePointerTo,
finish,
osd,
clickEffectBefore() {
return () => clickEffectBefore();
},
Expand Down
29 changes: 28 additions & 1 deletion addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,35 @@ export function shutdown(returnValue) {
let promise = RSVP.resolve(returnValue);

if (window.QUnit && window.QUnit.urlParams.tellingStories) {
return Animation.sleep(3000)().then(() => promise);
return Animation.finish().then(() => promise);
}

return promise;
}

export function suiteStart(totalTests) {
console.log(`Test suite starts. Total tests: ${totalTests}`);
}

export function suiteEnd() {
console.log('Test suite ends');
}

export function moduleStart(name) {
console.log(`Module starts: ${name}`);
}

export function moduleEnd() {
console.log('Module ends');
}

export function testStart(context) {
console.log(`Test starts: %o`, context);
if (/^Acceptance/.test(context.module)) {
Animation.osd(context.name);
}
}

export function testEnd() {
console.log(`Test ends`);
}
31 changes: 19 additions & 12 deletions addon/page-object-execution-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function TellingStoriesContext(pageObjectNode) {
this.pageObjectNode = pageObjectNode;
}

let previousElement = null;
// let previousElement = null;

TellingStoriesContext.prototype = {
run(cb) {
Expand All @@ -26,9 +26,12 @@ TellingStoriesContext.prototype = {
visit(path) {
/* global visit */
visit(path);
wait().then(Animation.sleep(3000));
},

click(selector, container) {
container = container || '#ember-testing';

/* global wait */
wait()
.then(Animation.movePointerTo(selector, container))
Expand All @@ -41,6 +44,8 @@ TellingStoriesContext.prototype = {
},

fillIn(selector, container, text) {
container = container || '#ember-testing';

/* global wait */
wait()
.then(Animation.movePointerTo(selector, container))
Expand All @@ -55,6 +60,8 @@ TellingStoriesContext.prototype = {
},

triggerEvent(selector, container, eventName, eventOptions) {
container = container || '#ember-testing';

/* global wait */
wait().then(Animation.sleep(500));

Expand All @@ -76,7 +83,7 @@ TellingStoriesContext.prototype = {
selector = buildSelector(this.pageObjectNode, selector, options);

/* global find */
result = find(selector, options.testContainer);
result = find(selector, options.testContainer || findClosestValue(this.pageObjectNode, 'testContainer'));

this.attention(result);

Expand All @@ -100,15 +107,15 @@ TellingStoriesContext.prototype = {
return result;
},

attention(element) {
wait().then(() => {
if (previousElement) {
previousElement.removeClass('tsAttention');
}

previousElement = element.addClass('tsAttention');

return Animation.sleep(1000)();
});
attention(/* element */) {
// wait().then(() => {
// if (previousElement) {
// previousElement.removeClass('tsAttention');
// }
//
// previousElement = element.addClass('tsAttention');
//
// return Animation.sleep(1000)();
// });
}
};
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {

this._super.included.apply(this, arguments);

app.import('vendor/telling-stories/qunit-configuration.js', { type: 'test' });
app.import('vendor/telling-stories/qunit-configuration.js', { type: 'test', prepend: true });
app.import('vendor/telling-stories/player-mode.css', { type: 'test' });
},

Expand Down
12 changes: 12 additions & 0 deletions vendor/telling-stories/player-mode.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,15 @@
75% { opacity: .5; }
100% { opacity: 1; }
}

.tsOSD {
position: fixed;
top: 150px;
left: 150px;
font-size: 40px;
z-index: 99999;
padding: 20px 40px;
background: rgba(255,255,255,0.8);
border-radius: 5px;
box-shadow: 0 0 5px black;
}
19 changes: 15 additions & 4 deletions vendor/telling-stories/qunit-configuration.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
jQuery(function() {
if (window.QUnit) {
window.QUnit.config.urlConfig.push({
var qunit = window.QUnit;

if (qunit) {
qunit.config.urlConfig.push({
id: 'tellingStories',
label: 'Tell me the story'
});

if (window.QUnit.urlParams.tellingStories) {
window.QUnit.urlParams.devmode = true;
if (qunit.urlParams.tellingStories) {
qunit.urlParams.devmode = true;
$('body').addClass('telling-stories');

var callbacks = require('telling-stories');

qunit.begin(callbacks.suiteStart);
qunit.done(callbacks.suiteEnd);
qunit.moduleStart(callbacks.moduleStart);
qunit.moduleDone(callbacks.moduleEnd);
qunit.testStart(callbacks.testStart);
qunit.testDone(callbacks.testEnd);
}
}
});

0 comments on commit ab24a51

Please sign in to comment.