From 8e7d12e3cba3f2dbe70fe0a69f15c34ec7f9ed65 Mon Sep 17 00:00:00 2001 From: Joe Wroten Date: Sun, 16 Dec 2018 15:26:30 -0600 Subject: [PATCH] Download alert has expected content --- app/components/file-table.js | 6 ++++++ app/templates/components/file-table.hbs | 6 +++++- tests/integration/components/file-table-test.js | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/components/file-table.js b/app/components/file-table.js index 38ca04c..830d03c 100644 --- a/app/components/file-table.js +++ b/app/components/file-table.js @@ -15,6 +15,12 @@ export default Component.extend({ } else return this.selectedFilePaths.length === 0 ? 'none' : 'some'; }), + selectedFileDownloads: computed('selectedFilePaths.[]', 'files.@each.{status,path}', function() { + return this.selectedFilePaths.map(path => { + return this.files.find(file => file.status === 'available' && file.path === path); + }) + }), + actions: { downloadSelected() { set(this, 'showDownloadAlert', true); diff --git a/app/templates/components/file-table.hbs b/app/templates/components/file-table.hbs index e2f99fe..569407a 100644 --- a/app/templates/components/file-table.hbs +++ b/app/templates/components/file-table.hbs @@ -9,7 +9,11 @@ > Close - Foo +
    + {{#each selectedFileDownloads as | file |}} +
  1. {{file.device}}: {{file.path}}
  2. + {{/each}} +
{{/if}} diff --git a/tests/integration/components/file-table-test.js b/tests/integration/components/file-table-test.js index 76624f5..ddbb7de 100644 --- a/tests/integration/components/file-table-test.js +++ b/tests/integration/components/file-table-test.js @@ -90,11 +90,15 @@ module('Integration | Component | file-table', function(hooks) { test('it handles showing download device/path for selected available files', async function(assert) { this.set('files', [genericFile(), genericFile()]); + this.set('files.1.status', 'scheduled'); await render(hbs`{{file-table files=files}}`); await click('[data-test-action=file-table-select-all]'); await click('[data-test-action=file-table-download-selected]'); assert.ok(find('[data-test-id=file-table-download-alert]'), 'Renders download alert wrapper'); + assert.equal(find('[data-test-id=file-table-download-alert]').innerText.includes(this.files[0].device), true, 'Renders first file device'); + assert.equal(find('[data-test-id=file-table-download-alert]').innerText.includes(this.files[0].path), true, 'Renders first file path'); + assert.equal(find('[data-test-id=file-table-download-alert]').innerText.includes(this.files[1].path), false, 'Does NOT render second file path'); await click('[data-test-action=file-table-download-close]'); assert.notOk(find('[data-test-id=file-table-download-alert]'), 'Closes download alert wrapper');