From c9115be63f7c48e6c5e0cc858a4f9a1f3ae6b1c8 Mon Sep 17 00:00:00 2001 From: daveconnis Date: Wed, 20 Dec 2017 15:48:41 -0500 Subject: [PATCH 01/17] added conversation-part-closed component --- .../conversations/conversation-part-closed.js | 20 +++++++++++++++ .../conversation-part-closed.hbs | 9 +++++++ .../conversation-part-closed-test.js | 25 +++++++++++++++++++ .../conversations/conversation-part-closed.js | 7 ++++++ 4 files changed, 61 insertions(+) create mode 100644 app/components/conversations/conversation-part-closed.js create mode 100644 app/templates/components/conversations/conversation-part-closed.hbs create mode 100644 tests/integration/components/conversations/conversation-part-closed-test.js create mode 100644 tests/pages/components/conversations/conversation-part-closed.js diff --git a/app/components/conversations/conversation-part-closed.js b/app/components/conversations/conversation-part-closed.js new file mode 100644 index 000000000..426b99c90 --- /dev/null +++ b/app/components/conversations/conversation-part-closed.js @@ -0,0 +1,20 @@ +import Component from '@ember/component'; +import { inject as service } from '@ember/service'; +import { computed, get } from '@ember/object'; + +export default Component.extend({ + classNames: ['conversation-part-closed'], + + closedAt: null, + + currentUser: service(), + + isSelf: computed('author', 'user', function() { + return get(this, 'author.id') === get(this, 'user.id'); + + closedUser: computed ('isSelf', 'currentUser', function() { + if + }) + }) + }) +}); diff --git a/app/templates/components/conversations/conversation-part-closed.hbs b/app/templates/components/conversations/conversation-part-closed.hbs new file mode 100644 index 000000000..d586a427f --- /dev/null +++ b/app/templates/components/conversations/conversation-part-closed.hbs @@ -0,0 +1,9 @@ +
+
+ {{if currentUser}} + You closed this at... + {{else}} +
+ {{author.username}} closed this at... +
+
diff --git a/tests/integration/components/conversations/conversation-part-closed-test.js b/tests/integration/components/conversations/conversation-part-closed-test.js new file mode 100644 index 000000000..dda4db4cc --- /dev/null +++ b/tests/integration/components/conversations/conversation-part-closed-test.js @@ -0,0 +1,25 @@ +import { moduleForComponent, test } from 'ember-qunit'; +import hbs from 'htmlbars-inline-precompile'; + +moduleForComponent('conversations/conversation-part-closed', 'Integration | Component | conversations/conversation part closed', { + integration: true +}); + +test('it renders', function(assert) { + + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); + + this.render(hbs`{{conversations/conversation-part-closed}}`); + + assert.equal(this.$().text().trim(), ''); + + // Template block usage: + this.render(hbs` + {{#conversations/conversation-part-closed}} + template block text + {{/conversations/conversation-part-closed}} + `); + + assert.equal(this.$().text().trim(), 'template block text'); +}); diff --git a/tests/pages/components/conversations/conversation-part-closed.js b/tests/pages/components/conversations/conversation-part-closed.js new file mode 100644 index 000000000..385d7591d --- /dev/null +++ b/tests/pages/components/conversations/conversation-part-closed.js @@ -0,0 +1,7 @@ +import { + text +} from 'ember-cli-page-object'; + +export default { + title: text('h1') +}; From bd476e458e6a0e3198bf5aac6e75f0dc23af2e35 Mon Sep 17 00:00:00 2001 From: daveconnis Date: Thu, 21 Dec 2017 12:14:09 -0500 Subject: [PATCH 02/17] changed component name from conversation-part to conversation-part-comment --- .../conversations/conversation-part-closed.js | 4 +- ...n-part.js => conversation-part-comment.js} | 4 +- .../conversation-part-closed.scss | 61 +++++++++++++++++++ .../conversation-part-closed.hbs | 10 +-- ...part.hbs => conversation-part-comment.hbs} | 10 +-- ...t.js => conversation-part-comment-test.js} | 4 +- ...n-part.js => conversation-part-comment.js} | 2 +- 7 files changed, 77 insertions(+), 18 deletions(-) rename app/components/conversations/{conversation-part.js => conversation-part-comment.js} (83%) create mode 100644 app/styles/components/conversations/conversation-part-closed.scss rename app/templates/components/conversations/{conversation-part.hbs => conversation-part-comment.hbs} (77%) rename tests/integration/components/conversations/{conversation-part-test.js => conversation-part-comment-test.js} (93%) rename tests/pages/components/conversations/{conversation-part.js => conversation-part-comment.js} (92%) diff --git a/app/components/conversations/conversation-part-closed.js b/app/components/conversations/conversation-part-closed.js index 426b99c90..f27a10b6f 100644 --- a/app/components/conversations/conversation-part-closed.js +++ b/app/components/conversations/conversation-part-closed.js @@ -12,9 +12,7 @@ export default Component.extend({ isSelf: computed('author', 'user', function() { return get(this, 'author.id') === get(this, 'user.id'); - closedUser: computed ('isSelf', 'currentUser', function() { - if - }) + }) }) }); diff --git a/app/components/conversations/conversation-part.js b/app/components/conversations/conversation-part-comment.js similarity index 83% rename from app/components/conversations/conversation-part.js rename to app/components/conversations/conversation-part-comment.js index 5874ff2f0..92a734904 100644 --- a/app/components/conversations/conversation-part.js +++ b/app/components/conversations/conversation-part-comment.js @@ -4,8 +4,8 @@ import { alias } from '@ember/object/computed'; import { inject as service } from '@ember/service'; export default Component.extend({ - classNames: ['conversation-part'], - classNameBindings: ['isSelf:conversation-part--is-self'], + classNames: ['conversation-part-comment'], + classNameBindings: ['isSelf:conversation-part-comment--is-self'], author: null, body: null, diff --git a/app/styles/components/conversations/conversation-part-closed.scss b/app/styles/components/conversations/conversation-part-closed.scss new file mode 100644 index 000000000..311ed5e6e --- /dev/null +++ b/app/styles/components/conversations/conversation-part-closed.scss @@ -0,0 +1,61 @@ +.conversation-part-closed { + display: flex; + margin-bottom: 0.5em; + + .conversation-part-closed__avatar { + margin-right: 0.5em; + + span { + display: flex; + } + } + + &--is-self { + flex-direction: row-reverse; + + .conversation-part-closed__avatar { + margin-left: 0.5em; + margin-right: 0; + } + + .conversation-part-closed__bubble-wrapper { + flex-direction: row-reverse; + } + + .conversation-part-closed__bubble { + background: $blue; + color: white; + } + + .conversation-part-closed__timestamps-wrapper { + flex-direction: row-reverse; + } + } + + &__timestamps { + color: $text--lightest; + font-size: $body-font-size-tiny; + + i.is-read { + color: $blue; + } + } +} + +.conversation-part-closed__bubble { + background: $gray--lightest; + border-radius: 4px; + color: $text--dark; + padding: 1em; +} + +.conversation-part-closed__bubble-wrapper { + align-items: flex-start; + display: flex; + margin-bottom: 3px; +} + +.conversation-part-closed__timestamps-wrapper { + align-items: flex-start; + display: flex; +} diff --git a/app/templates/components/conversations/conversation-part-closed.hbs b/app/templates/components/conversations/conversation-part-closed.hbs index d586a427f..212ac19f4 100644 --- a/app/templates/components/conversations/conversation-part-closed.hbs +++ b/app/templates/components/conversations/conversation-part-closed.hbs @@ -1,9 +1,9 @@ -
-
- {{if currentUser}} +
+ {{#if currentUser}} You closed this at... - {{else}} + {{else}}
{{author.username}} closed this at... + {{/if}} +
-
diff --git a/app/templates/components/conversations/conversation-part.hbs b/app/templates/components/conversations/conversation-part-comment.hbs similarity index 77% rename from app/templates/components/conversations/conversation-part.hbs rename to app/templates/components/conversations/conversation-part-comment.hbs index d791b3044..7bff88b43 100644 --- a/app/templates/components/conversations/conversation-part.hbs +++ b/app/templates/components/conversations/conversation-part-comment.hbs @@ -1,4 +1,4 @@ -
+
{{#tooltip-on-element @@ -12,14 +12,14 @@ {{/tooltip-on-element}}
-
-
+
+
{{body}}
-
-
+
+
{{#if sentAt}} {{moment-from-now sentAt interval=60000}} diff --git a/tests/integration/components/conversations/conversation-part-test.js b/tests/integration/components/conversations/conversation-part-comment-test.js similarity index 93% rename from tests/integration/components/conversations/conversation-part-test.js rename to tests/integration/components/conversations/conversation-part-comment-test.js index 402e757f0..86a887edd 100644 --- a/tests/integration/components/conversations/conversation-part-test.js +++ b/tests/integration/components/conversations/conversation-part-comment-test.js @@ -2,7 +2,7 @@ import { moduleForComponent, test } from 'ember-qunit'; import { set } from '@ember/object'; import hbs from 'htmlbars-inline-precompile'; import PageObject from 'ember-cli-page-object'; -import component from 'code-corps-ember/tests/pages/components/conversations/conversation-part'; +import component from 'code-corps-ember/tests/pages/components/conversations/conversation-part-comment'; import moment from 'moment'; import stubService from 'code-corps-ember/tests/helpers/stub-service'; import { @@ -24,7 +24,7 @@ function renderPage() { `); } -moduleForComponent('conversations/conversation-part', 'Integration | Component | conversations/conversation part', { +moduleForComponent('conversations/conversation-part-comment', 'Integration | Component | conversations/conversation part comment', { integration: true, beforeEach() { page.setContext(this); diff --git a/tests/pages/components/conversations/conversation-part.js b/tests/pages/components/conversations/conversation-part-comment.js similarity index 92% rename from tests/pages/components/conversations/conversation-part.js rename to tests/pages/components/conversations/conversation-part-comment.js index 3affd03a8..b9a7d9ce4 100644 --- a/tests/pages/components/conversations/conversation-part.js +++ b/tests/pages/components/conversations/conversation-part-comment.js @@ -5,7 +5,7 @@ import { } from 'ember-cli-page-object'; export default { - scope: '.conversation-part', + scope: '.conversation-part-comment', body: { scope: '[data-test-body]' From 7da31f3fa6bd149f017f5b4fa0cca924e625db05 Mon Sep 17 00:00:00 2001 From: daveconnis Date: Thu, 21 Dec 2017 13:12:33 -0500 Subject: [PATCH 03/17] fix component-part naming --- .../conversations/conversation-part-comment.js | 4 ++-- .../conversations/conversation-part-closed.hbs | 10 +++++----- ...ersation-part-comment.hbs => conversation-part.hbs} | 10 +++++----- ...-part-comment-test.js => conversation-part-test.js} | 4 ++-- ...nversation-part-comment.js => conversation-part.js} | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) rename app/templates/components/conversations/{conversation-part-comment.hbs => conversation-part.hbs} (77%) rename tests/integration/components/conversations/{conversation-part-comment-test.js => conversation-part-test.js} (93%) rename tests/pages/components/conversations/{conversation-part-comment.js => conversation-part.js} (92%) diff --git a/app/components/conversations/conversation-part-comment.js b/app/components/conversations/conversation-part-comment.js index 92a734904..5874ff2f0 100644 --- a/app/components/conversations/conversation-part-comment.js +++ b/app/components/conversations/conversation-part-comment.js @@ -4,8 +4,8 @@ import { alias } from '@ember/object/computed'; import { inject as service } from '@ember/service'; export default Component.extend({ - classNames: ['conversation-part-comment'], - classNameBindings: ['isSelf:conversation-part-comment--is-self'], + classNames: ['conversation-part'], + classNameBindings: ['isSelf:conversation-part--is-self'], author: null, body: null, diff --git a/app/templates/components/conversations/conversation-part-closed.hbs b/app/templates/components/conversations/conversation-part-closed.hbs index 212ac19f4..fe193d36d 100644 --- a/app/templates/components/conversations/conversation-part-closed.hbs +++ b/app/templates/components/conversations/conversation-part-closed.hbs @@ -1,9 +1,9 @@
{{#if currentUser}} - You closed this at... + You closed this at... You closed this at {{moment-format conversationPart.updatedAt 'MM/DD/YYYY hh:mm:ss'}} {{else}} -
- {{author.username}} closed this at... - {{/if}} -
+
+ {{author.username}} closed this at {{moment-format conversationPart.updatedAt 'MM/DD/YYYY hh:mm:ss'}} + {{/if}}
+
diff --git a/app/templates/components/conversations/conversation-part-comment.hbs b/app/templates/components/conversations/conversation-part.hbs similarity index 77% rename from app/templates/components/conversations/conversation-part-comment.hbs rename to app/templates/components/conversations/conversation-part.hbs index 7bff88b43..d791b3044 100644 --- a/app/templates/components/conversations/conversation-part-comment.hbs +++ b/app/templates/components/conversations/conversation-part.hbs @@ -1,4 +1,4 @@ -
+
{{#tooltip-on-element @@ -12,14 +12,14 @@ {{/tooltip-on-element}}
-
-
+
+
{{body}}
-
-
+
+
{{#if sentAt}} {{moment-from-now sentAt interval=60000}} diff --git a/tests/integration/components/conversations/conversation-part-comment-test.js b/tests/integration/components/conversations/conversation-part-test.js similarity index 93% rename from tests/integration/components/conversations/conversation-part-comment-test.js rename to tests/integration/components/conversations/conversation-part-test.js index 86a887edd..402e757f0 100644 --- a/tests/integration/components/conversations/conversation-part-comment-test.js +++ b/tests/integration/components/conversations/conversation-part-test.js @@ -2,7 +2,7 @@ import { moduleForComponent, test } from 'ember-qunit'; import { set } from '@ember/object'; import hbs from 'htmlbars-inline-precompile'; import PageObject from 'ember-cli-page-object'; -import component from 'code-corps-ember/tests/pages/components/conversations/conversation-part-comment'; +import component from 'code-corps-ember/tests/pages/components/conversations/conversation-part'; import moment from 'moment'; import stubService from 'code-corps-ember/tests/helpers/stub-service'; import { @@ -24,7 +24,7 @@ function renderPage() { `); } -moduleForComponent('conversations/conversation-part-comment', 'Integration | Component | conversations/conversation part comment', { +moduleForComponent('conversations/conversation-part', 'Integration | Component | conversations/conversation part', { integration: true, beforeEach() { page.setContext(this); diff --git a/tests/pages/components/conversations/conversation-part-comment.js b/tests/pages/components/conversations/conversation-part.js similarity index 92% rename from tests/pages/components/conversations/conversation-part-comment.js rename to tests/pages/components/conversations/conversation-part.js index b9a7d9ce4..3affd03a8 100644 --- a/tests/pages/components/conversations/conversation-part-comment.js +++ b/tests/pages/components/conversations/conversation-part.js @@ -5,7 +5,7 @@ import { } from 'ember-cli-page-object'; export default { - scope: '.conversation-part-comment', + scope: '.conversation-part', body: { scope: '[data-test-body]' From e5f797d430b9e6e43a7874a5435d8fc34928be98 Mon Sep 17 00:00:00 2001 From: daveconnis Date: Mon, 1 Jan 2018 16:17:18 -0500 Subject: [PATCH 04/17] write page object and test for component --- .../conversations/conversation-part-closed.js | 3 --- .../conversation-part-closed.hbs | 12 +++++++---- .../conversation-part-closed-test.js | 21 +++++++++++++++++++ .../conversations/conversation-part-closed.js | 12 +++++++++-- 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/app/components/conversations/conversation-part-closed.js b/app/components/conversations/conversation-part-closed.js index f27a10b6f..7c0c38f04 100644 --- a/app/components/conversations/conversation-part-closed.js +++ b/app/components/conversations/conversation-part-closed.js @@ -11,8 +11,5 @@ export default Component.extend({ isSelf: computed('author', 'user', function() { return get(this, 'author.id') === get(this, 'user.id'); - - - }) }) }); diff --git a/app/templates/components/conversations/conversation-part-closed.hbs b/app/templates/components/conversations/conversation-part-closed.hbs index fe193d36d..4a7b52652 100644 --- a/app/templates/components/conversations/conversation-part-closed.hbs +++ b/app/templates/components/conversations/conversation-part-closed.hbs @@ -1,9 +1,13 @@
- {{#if currentUser}} - You closed this at... You closed this at {{moment-format conversationPart.updatedAt 'MM/DD/YYYY hh:mm:ss'}} +
+
+ + {{#if isSelf}} + You closed this at {{moment-format conversationPart.updatedAt 'MM/DD/YYYY hh:mm:ss'}} {{else}} -
{{author.username}} closed this at {{moment-format conversationPart.updatedAt 'MM/DD/YYYY hh:mm:ss'}} - {{/if}} + {{/if}} + +
diff --git a/tests/integration/components/conversations/conversation-part-closed-test.js b/tests/integration/components/conversations/conversation-part-closed-test.js index dda4db4cc..f989d5a54 100644 --- a/tests/integration/components/conversations/conversation-part-closed-test.js +++ b/tests/integration/components/conversations/conversation-part-closed-test.js @@ -1,10 +1,31 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; +import PageObject from 'ember-cli-page-object'; +import component from 'code-corps-ember/tests/pages/components/conversations/conversation-part-closed'; +import stubService from 'code-corps-ember/tests/helpers/stub-service'; + +let page = PageObject.create(component); + +function renderPage() { + page.render(hbs` + {{conversations/conversation-part-closed + author=author + closedAt=closedAt + }} + `); moduleForComponent('conversations/conversation-part-closed', 'Integration | Component | conversations/conversation part closed', { integration: true }); +test('if user closes message, "You closed this at" is rendered', function(assert){ + +}) + +test('if user looks at closed message they did not close, "author.username" is rendered', function(assert){ + +}) + test('it renders', function(assert) { // Set any properties with this.set('myProperty', 'value'); diff --git a/tests/pages/components/conversations/conversation-part-closed.js b/tests/pages/components/conversations/conversation-part-closed.js index 385d7591d..19f163dc1 100644 --- a/tests/pages/components/conversations/conversation-part-closed.js +++ b/tests/pages/components/conversations/conversation-part-closed.js @@ -1,7 +1,15 @@ import { - text + hasClass } from 'ember-cli-page-object'; export default { - title: text('h1') + + scope: '.conversation-part-closed', + + closedAt: { + scope: '[data-test-closed-at]' + }, + + sentByCurrentUser: hasClass('conversation-part-closed--is-self') + }; From 600c5181f981aeec7530b8027f594e313a51b240 Mon Sep 17 00:00:00 2001 From: daveconnis Date: Tue, 2 Jan 2018 16:05:42 -0500 Subject: [PATCH 05/17] start tests for conversation-part-closed --- .../conversations/conversation-part-closed.js | 9 +++- .../conversation-part-comment.js | 4 +- ...part.hbs => conversation-part-comment.hbs} | 10 ++--- .../conversations/conversation-thread.hbs | 16 +++---- .../conversation-part-closed-test.js | 42 +++++++++---------- ...t.js => conversation-part-comment-test.js} | 6 +-- .../conversations/conversation-part-closed.js | 3 +- ...n-part.js => conversation-part-comment.js} | 4 +- .../conversations/conversation-thread.js | 6 +-- 9 files changed, 52 insertions(+), 48 deletions(-) rename app/templates/components/conversations/{conversation-part.hbs => conversation-part-comment.hbs} (77%) rename tests/integration/components/conversations/{conversation-part-test.js => conversation-part-comment-test.js} (92%) rename tests/pages/components/conversations/{conversation-part.js => conversation-part-comment.js} (78%) diff --git a/app/components/conversations/conversation-part-closed.js b/app/components/conversations/conversation-part-closed.js index 7c0c38f04..418b0640c 100644 --- a/app/components/conversations/conversation-part-closed.js +++ b/app/components/conversations/conversation-part-closed.js @@ -1,9 +1,14 @@ import Component from '@ember/component'; import { inject as service } from '@ember/service'; import { computed, get } from '@ember/object'; +import { alias } from '@ember/object/computed'; export default Component.extend({ + + author: null, + classNames: ['conversation-part-closed'], + classNameBindings: ['isSelf:conversation-part-closed--is-self'], closedAt: null, @@ -11,5 +16,7 @@ export default Component.extend({ isSelf: computed('author', 'user', function() { return get(this, 'author.id') === get(this, 'user.id'); - }) + }), + + user: alias('currentUser.user') }); diff --git a/app/components/conversations/conversation-part-comment.js b/app/components/conversations/conversation-part-comment.js index 5874ff2f0..92a734904 100644 --- a/app/components/conversations/conversation-part-comment.js +++ b/app/components/conversations/conversation-part-comment.js @@ -4,8 +4,8 @@ import { alias } from '@ember/object/computed'; import { inject as service } from '@ember/service'; export default Component.extend({ - classNames: ['conversation-part'], - classNameBindings: ['isSelf:conversation-part--is-self'], + classNames: ['conversation-part-comment'], + classNameBindings: ['isSelf:conversation-part-comment--is-self'], author: null, body: null, diff --git a/app/templates/components/conversations/conversation-part.hbs b/app/templates/components/conversations/conversation-part-comment.hbs similarity index 77% rename from app/templates/components/conversations/conversation-part.hbs rename to app/templates/components/conversations/conversation-part-comment.hbs index d791b3044..7bff88b43 100644 --- a/app/templates/components/conversations/conversation-part.hbs +++ b/app/templates/components/conversations/conversation-part-comment.hbs @@ -1,4 +1,4 @@ -
+
{{#tooltip-on-element @@ -12,14 +12,14 @@ {{/tooltip-on-element}}
-
-
+
+
{{body}}
-
-
+
+
{{#if sentAt}} {{moment-from-now sentAt interval=60000}} diff --git a/app/templates/components/conversations/conversation-thread.hbs b/app/templates/components/conversations/conversation-thread.hbs index 36702ba0f..30c2e697e 100644 --- a/app/templates/components/conversations/conversation-thread.hbs +++ b/app/templates/components/conversations/conversation-thread.hbs @@ -1,20 +1,20 @@
{{#if conversation.message.isLoaded}} - {{conversations/conversation-part + {{conversations/conversation-part-comment author=conversation.message.author body=conversation.message.body readAt=conversation.message.readAt sentAt=conversation.message.insertedAt }} {{/if}} - {{#each conversation.conversationParts as |conversationPart|}} - {{#if conversationPart.isLoaded}} - {{conversations/conversation-part - author=conversationPart.author - body=conversationPart.body - readAt=conversationPart.readAt - sentAt=conversationPart.insertedAt + {{#each conversation.conversationPartComments as |conversationPart|}} + {{#if conversationPartComment.isLoaded}} + {{conversations/conversation-part-comment + author=conversationPartComment.author + body=conversationPartComment.body + readAt=conversationPartComment.readAt + sentAt=conversationPartComment.insertedAt }} {{/if}} {{/each}} diff --git a/tests/integration/components/conversations/conversation-part-closed-test.js b/tests/integration/components/conversations/conversation-part-closed-test.js index f989d5a54..e48433365 100644 --- a/tests/integration/components/conversations/conversation-part-closed-test.js +++ b/tests/integration/components/conversations/conversation-part-closed-test.js @@ -1,8 +1,10 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; +import { set } from '@ember/object'; import PageObject from 'ember-cli-page-object'; import component from 'code-corps-ember/tests/pages/components/conversations/conversation-part-closed'; import stubService from 'code-corps-ember/tests/helpers/stub-service'; +import moment from 'moment'; let page = PageObject.create(component); @@ -13,34 +15,30 @@ function renderPage() { closedAt=closedAt }} `); +} moduleForComponent('conversations/conversation-part-closed', 'Integration | Component | conversations/conversation part closed', { - integration: true + integration: true, + beforeEach() { + page.setContext(this); + }, + afterEach() { + page.removeContext(); + } }); -test('if user closes message, "You closed this at" is rendered', function(assert){ +test('if user closes message, "You closed this at" is rendered', function(assert) { + assert.expect(1); -}) + let user = { + id: 1 + }; -test('if user looks at closed message they did not close, "author.username" is rendered', function(assert){ + set(this, 'author', user); + set(this, 'closedAt', moment().subtract(2, 'days')); + stubService(this, 'current-user', { user: { id: 1 } }); -}) + renderPage(); -test('it renders', function(assert) { - - // Set any properties with this.set('myProperty', 'value'); - // Handle any actions with this.on('myAction', function(val) { ... }); - - this.render(hbs`{{conversations/conversation-part-closed}}`); - - assert.equal(this.$().text().trim(), ''); - - // Template block usage: - this.render(hbs` - {{#conversations/conversation-part-closed}} - template block text - {{/conversations/conversation-part-closed}} - `); - - assert.equal(this.$().text().trim(), 'template block text'); + assert.ok(page.closedAt.text, 'You closed this two days ago', 'The closed at timestamp is rendered'); }); diff --git a/tests/integration/components/conversations/conversation-part-test.js b/tests/integration/components/conversations/conversation-part-comment-test.js similarity index 92% rename from tests/integration/components/conversations/conversation-part-test.js rename to tests/integration/components/conversations/conversation-part-comment-test.js index 402e757f0..0d5e5b6ea 100644 --- a/tests/integration/components/conversations/conversation-part-test.js +++ b/tests/integration/components/conversations/conversation-part-comment-test.js @@ -2,7 +2,7 @@ import { moduleForComponent, test } from 'ember-qunit'; import { set } from '@ember/object'; import hbs from 'htmlbars-inline-precompile'; import PageObject from 'ember-cli-page-object'; -import component from 'code-corps-ember/tests/pages/components/conversations/conversation-part'; +import component from 'code-corps-ember/tests/pages/components/conversations/conversation-part-comment'; import moment from 'moment'; import stubService from 'code-corps-ember/tests/helpers/stub-service'; import { @@ -16,7 +16,7 @@ let page = PageObject.create(component); function renderPage() { page.render(hbs` - {{conversations/conversation-part + {{conversations/conversation-part-comment author=author body=body sentAt=sentAt @@ -24,7 +24,7 @@ function renderPage() { `); } -moduleForComponent('conversations/conversation-part', 'Integration | Component | conversations/conversation part', { +moduleForComponent('conversations/conversation-part-comment', 'Integration | Component | conversations/conversation part', { integration: true, beforeEach() { page.setContext(this); diff --git a/tests/pages/components/conversations/conversation-part-closed.js b/tests/pages/components/conversations/conversation-part-closed.js index 19f163dc1..19f2232c5 100644 --- a/tests/pages/components/conversations/conversation-part-closed.js +++ b/tests/pages/components/conversations/conversation-part-closed.js @@ -10,6 +10,5 @@ export default { scope: '[data-test-closed-at]' }, - sentByCurrentUser: hasClass('conversation-part-closed--is-self') - + closedByCurrentUser: hasClass('conversation-part-closed--is-self') }; diff --git a/tests/pages/components/conversations/conversation-part.js b/tests/pages/components/conversations/conversation-part-comment.js similarity index 78% rename from tests/pages/components/conversations/conversation-part.js rename to tests/pages/components/conversations/conversation-part-comment.js index 3affd03a8..63d6cd58f 100644 --- a/tests/pages/components/conversations/conversation-part.js +++ b/tests/pages/components/conversations/conversation-part-comment.js @@ -5,7 +5,7 @@ import { } from 'ember-cli-page-object'; export default { - scope: '.conversation-part', + scope: '.conversation-part-comment', body: { scope: '[data-test-body]' @@ -25,5 +25,5 @@ export default { scope: '[data-test-sent-at]' }, - sentByCurrentUser: hasClass('conversation-part--is-self') + sentByCurrentUser: hasClass('conversation-part-comment--is-self') }; diff --git a/tests/pages/components/conversations/conversation-thread.js b/tests/pages/components/conversations/conversation-thread.js index a980115e8..188d27dd1 100644 --- a/tests/pages/components/conversations/conversation-thread.js +++ b/tests/pages/components/conversations/conversation-thread.js @@ -1,15 +1,15 @@ import { collection } from 'ember-cli-page-object'; import conversationComposer from 'code-corps-ember/tests/pages/components/conversations/conversation-composer'; -import conversationPart from 'code-corps-ember/tests/pages/components/conversations/conversation-part'; +import conversationPartComment from 'code-corps-ember/tests/pages/components/conversations/conversation-part-comment'; export default { scope: '.conversation-thread', conversationComposer, conversationParts: collection({ scope: '.conversation-thread__messages', - item: conversationPart, + item: conversationPartComment, // when a collection scope is specified, itemScope is required // in order to correctly detect when there is 0 items - itemScope: conversationPart.scope + itemScope: conversationPartComment.scope }) }; From 368686b0595ae685868570a073dd9ddf6a488f2d Mon Sep 17 00:00:00 2001 From: daveconnis Date: Thu, 4 Jan 2018 11:04:00 -0500 Subject: [PATCH 06/17] work on getting tests to pass --- .../conversations/conversation-thread.hbs | 20 +++++++++++-------- .../conversation-part-closed-test.js | 2 +- .../conversations/conversation-thread-test.js | 6 +++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/templates/components/conversations/conversation-thread.hbs b/app/templates/components/conversations/conversation-thread.hbs index 30c2e697e..6bf9c82ef 100644 --- a/app/templates/components/conversations/conversation-thread.hbs +++ b/app/templates/components/conversations/conversation-thread.hbs @@ -8,14 +8,18 @@ sentAt=conversation.message.insertedAt }} {{/if}} - {{#each conversation.conversationPartComments as |conversationPart|}} - {{#if conversationPartComment.isLoaded}} - {{conversations/conversation-part-comment - author=conversationPartComment.author - body=conversationPartComment.body - readAt=conversationPartComment.readAt - sentAt=conversationPartComment.insertedAt - }} + {{#each conversation.conversationPart as |conversationPart|}} + {{#if conversationPart.isLoaded}} + {{#if (eq conversationPart.partType 'Closed')}} + {{conversation/converation-part-closed}} + {{else}} + {{conversations/conversation-part-comment + author=conversationPart.author + body=conversationPart.body + readAt=conversationPart.readAt + sentAt=conversationPart.insertedAt + }} + {{/if}} {{/if}} {{/each}}
diff --git a/tests/integration/components/conversations/conversation-part-closed-test.js b/tests/integration/components/conversations/conversation-part-closed-test.js index e48433365..5cedd6208 100644 --- a/tests/integration/components/conversations/conversation-part-closed-test.js +++ b/tests/integration/components/conversations/conversation-part-closed-test.js @@ -27,7 +27,7 @@ moduleForComponent('conversations/conversation-part-closed', 'Integration | Comp } }); -test('if user closes message, "You closed this at" is rendered', function(assert) { +test('if current user closes message, "You closed this at" is rendered', function(assert) { assert.expect(1); let user = { diff --git a/tests/integration/components/conversations/conversation-thread-test.js b/tests/integration/components/conversations/conversation-thread-test.js index 2aaab8688..39937e0af 100644 --- a/tests/integration/components/conversations/conversation-thread-test.js +++ b/tests/integration/components/conversations/conversation-thread-test.js @@ -61,9 +61,9 @@ test('it renders each conversation part', function(assert) { assert.expect(4); let conversationParts = [ - { isLoaded: true, body: 'foo 1' }, - { isLoaded: true, body: 'foo 2' }, - { isLoaded: true, body: 'foo 3' } + { isLoaded:true, body: 'foo 1' }, + { isLoaded:true, body: 'foo 2' }, + { isLoaded:true, body: 'foo 3' } ]; set(this, 'conversation', { conversationParts }); renderPage(); From 36220d52f3e16d3eccdbc66c6a629efd62585b05 Mon Sep 17 00:00:00 2001 From: daveconnis Date: Thu, 4 Jan 2018 15:18:55 -0500 Subject: [PATCH 07/17] write tests for conversation-part-closed --- app/models/conversation-part.js | 1 + .../conversation-part-closed.hbs | 4 +-- .../conversations/conversation-thread.hbs | 7 ++-- .../conversation-part-closed-test.js | 32 ++++++++++++++++--- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/app/models/conversation-part.js b/app/models/conversation-part.js index b39675a92..e65141d85 100644 --- a/app/models/conversation-part.js +++ b/app/models/conversation-part.js @@ -7,6 +7,7 @@ export default Model.extend({ insertedAt: attr(), readAt: attr(), updatedAt: attr(), + closedAt: attr(), author: belongsTo('user', { async: true }), conversation: belongsTo('conversation', { async: true }) diff --git a/app/templates/components/conversations/conversation-part-closed.hbs b/app/templates/components/conversations/conversation-part-closed.hbs index 4a7b52652..fd0781b29 100644 --- a/app/templates/components/conversations/conversation-part-closed.hbs +++ b/app/templates/components/conversations/conversation-part-closed.hbs @@ -3,9 +3,9 @@
{{#if isSelf}} - You closed this at {{moment-format conversationPart.updatedAt 'MM/DD/YYYY hh:mm:ss'}} + You closed this on {{moment-format conversationPart.closedAt 'MM/DD/YYYY hh:mm:ss'}} {{else}} - {{author.username}} closed this at {{moment-format conversationPart.updatedAt 'MM/DD/YYYY hh:mm:ss'}} + {{author.username}} closed this on {{moment-format conversationPart.closedAt 'MM/DD/YYYY hh:mm:ss'}} {{/if}}
diff --git a/app/templates/components/conversations/conversation-thread.hbs b/app/templates/components/conversations/conversation-thread.hbs index 6bf9c82ef..2fe0d6c1a 100644 --- a/app/templates/components/conversations/conversation-thread.hbs +++ b/app/templates/components/conversations/conversation-thread.hbs @@ -8,10 +8,13 @@ sentAt=conversation.message.insertedAt }} {{/if}} - {{#each conversation.conversationPart as |conversationPart|}} + {{#each conversation.conversationParts as |conversationPart|}} {{#if conversationPart.isLoaded}} {{#if (eq conversationPart.partType 'Closed')}} - {{conversation/converation-part-closed}} + {{conversation/conversation-part-closed + author=conversationPart.author + closedAt=conversationPart.insertedAt + }} {{else}} {{conversations/conversation-part-comment author=conversationPart.author diff --git a/tests/integration/components/conversations/conversation-part-closed-test.js b/tests/integration/components/conversations/conversation-part-closed-test.js index 5cedd6208..e33cc9f94 100644 --- a/tests/integration/components/conversations/conversation-part-closed-test.js +++ b/tests/integration/components/conversations/conversation-part-closed-test.js @@ -27,18 +27,42 @@ moduleForComponent('conversations/conversation-part-closed', 'Integration | Comp } }); -test('if current user closes message, "You closed this at" is rendered', function(assert) { +test('if current user closes message, "You closed this" is rendered', function(assert) { assert.expect(1); let user = { - id: 1 + id: 1, + username: 'testuser' }; + let closedAt = 'MM/DD/YYYY hh:mm:ss'; + set(this, 'author', user); - set(this, 'closedAt', moment().subtract(2, 'days')); + set(this, 'closedAt', moment().fromNow()); stubService(this, 'current-user', { user: { id: 1 } }); renderPage(); + assert.equal(page.closedAt.text, 'You closed this on', 'The closed at timestamp is rendered'); + +}); + +test('if someone other than the current user closes the message, "Author.username closed this at" is rendered', function(assert) { + assert.expect(1); + + let user = { + id: 1, + username: 'currentuser' + }; + + let user1 = { + id: 2, + username: 'authoruser' + }; + + set(this, 'author', { user1 }); + set(this, 'closedAt', moment().from()); + stubService(this, 'current-user', { user }); - assert.ok(page.closedAt.text, 'You closed this two days ago', 'The closed at timestamp is rendered'); + renderPage(); + assert.equal(page.closedAt.text, 'authoruser closed this on', 'The closed at timestamp is rendered'); }); From f11705cd1c274e0b39073febd891552ebdca739f Mon Sep 17 00:00:00 2001 From: daveconnis Date: Mon, 8 Jan 2018 14:15:37 -0500 Subject: [PATCH 08/17] Fix integration tests --- .../conversation-part-closed.hbs | 4 +-- .../conversation-part-closed-test.js | 28 +++++++++++-------- .../conversations/conversation-thread-test.js | 6 ++-- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/app/templates/components/conversations/conversation-part-closed.hbs b/app/templates/components/conversations/conversation-part-closed.hbs index fd0781b29..e4295e3b1 100644 --- a/app/templates/components/conversations/conversation-part-closed.hbs +++ b/app/templates/components/conversations/conversation-part-closed.hbs @@ -3,9 +3,9 @@
{{#if isSelf}} - You closed this on {{moment-format conversationPart.closedAt 'MM/DD/YYYY hh:mm:ss'}} + You closed this {{moment-from-now closedAt interval=60000}} {{else}} - {{author.username}} closed this on {{moment-format conversationPart.closedAt 'MM/DD/YYYY hh:mm:ss'}} + {{author.username}} closed this {{moment-from-now closedAt interval=60000}} {{/if}}
diff --git a/tests/integration/components/conversations/conversation-part-closed-test.js b/tests/integration/components/conversations/conversation-part-closed-test.js index e33cc9f94..eefdaa36b 100644 --- a/tests/integration/components/conversations/conversation-part-closed-test.js +++ b/tests/integration/components/conversations/conversation-part-closed-test.js @@ -1,6 +1,7 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import { set } from '@ember/object'; +import { run } from '@ember/runloop'; import PageObject from 'ember-cli-page-object'; import component from 'code-corps-ember/tests/pages/components/conversations/conversation-part-closed'; import stubService from 'code-corps-ember/tests/helpers/stub-service'; @@ -34,16 +35,17 @@ test('if current user closes message, "You closed this" is rendered', function(a id: 1, username: 'testuser' }; - - let closedAt = 'MM/DD/YYYY hh:mm:ss'; - set(this, 'author', user); - set(this, 'closedAt', moment().fromNow()); - stubService(this, 'current-user', { user: { id: 1 } }); + stubService(this, 'current-user', { user }); + + let twoMinutesAgo = moment().subtract(2, 'minutes'); + let twoMinutesAgoFriendly = twoMinutesAgo.from(); + set(this, 'closedAt', twoMinutesAgo); renderPage(); - assert.equal(page.closedAt.text, 'You closed this on', 'The closed at timestamp is rendered'); + let text = `You closed this ${twoMinutesAgoFriendly}`; + assert.equal(page.closedAt.text, text, 'The closed at timestamp is rendered'); }); test('if someone other than the current user closes the message, "Author.username closed this at" is rendered', function(assert) { @@ -53,16 +55,20 @@ test('if someone other than the current user closes the message, "Author.usernam id: 1, username: 'currentuser' }; + stubService(this, 'current-user', { user }); - let user1 = { + let author = { id: 2, username: 'authoruser' }; + set(this, 'author', author); - set(this, 'author', { user1 }); - set(this, 'closedAt', moment().from()); - stubService(this, 'current-user', { user }); + let twoMinutesAgo = moment().subtract(2, 'minutes'); + let twoMinutesAgoFriendly = twoMinutesAgo.from(); + set(this, 'closedAt', twoMinutesAgo); renderPage(); - assert.equal(page.closedAt.text, 'authoruser closed this on', 'The closed at timestamp is rendered'); + + let text = `${author.username} closed this ${twoMinutesAgoFriendly}`; + assert.equal(page.closedAt.text, text, 'The closed at timestamp is rendered'); }); diff --git a/tests/integration/components/conversations/conversation-thread-test.js b/tests/integration/components/conversations/conversation-thread-test.js index 39937e0af..2aaab8688 100644 --- a/tests/integration/components/conversations/conversation-thread-test.js +++ b/tests/integration/components/conversations/conversation-thread-test.js @@ -61,9 +61,9 @@ test('it renders each conversation part', function(assert) { assert.expect(4); let conversationParts = [ - { isLoaded:true, body: 'foo 1' }, - { isLoaded:true, body: 'foo 2' }, - { isLoaded:true, body: 'foo 3' } + { isLoaded: true, body: 'foo 1' }, + { isLoaded: true, body: 'foo 2' }, + { isLoaded: true, body: 'foo 3' } ]; set(this, 'conversation', { conversationParts }); renderPage(); From 8ec511b2e519bd5eddafe98e619d72baa41e3916 Mon Sep 17 00:00:00 2001 From: daveconnis Date: Tue, 9 Jan 2018 12:02:25 -0500 Subject: [PATCH 09/17] change 'text' to 'expectedText' --- .../conversations/conversation-part-closed-test.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/integration/components/conversations/conversation-part-closed-test.js b/tests/integration/components/conversations/conversation-part-closed-test.js index eefdaa36b..81de8bb9b 100644 --- a/tests/integration/components/conversations/conversation-part-closed-test.js +++ b/tests/integration/components/conversations/conversation-part-closed-test.js @@ -1,7 +1,6 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import { set } from '@ember/object'; -import { run } from '@ember/runloop'; import PageObject from 'ember-cli-page-object'; import component from 'code-corps-ember/tests/pages/components/conversations/conversation-part-closed'; import stubService from 'code-corps-ember/tests/helpers/stub-service'; @@ -44,8 +43,8 @@ test('if current user closes message, "You closed this" is rendered', function(a renderPage(); - let text = `You closed this ${twoMinutesAgoFriendly}`; - assert.equal(page.closedAt.text, text, 'The closed at timestamp is rendered'); + let expectedText = `You closed this ${twoMinutesAgoFriendly}`; + assert.equal(page.closedAt.text, expectedText, 'The closed at timestamp is rendered'); }); test('if someone other than the current user closes the message, "Author.username closed this at" is rendered', function(assert) { @@ -69,6 +68,6 @@ test('if someone other than the current user closes the message, "Author.usernam renderPage(); - let text = `${author.username} closed this ${twoMinutesAgoFriendly}`; - assert.equal(page.closedAt.text, text, 'The closed at timestamp is rendered'); + let expectedText = `${author.username} closed this ${twoMinutesAgoFriendly}`; + assert.equal(page.closedAt.text, expectedText, 'The closed at timestamp is rendered'); }); From 955cea97e685285c147304f58837ddb54ce572fc Mon Sep 17 00:00:00 2001 From: daveconnis Date: Wed, 10 Jan 2018 14:19:35 -0500 Subject: [PATCH 10/17] make changes to dry up code --- .../conversation-part-comment.js | 4 +- .../conversation-part-closed.scss | 61 ------------------- .../conversation-part-closed.hbs | 16 ++--- .../conversation-part-comment.hbs | 10 +-- .../conversations/conversation-thread.hbs | 2 +- .../conversation-part-closed-test.js | 2 +- .../conversation-part-comment-test.js | 10 +-- .../conversations/conversation-part-closed.js | 14 ----- ...n-part-comment.js => conversation-part.js} | 10 ++- .../conversations/conversation-thread.js | 6 +- 10 files changed, 33 insertions(+), 102 deletions(-) delete mode 100644 app/styles/components/conversations/conversation-part-closed.scss delete mode 100644 tests/pages/components/conversations/conversation-part-closed.js rename tests/pages/components/conversations/{conversation-part-comment.js => conversation-part.js} (60%) diff --git a/app/components/conversations/conversation-part-comment.js b/app/components/conversations/conversation-part-comment.js index 92a734904..73257d884 100644 --- a/app/components/conversations/conversation-part-comment.js +++ b/app/components/conversations/conversation-part-comment.js @@ -4,8 +4,8 @@ import { alias } from '@ember/object/computed'; import { inject as service } from '@ember/service'; export default Component.extend({ - classNames: ['conversation-part-comment'], - classNameBindings: ['isSelf:conversation-part-comment--is-self'], + classNames: ['conversation-part, conversation-part-comment'], + classNameBindings: ['isSelf:conversation-part--is-self'], author: null, body: null, diff --git a/app/styles/components/conversations/conversation-part-closed.scss b/app/styles/components/conversations/conversation-part-closed.scss deleted file mode 100644 index 311ed5e6e..000000000 --- a/app/styles/components/conversations/conversation-part-closed.scss +++ /dev/null @@ -1,61 +0,0 @@ -.conversation-part-closed { - display: flex; - margin-bottom: 0.5em; - - .conversation-part-closed__avatar { - margin-right: 0.5em; - - span { - display: flex; - } - } - - &--is-self { - flex-direction: row-reverse; - - .conversation-part-closed__avatar { - margin-left: 0.5em; - margin-right: 0; - } - - .conversation-part-closed__bubble-wrapper { - flex-direction: row-reverse; - } - - .conversation-part-closed__bubble { - background: $blue; - color: white; - } - - .conversation-part-closed__timestamps-wrapper { - flex-direction: row-reverse; - } - } - - &__timestamps { - color: $text--lightest; - font-size: $body-font-size-tiny; - - i.is-read { - color: $blue; - } - } -} - -.conversation-part-closed__bubble { - background: $gray--lightest; - border-radius: 4px; - color: $text--dark; - padding: 1em; -} - -.conversation-part-closed__bubble-wrapper { - align-items: flex-start; - display: flex; - margin-bottom: 3px; -} - -.conversation-part-closed__timestamps-wrapper { - align-items: flex-start; - display: flex; -} diff --git a/app/templates/components/conversations/conversation-part-closed.hbs b/app/templates/components/conversations/conversation-part-closed.hbs index e4295e3b1..f9784e504 100644 --- a/app/templates/components/conversations/conversation-part-closed.hbs +++ b/app/templates/components/conversations/conversation-part-closed.hbs @@ -1,12 +1,12 @@ -
-
-
+
+
+
- {{#if isSelf}} - You closed this {{moment-from-now closedAt interval=60000}} - {{else}} - {{author.username}} closed this {{moment-from-now closedAt interval=60000}} - {{/if}} + {{#if isSelf}} + You closed this {{moment-from-now closedAt interval=60000}} + {{else}} + {{author.username}} closed this {{moment-from-now closedAt interval=60000}} + {{/if}}
diff --git a/app/templates/components/conversations/conversation-part-comment.hbs b/app/templates/components/conversations/conversation-part-comment.hbs index 7bff88b43..d791b3044 100644 --- a/app/templates/components/conversations/conversation-part-comment.hbs +++ b/app/templates/components/conversations/conversation-part-comment.hbs @@ -1,4 +1,4 @@ -
+
{{#tooltip-on-element @@ -12,14 +12,14 @@ {{/tooltip-on-element}}
-
-
+
+
{{body}}
-
-
+
+
{{#if sentAt}} {{moment-from-now sentAt interval=60000}} diff --git a/app/templates/components/conversations/conversation-thread.hbs b/app/templates/components/conversations/conversation-thread.hbs index 2fe0d6c1a..2b30d62a0 100644 --- a/app/templates/components/conversations/conversation-thread.hbs +++ b/app/templates/components/conversations/conversation-thread.hbs @@ -10,7 +10,7 @@ {{/if}} {{#each conversation.conversationParts as |conversationPart|}} {{#if conversationPart.isLoaded}} - {{#if (eq conversationPart.partType 'Closed')}} + {{#if (eq conversationPart.partType 'isClosed')}} {{conversation/conversation-part-closed author=conversationPart.author closedAt=conversationPart.insertedAt diff --git a/tests/integration/components/conversations/conversation-part-closed-test.js b/tests/integration/components/conversations/conversation-part-closed-test.js index 81de8bb9b..c108c7906 100644 --- a/tests/integration/components/conversations/conversation-part-closed-test.js +++ b/tests/integration/components/conversations/conversation-part-closed-test.js @@ -2,7 +2,7 @@ import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import { set } from '@ember/object'; import PageObject from 'ember-cli-page-object'; -import component from 'code-corps-ember/tests/pages/components/conversations/conversation-part-closed'; +import component from 'code-corps-ember/tests/pages/components/conversations/conversation-part'; import stubService from 'code-corps-ember/tests/helpers/stub-service'; import moment from 'moment'; diff --git a/tests/integration/components/conversations/conversation-part-comment-test.js b/tests/integration/components/conversations/conversation-part-comment-test.js index 0d5e5b6ea..a49084511 100644 --- a/tests/integration/components/conversations/conversation-part-comment-test.js +++ b/tests/integration/components/conversations/conversation-part-comment-test.js @@ -2,7 +2,7 @@ import { moduleForComponent, test } from 'ember-qunit'; import { set } from '@ember/object'; import hbs from 'htmlbars-inline-precompile'; import PageObject from 'ember-cli-page-object'; -import component from 'code-corps-ember/tests/pages/components/conversations/conversation-part-comment'; +import component from 'code-corps-ember/tests/pages/components/conversations/conversation-part'; import moment from 'moment'; import stubService from 'code-corps-ember/tests/helpers/stub-service'; import { @@ -24,7 +24,7 @@ function renderPage() { `); } -moduleForComponent('conversations/conversation-part-comment', 'Integration | Component | conversations/conversation part', { +moduleForComponent('conversations/conversation-part-comment', 'Integration | Component | conversations/conversation part comment', { integration: true, beforeEach() { page.setContext(this); @@ -53,7 +53,7 @@ test('it renders all the details', function(assert) { assert.equal(page.body.text, body, 'The body renders in the chat bubble'); assert.equal(page.sentAt.text, '2 days ago', 'The sent at timestamp renders'); - assert.notOk(page.sentByCurrentUser, 'Does not have the current user styles'); + assert.notOk(page.isByCurrentUser, 'Does not have the current user styles'); assert.equal(page.photo.url, user.photoThumbUrl, 'The user photo renders'); assertTooltipNotRendered(assert); @@ -82,7 +82,7 @@ test('when the current user did not send the message', function(assert) { renderPage(); - assert.notOk(page.sentByCurrentUser, 'Does not have the current user styles'); + assert.notOk(page.isByCurrentUser, 'Does not have the current user styles'); }); test('when the current user sent the message', function(assert) { @@ -93,5 +93,5 @@ test('when the current user sent the message', function(assert) { renderPage(); - assert.ok(page.sentByCurrentUser, 'Has the current user styles'); + assert.ok(page.isByCurrentUser, 'Has the current user styles'); }); diff --git a/tests/pages/components/conversations/conversation-part-closed.js b/tests/pages/components/conversations/conversation-part-closed.js deleted file mode 100644 index 19f2232c5..000000000 --- a/tests/pages/components/conversations/conversation-part-closed.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - hasClass -} from 'ember-cli-page-object'; - -export default { - - scope: '.conversation-part-closed', - - closedAt: { - scope: '[data-test-closed-at]' - }, - - closedByCurrentUser: hasClass('conversation-part-closed--is-self') -}; diff --git a/tests/pages/components/conversations/conversation-part-comment.js b/tests/pages/components/conversations/conversation-part.js similarity index 60% rename from tests/pages/components/conversations/conversation-part-comment.js rename to tests/pages/components/conversations/conversation-part.js index 63d6cd58f..f12fe408c 100644 --- a/tests/pages/components/conversations/conversation-part-comment.js +++ b/tests/pages/components/conversations/conversation-part.js @@ -5,12 +5,16 @@ import { } from 'ember-cli-page-object'; export default { - scope: '.conversation-part-comment', + scope: '.conversation-part--comment', body: { scope: '[data-test-body]' }, + closedAt: { + scope: '[data-test-closed-at]' + }, + photo: { scope: '[data-test-target-photo]', url: attribute('src') @@ -25,5 +29,7 @@ export default { scope: '[data-test-sent-at]' }, - sentByCurrentUser: hasClass('conversation-part-comment--is-self') + isComment: hasClass('conversation-part--comment'), + isClosed: hasClass('conversation-part--closed'), + isByCurrentUser: hasClass('conversation-part--is-self') }; diff --git a/tests/pages/components/conversations/conversation-thread.js b/tests/pages/components/conversations/conversation-thread.js index 188d27dd1..a980115e8 100644 --- a/tests/pages/components/conversations/conversation-thread.js +++ b/tests/pages/components/conversations/conversation-thread.js @@ -1,15 +1,15 @@ import { collection } from 'ember-cli-page-object'; import conversationComposer from 'code-corps-ember/tests/pages/components/conversations/conversation-composer'; -import conversationPartComment from 'code-corps-ember/tests/pages/components/conversations/conversation-part-comment'; +import conversationPart from 'code-corps-ember/tests/pages/components/conversations/conversation-part'; export default { scope: '.conversation-thread', conversationComposer, conversationParts: collection({ scope: '.conversation-thread__messages', - item: conversationPartComment, + item: conversationPart, // when a collection scope is specified, itemScope is required // in order to correctly detect when there is 0 items - itemScope: conversationPartComment.scope + itemScope: conversationPart.scope }) }; From 27f59474182ae265d36fcaa91974da60d0174322 Mon Sep 17 00:00:00 2001 From: daveconnis Date: Wed, 10 Jan 2018 15:30:32 -0500 Subject: [PATCH 11/17] change conversation-part/conversation-part-comment with tests passing --- .../conversations/conversation-part-closed.js | 2 +- .../conversations/conversation-part-comment.js | 2 +- .../components/conversations/conversation-part.js | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/components/conversations/conversation-part-closed.js b/app/components/conversations/conversation-part-closed.js index 418b0640c..1b140bbf2 100644 --- a/app/components/conversations/conversation-part-closed.js +++ b/app/components/conversations/conversation-part-closed.js @@ -7,7 +7,7 @@ export default Component.extend({ author: null, - classNames: ['conversation-part-closed'], + classNames: ['conversation-part', 'conversation-part--closed'], classNameBindings: ['isSelf:conversation-part-closed--is-self'], closedAt: null, diff --git a/app/components/conversations/conversation-part-comment.js b/app/components/conversations/conversation-part-comment.js index 73257d884..983e12d88 100644 --- a/app/components/conversations/conversation-part-comment.js +++ b/app/components/conversations/conversation-part-comment.js @@ -4,7 +4,7 @@ import { alias } from '@ember/object/computed'; import { inject as service } from '@ember/service'; export default Component.extend({ - classNames: ['conversation-part, conversation-part-comment'], + classNames: ['conversation-part', 'conversation-part--comment'], classNameBindings: ['isSelf:conversation-part--is-self'], author: null, diff --git a/tests/pages/components/conversations/conversation-part.js b/tests/pages/components/conversations/conversation-part.js index f12fe408c..322089e0f 100644 --- a/tests/pages/components/conversations/conversation-part.js +++ b/tests/pages/components/conversations/conversation-part.js @@ -5,7 +5,7 @@ import { } from 'ember-cli-page-object'; export default { - scope: '.conversation-part--comment', + scope: '.conversation-part', body: { scope: '[data-test-body]' @@ -15,6 +15,10 @@ export default { scope: '[data-test-closed-at]' }, + isComment: hasClass('conversation-part--comment'), + isClosed: hasClass('conversation-part--closed'), + isByCurrentUser: hasClass('conversation-part--is-self'), + photo: { scope: '[data-test-target-photo]', url: attribute('src') @@ -27,9 +31,5 @@ export default { sentAt: { scope: '[data-test-sent-at]' - }, - - isComment: hasClass('conversation-part--comment'), - isClosed: hasClass('conversation-part--closed'), - isByCurrentUser: hasClass('conversation-part--is-self') + } }; From 6de8ba18dab639c08703c18c9235a374c35c486d Mon Sep 17 00:00:00 2001 From: daveconnis Date: Wed, 10 Jan 2018 15:51:23 -0500 Subject: [PATCH 12/17] fix syntax and alpha-ordering --- app/models/conversation-part.js | 2 +- .../conversation-part-closed.hbs | 4 ++-- .../conversations/conversation-thread.hbs | 24 +++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/models/conversation-part.js b/app/models/conversation-part.js index e65141d85..d84bb39f4 100644 --- a/app/models/conversation-part.js +++ b/app/models/conversation-part.js @@ -4,10 +4,10 @@ import { belongsTo } from 'ember-data/relationships'; export default Model.extend({ body: attr(), + closedAt: attr(), insertedAt: attr(), readAt: attr(), updatedAt: attr(), - closedAt: attr(), author: belongsTo('user', { async: true }), conversation: belongsTo('conversation', { async: true }) diff --git a/app/templates/components/conversations/conversation-part-closed.hbs b/app/templates/components/conversations/conversation-part-closed.hbs index f9784e504..d5c93d985 100644 --- a/app/templates/components/conversations/conversation-part-closed.hbs +++ b/app/templates/components/conversations/conversation-part-closed.hbs @@ -3,9 +3,9 @@
{{#if isSelf}} - You closed this {{moment-from-now closedAt interval=60000}} + You closed this {{moment-from-now closedAt interval=60000}} {{else}} - {{author.username}} closed this {{moment-from-now closedAt interval=60000}} + {{author.username}} closed this {{moment-from-now closedAt interval=60000}} {{/if}}
diff --git a/app/templates/components/conversations/conversation-thread.hbs b/app/templates/components/conversations/conversation-thread.hbs index 2b30d62a0..770b7c473 100644 --- a/app/templates/components/conversations/conversation-thread.hbs +++ b/app/templates/components/conversations/conversation-thread.hbs @@ -12,19 +12,19 @@ {{#if conversationPart.isLoaded}} {{#if (eq conversationPart.partType 'isClosed')}} {{conversation/conversation-part-closed - author=conversationPart.author - closedAt=conversationPart.insertedAt + author=conversationPart.author + closedAt=conversationPart.insertedAt }} - {{else}} - {{conversations/conversation-part-comment - author=conversationPart.author - body=conversationPart.body - readAt=conversationPart.readAt - sentAt=conversationPart.insertedAt - }} - {{/if}} - {{/if}} - {{/each}} + {{else}} + {{conversations/conversation-part-comment + author=conversationPart.author + body=conversationPart.body + readAt=conversationPart.readAt + sentAt=conversationPart.insertedAt + }} + {{/if}} + {{/if}} +{{/each}}
{{conversations/conversation-composer From 372f93e485746b36211da78d29bf78df0acbef44 Mon Sep 17 00:00:00 2001 From: daveconnis Date: Thu, 11 Jan 2018 15:20:12 -0500 Subject: [PATCH 13/17] fix syntax and remove unnecessary code --- .../conversations/conversation-part-closed.js | 2 +- app/models/conversation-part.js | 1 - .../conversations/conversation-thread.hbs | 22 +++++++++---------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/app/components/conversations/conversation-part-closed.js b/app/components/conversations/conversation-part-closed.js index 1b140bbf2..68f2e6d13 100644 --- a/app/components/conversations/conversation-part-closed.js +++ b/app/components/conversations/conversation-part-closed.js @@ -8,7 +8,7 @@ export default Component.extend({ author: null, classNames: ['conversation-part', 'conversation-part--closed'], - classNameBindings: ['isSelf:conversation-part-closed--is-self'], + classNameBindings: ['isSelf:conversation-part--is-self'], closedAt: null, diff --git a/app/models/conversation-part.js b/app/models/conversation-part.js index d84bb39f4..b39675a92 100644 --- a/app/models/conversation-part.js +++ b/app/models/conversation-part.js @@ -4,7 +4,6 @@ import { belongsTo } from 'ember-data/relationships'; export default Model.extend({ body: attr(), - closedAt: attr(), insertedAt: attr(), readAt: attr(), updatedAt: attr(), diff --git a/app/templates/components/conversations/conversation-thread.hbs b/app/templates/components/conversations/conversation-thread.hbs index 770b7c473..7bd0c6880 100644 --- a/app/templates/components/conversations/conversation-thread.hbs +++ b/app/templates/components/conversations/conversation-thread.hbs @@ -15,18 +15,18 @@ author=conversationPart.author closedAt=conversationPart.insertedAt }} - {{else}} - {{conversations/conversation-part-comment - author=conversationPart.author - body=conversationPart.body - readAt=conversationPart.readAt - sentAt=conversationPart.insertedAt - }} - {{/if}} - {{/if}} -{{/each}} + {{else}} + {{conversations/conversation-part-comment + author=conversationPart.author + body=conversationPart.body + readAt=conversationPart.readAt + sentAt=conversationPart.insertedAt + }} + {{/if}} + {{/if}} + {{/each}}
-
+
{{conversations/conversation-composer send=(pipe (action send) (action scrollBottom)) }} From 4144f99aece69c4f35d013a0f7e02d0ea0d3faad Mon Sep 17 00:00:00 2001 From: daveconnis Date: Thu, 11 Jan 2018 15:55:23 -0500 Subject: [PATCH 14/17] fix indentation --- app/templates/components/conversations/conversation-thread.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/components/conversations/conversation-thread.hbs b/app/templates/components/conversations/conversation-thread.hbs index 7bd0c6880..cfe39b6e7 100644 --- a/app/templates/components/conversations/conversation-thread.hbs +++ b/app/templates/components/conversations/conversation-thread.hbs @@ -15,7 +15,7 @@ author=conversationPart.author closedAt=conversationPart.insertedAt }} - {{else}} + {{else}} {{conversations/conversation-part-comment author=conversationPart.author body=conversationPart.body From a3f219ec6d5cb04e1dc2e9b2f2826a56097aa16c Mon Sep 17 00:00:00 2001 From: Nikola Begedin Date: Mon, 15 Jan 2018 18:04:51 +0100 Subject: [PATCH 15/17] Update conversation-thread.hbs --- app/templates/components/conversations/conversation-thread.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/components/conversations/conversation-thread.hbs b/app/templates/components/conversations/conversation-thread.hbs index fbb596cd7..33562243b 100644 --- a/app/templates/components/conversations/conversation-thread.hbs +++ b/app/templates/components/conversations/conversation-thread.hbs @@ -26,7 +26,7 @@ {{/if}} {{/each}}
-
+
{{conversations/conversation-composer onSend=(pipe (action send) (action scrollBottom)) }} From b18b60579c409792555cee4d3b6e43723d57510d Mon Sep 17 00:00:00 2001 From: daveconnis Date: Mon, 15 Jan 2018 13:31:37 -0500 Subject: [PATCH 16/17] reordered conversation-part-closed to match style guide --- .../conversations/conversation-part-closed.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/components/conversations/conversation-part-closed.js b/app/components/conversations/conversation-part-closed.js index 68f2e6d13..f15816a77 100644 --- a/app/components/conversations/conversation-part-closed.js +++ b/app/components/conversations/conversation-part-closed.js @@ -5,18 +5,18 @@ import { alias } from '@ember/object/computed'; export default Component.extend({ - author: null, - classNames: ['conversation-part', 'conversation-part--closed'], classNameBindings: ['isSelf:conversation-part--is-self'], + currentUser: service(), + + author: null, + closedAt: null, - currentUser: service(), + user: alias('currentUser.user'), isSelf: computed('author', 'user', function() { return get(this, 'author.id') === get(this, 'user.id'); - }), - - user: alias('currentUser.user') + }) }); From f03c50c06bd7a0006e09bcb086d4f0753c672192 Mon Sep 17 00:00:00 2001 From: Nikola Begedin Date: Tue, 16 Jan 2018 07:53:41 +0100 Subject: [PATCH 17/17] Update conversation-part-closed.js --- app/components/conversations/conversation-part-closed.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/components/conversations/conversation-part-closed.js b/app/components/conversations/conversation-part-closed.js index f15816a77..aeb5f41b6 100644 --- a/app/components/conversations/conversation-part-closed.js +++ b/app/components/conversations/conversation-part-closed.js @@ -4,14 +4,12 @@ import { computed, get } from '@ember/object'; import { alias } from '@ember/object/computed'; export default Component.extend({ - classNames: ['conversation-part', 'conversation-part--closed'], classNameBindings: ['isSelf:conversation-part--is-self'], currentUser: service(), author: null, - closedAt: null, user: alias('currentUser.user'),