Skip to content

Commit

Permalink
Merge pull request #4 from mvdwg/update-to-json-format-v2
Browse files Browse the repository at this point in the history
Update to json format and add player in inner route
  • Loading branch information
hidnasio authored Sep 15, 2016
2 parents 4a14787 + f4239e5 commit a3dc20b
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 49 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ matrix:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary
- env: EMBER_TRY_SCENARIO=ember-beta

before_install:
- npm config set spin false
Expand Down
24 changes: 0 additions & 24 deletions addon/components/feature-item.js

This file was deleted.

2 changes: 1 addition & 1 deletion addon/components/feature-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Component = Ember.Component.extend({
text: computed('feature', function() {
let feature = this.get('feature');

return Ember.String.capitalize(feature.name.replace(/^Acceptance \|\s*/, ''));
return Ember.String.capitalize(feature.module.replace(/^Acceptance \|\s*/, ''));
})
});

Expand Down
4 changes: 3 additions & 1 deletion addon/routes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import buildRoutes from 'ember-engines/routes';

export default buildRoutes(function() {
this.route('stories', { path: '/' });
this.route('stories', { path: '/' }, function() {
this.route('story', { path: ':testId' });
});
});
2 changes: 1 addition & 1 deletion addon/routes/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export default Ember.Route.extend({
setupController(controller, model) {
this._super(...arguments);

controller.set('modules', model);
controller.set('features', model);
}
});
26 changes: 26 additions & 0 deletions addon/routes/stories/story.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Ember from 'ember';

function findModuleAndTest(features, id) {
let test;
let i = -1;

while (!test && features[++i]) {
test = Ember.A(features[i].tests).findBy('id', id);
}

if (test) {
return { module: features[i].module, test: test.name };
}
}

export default Ember.Route.extend({
model(params) {
let model = findModuleAndTest(this.modelFor('stories'), params.testId);

return model;
},

setupController(controller, model) {
controller.set('url', `/tests/index.html?tellingStories&module=${encodeURIComponent(model.module)}&filter=${encodeURIComponent(model.test)}`);
}
});
1 change: 0 additions & 1 deletion addon/templates/components/feature-item.hbs

This file was deleted.

10 changes: 5 additions & 5 deletions addon/templates/stories.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<header class="ts-header">
<h1>Features</h1>
</header>
{{#each modules as |module|}}
{{feature-module module}}
{{#each features as |feature|}}
{{feature-module feature}}

<nav>
{{#each module.tests as |test|}}
{{feature-item module test}}
{{#each feature.tests as |test|}}
{{#link-to 'stories.story' test.id class="ts-feature-item"}}{{test.name}}{{/link-to}}
{{/each}}
</nav>
{{/each}}
</div>

<iframe class="ts-player" id="tsplayer" name="tsplayer" src="data:text/plain,Pick a feature"></iframe>
{{outlet}}
</main>
1 change: 1 addition & 0 deletions addon/templates/stories/story.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<iframe class="ts-player" id="tsplayer" name="tsplayer" src={{url}}></iframe>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"ember-disable-prototype-extensions": "^1.1.0",
"ember-export-application-global": "^1.0.5",
"ember-load-initializers": "^0.5.1",
"ember-qunit-nice-errors": "1.1.2",
"ember-resolver": "^2.0.3",
"loader.js": "^4.0.1"
},
Expand Down
14 changes: 4 additions & 10 deletions tests/acceptance/features-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,22 @@ test('view the list of features', function(assert) {
assert.equal(find('.ts-feature-list__title:first').text().trim(), 'Favorites');
assert.equal(find('.ts-feature-item').length, 4);
assert.equal(find('.ts-feature-item:first').text().trim(), 'User favorites email from inbox');
assert.equal(find('.ts-player').attr('src'), 'data:text/plain,Pick a feature');

let uri = find('.ts-feature-item:first').attr('href');

assert.ok(uri.indexOf('tellingStories') > -1);
assert.ok(uri.indexOf(encodeURIComponent('User favorites email from inbox')) > -1);
assert.ok(uri.indexOf(encodeURIComponent('Acceptance | favorites')) > -1);
assert.equal(find('.ts-feature-item').attr('href'), '/telling-stories-dashboard/12345');
});
});

test('view one feature', function(assert) {
visit('/telling-stories-dashboard');
visit('/telling-stories-dashboard/12345');

andThen(function() {
assert.equal(currentURL(), '/telling-stories-dashboard');
assert.equal(currentURL(), '/telling-stories-dashboard/12345');
assert.equal(find('.ts-feature-list__title').length, 2);
assert.equal(find('.ts-feature-list__title:first').text().trim(), 'Favorites');
assert.equal(find('.ts-feature-item').length, 4);
assert.equal(find('.ts-feature-item:first').text().trim(), 'User favorites email from inbox');
assert.equal(find('.ts-player').attr('src'), 'data:text/plain,Pick a feature');

let uri = find('.ts-feature-item:first').attr('href');
let uri = find('.ts-player').attr('src');

assert.ok(uri.indexOf('tellingStories') > -1);
assert.ok(uri.indexOf(encodeURIComponent('User favorites email from inbox')) > -1);
Expand Down
24 changes: 18 additions & 6 deletions tests/dummy/public/telling-stories.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
[
{
"name": "Acceptance | favorites",
"module": "Acceptance | favorites",
"tests": [
"User favorites email from inbox",
"User favorites email from sent"
{
"id": "12345",
"name": "User favorites email from inbox"
},
{
"id": "6789",
"name": "User favorites email from sent"
}
]
},
{
"name": "Acceptance | user writes an email",
"module": "Acceptance | user writes an email",
"tests": [
"User replies an emaill",
"User writes and send an email from scratch"
{
"id": "54321",
"name": "User replies an emaill"
},
{
"id": "9876",
"name": "User writes and send an email from scratch"
}
]
}
]

0 comments on commit a3dc20b

Please sign in to comment.