From 0b33216dbd881427b2d0a1621fd785f86bedb4be Mon Sep 17 00:00:00 2001 From: Phil Gengler Date: Sun, 20 Oct 2019 16:42:33 -0400 Subject: [PATCH] Display basic table with ember-try pass/fail for each scenario --- app/components/build-result-summary-table.js | 8 +++ app/models/test-result.js | 24 ++++---- app/templates/admin/build-results/show.hbs | 4 ++ .../components/build-result-summary-table.hbs | 25 ++++++++ tests/acceptance/build-results-test.js | 32 ++++++++++ tests/helpers/ember-try-scenario.js | 15 +++++ .../build-result-summary-table-test.js | 60 +++++++++++++++++++ 7 files changed, 157 insertions(+), 11 deletions(-) create mode 100644 app/components/build-result-summary-table.js create mode 100644 app/templates/components/build-result-summary-table.hbs create mode 100644 tests/helpers/ember-try-scenario.js create mode 100644 tests/integration/components/build-result-summary-table-test.js diff --git a/app/components/build-result-summary-table.js b/app/components/build-result-summary-table.js new file mode 100644 index 00000000..78fb298c --- /dev/null +++ b/app/components/build-result-summary-table.js @@ -0,0 +1,8 @@ +import Component from '@ember/component'; +import { readOnly } from '@ember/object/computed'; + +export default Component.extend({ + tagName: '', + + scenarios: readOnly('results.scenarios') +}); diff --git a/app/models/test-result.js b/app/models/test-result.js index f0a5387c..b7715442 100644 --- a/app/models/test-result.js +++ b/app/models/test-result.js @@ -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') }); diff --git a/app/templates/admin/build-results/show.hbs b/app/templates/admin/build-results/show.hbs index 7220f654..4dbe0121 100644 --- a/app/templates/admin/build-results/show.hbs +++ b/app/templates/admin/build-results/show.hbs @@ -23,6 +23,10 @@ + {{#if buildResult.emberTryResults}} + + {{/if}} +

Output

diff --git a/app/templates/components/build-result-summary-table.hbs b/app/templates/components/build-result-summary-table.hbs new file mode 100644 index 00000000..b4d4d3a1 --- /dev/null +++ b/app/templates/components/build-result-summary-table.hbs @@ -0,0 +1,25 @@ + + + + + + + + + {{#each this.scenarios as |scenario|}} + + + + + {{/each}} + +
ScenarioResult
{{scenario.scenarioName}} + {{#if scenario.passed}} + Passed + {{else}} + Failed + {{#if scenario.allowedToFail}} + (allowed) + {{/if}} + {{/if}} +
diff --git a/tests/acceptance/build-results-test.js b/tests/acceptance/build-results-test.js index eaea05d6..3450fdbe 100644 --- a/tests/acceptance/build-results-test.js +++ b/tests/acceptance/build-results-test.js @@ -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'; @@ -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(); + }); }); }); diff --git a/tests/helpers/ember-try-scenario.js b/tests/helpers/ember-try-scenario.js new file mode 100644 index 00000000..56fdaf63 --- /dev/null +++ b/tests/helpers/ember-try-scenario.js @@ -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' + } + ] + }; +} diff --git a/tests/integration/components/build-result-summary-table-test.js b/tests/integration/components/build-result-summary-table-test.js new file mode 100644 index 00000000..eed381e1 --- /dev/null +++ b/tests/integration/components/build-result-summary-table-test.js @@ -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` + + `); + + 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` + + `); + + 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` + + `); + + assert.dom('tbody tr td:nth-child(2)').hasText('Failed (allowed)'); + }); +});