Skip to content

Commit

Permalink
Display basic table with ember-try pass/fail for each scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
pgengler committed Oct 31, 2019
1 parent 2feaadc commit 0b33216
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 11 deletions.
8 changes: 8 additions & 0 deletions app/components/build-result-summary-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Component from '@ember/component';
import { readOnly } from '@ember/object/computed';

export default Component.extend({
tagName: '',

scenarios: readOnly('results.scenarios')
});
24 changes: 13 additions & 11 deletions app/models/test-result.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { readOnly } from '@ember/object/computed';
import DS from 'ember-data';
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';

export default DS.Model.extend({
succeeded: DS.attr('boolean'),
statusMessage: DS.attr('string'),
createdAt: DS.attr('date'),
canary: DS.attr('boolean'),
output: DS.attr('string'),
outputFormat: DS.attr('string'),
semverString: DS.attr('string'),
export default Model.extend({
succeeded: attr('boolean'),
statusMessage: attr('string'),
createdAt: attr('date'),
canary: attr('boolean'),
output: attr('string'),
outputFormat: attr('string'),
semverString: attr('string'),
emberTryResults: attr(),

version: belongsTo('version'),
emberVersionCompatibilities: hasMany('emberVersionCompatibility'),

version: DS.belongsTo('version'),
emberVersionCompatibilities: DS.hasMany('emberVersionCompatibility'),
testsRunAt: readOnly('createdAt')
});
4 changes: 4 additions & 0 deletions app/templates/admin/build-results/show.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
</span>
</div>

{{#if buildResult.emberTryResults}}
<BuildResultSummaryTable @results={{buildResult.emberTryResults}} />
{{/if}}

<h2>Output</h2>
<BuildResultOutput @buildResult={{buildResult}} />
</div>
25 changes: 25 additions & 0 deletions app/templates/components/build-result-summary-table.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<table data-test-results-table>
<thead>
<tr>
<th>Scenario</th>
<th>Result</th>
</tr>
</thead>
<tbody>
{{#each this.scenarios as |scenario|}}
<tr>
<td>{{scenario.scenarioName}}</td>
<td>
{{#if scenario.passed}}
Passed
{{else}}
Failed
{{#if scenario.allowedToFail}}
(allowed)
{{/if}}
{{/if}}
</td>
</tr>
{{/each}}
</tbody>
</table>
32 changes: 32 additions & 0 deletions tests/acceptance/build-results-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { findAll, click, currentURL, currentRouteName, visit } from '@ember/test
import { module, test } from 'qunit';
import { percySnapshot } from 'ember-percy';
import { setupEmberObserverTest } from '../helpers/setup-ember-observer-test';
import emberTryScenario from 'ember-observer/tests/helpers/ember-try-scenario';
import findByText from '../helpers/find-by-text';
import login from 'ember-observer/tests/helpers/login';
import moment from 'moment';
Expand Down Expand Up @@ -234,5 +235,36 @@ module('Acceptance | build results', function(hooks) {

assert.dom('.test-retry-build').doesNotExist('no "retry" button should be displayed');
});

test('when test result has ember-try results, displays a summary table', async function(assert) {
let testResult = server.create('testResult', {
version: server.create('version'),
succeeded: true,
emberTryResults: {
scenarios: [
emberTryScenario('3.4'),
emberTryScenario('3.8'),
emberTryScenario('3.12'),
emberTryScenario('3.13')
]
}
});

await visit(`/admin/build-results/${testResult.id}`);

assert.dom('[data-test-results-table]').exists();
});

test('when test result does not have ember-try results, does not display summary table', async function(assert) {
let testResult = server.create('testResult', {
version: server.create('version'),
succeeded: true,
emberTryResults: null
});

await visit(`/admin/build-results/${testResult.id}`);

assert.dom('[data-test-results-table]').doesNotExist();
});
});
});
15 changes: 15 additions & 0 deletions tests/helpers/ember-try-scenario.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default function emberTryScenario(version) {
return {
scenarioName: `ember-${version}`,
passed: true,
allowedToFail: false,
dependencies: [
{
name: 'ember-source',
versionSeen: `${version}.2`,
versionExpected: `${version}.0`,
type: 'yarn'
}
]
};
}
60 changes: 60 additions & 0 deletions tests/integration/components/build-result-summary-table-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

import emberTryScenario from 'ember-observer/tests/helpers/ember-try-scenario';

module('Integration | Component | build-result-summary-table', function(hooks) {
setupRenderingTest(hooks);

test('displays a row for each scenario in the provided results', async function(assert) {
this.emberTryResults = {
scenarios: [
emberTryScenario('3.4'),
emberTryScenario('3.8'),
emberTryScenario('3.12'),
emberTryScenario('3.13'),
]
};

await render(hbs`
<BuildResultSummaryTable @results={{this.emberTryResults}} />
`);

assert.dom('table tbody tr').exists({ count: 4 });
});

test('displays information for a scenario', async function(assert) {
let scenario = emberTryScenario('3.13');
this.emberTryResults = {
scenarios: [
scenario
]
};

await render(hbs`
<BuildResultSummaryTable @results={{this.emberTryResults}} />
`);

assert.dom('tbody tr td:nth-child(1)').hasText(scenario.scenarioName, 'displays scenario name in first column');
assert.dom('tbody tr td:nth-child(2)').hasText('Passed', 'displays result in second column');
});

test('when an allowed-to-fail scenario fails, result text reflects that', async function(assert) {
let scenario = emberTryScenario('3.13');
scenario.allowedToFail = true;
scenario.passed = false;
this.emberTryResults = {
scenarios: [
scenario
]
};

await render(hbs`
<BuildResultSummaryTable @results={{this.emberTryResults}} />
`);

assert.dom('tbody tr td:nth-child(2)').hasText('Failed (allowed)');
});
});

0 comments on commit 0b33216

Please sign in to comment.