-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add conversation-part-closed component #1638
Merged
begedin
merged 18 commits into
develop
from
conversation-part-for-open-and-closed-status-changed
Jan 16, 2018
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c9115be
added conversation-part-closed component
daveconnis bd476e4
changed component name from conversation-part to conversation-part-co…
daveconnis 7da31f3
fix component-part naming
daveconnis e5f797d
write page object and test for component
daveconnis 600c518
start tests for conversation-part-closed
daveconnis 368686b
work on getting tests to pass
daveconnis 36220d5
write tests for conversation-part-closed
daveconnis f11705c
Fix integration tests
daveconnis 8ec511b
change 'text' to 'expectedText'
daveconnis 955cea9
make changes to dry up code
daveconnis 27f5947
change conversation-part/conversation-part-comment with tests passing
daveconnis 6de8ba1
fix syntax and alpha-ordering
daveconnis 372f93e
fix syntax and remove unnecessary code
daveconnis 4144f99
fix indentation
daveconnis 9f5c0da
Merge branch 'develop' into conversation-part-for-open-and-closed-sta…
begedin a3f219e
Update conversation-thread.hbs
begedin b18b605
reordered conversation-part-closed to match style guide
daveconnis f03c50c
Update conversation-part-closed.js
begedin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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({ | ||
classNames: ['conversation-part', 'conversation-part--closed'], | ||
classNameBindings: ['isSelf:conversation-part--is-self'], | ||
|
||
currentUser: service(), | ||
|
||
author: null, | ||
closedAt: null, | ||
|
||
user: alias('currentUser.user'), | ||
|
||
isSelf: computed('author', 'user', function() { | ||
return get(this, 'author.id') === get(this, 'user.id'); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
app/templates/components/conversations/conversation-part-closed.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="coversation-part__message-wrapper"> | ||
<div class="conversation-part__timestamps-wrapper"> | ||
<div class="conversation-part__timestamps"> | ||
<span data-test-closed-at> | ||
{{#if isSelf}} | ||
You closed this {{moment-from-now closedAt interval=60000}} | ||
{{else}} | ||
{{author.username}} closed this {{moment-from-now closedAt interval=60000}} | ||
{{/if}} | ||
</span> | ||
</div> | ||
</div> | ||
</div> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
tests/integration/components/conversations/conversation-part-closed-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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'; | ||
import stubService from 'code-corps-ember/tests/helpers/stub-service'; | ||
import moment from 'moment'; | ||
|
||
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, | ||
beforeEach() { | ||
page.setContext(this); | ||
}, | ||
afterEach() { | ||
page.removeContext(); | ||
} | ||
}); | ||
|
||
test('if current user closes message, "You closed this" is rendered', function(assert) { | ||
assert.expect(1); | ||
|
||
let user = { | ||
id: 1, | ||
username: 'testuser' | ||
}; | ||
set(this, 'author', user); | ||
stubService(this, 'current-user', { user }); | ||
|
||
let twoMinutesAgo = moment().subtract(2, 'minutes'); | ||
let twoMinutesAgoFriendly = twoMinutesAgo.from(); | ||
set(this, 'closedAt', twoMinutesAgo); | ||
|
||
renderPage(); | ||
|
||
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) { | ||
assert.expect(1); | ||
|
||
let user = { | ||
id: 1, | ||
username: 'currentuser' | ||
}; | ||
stubService(this, 'current-user', { user }); | ||
|
||
let author = { | ||
id: 2, | ||
username: 'authoruser' | ||
}; | ||
set(this, 'author', author); | ||
|
||
let twoMinutesAgo = moment().subtract(2, 'minutes'); | ||
let twoMinutesAgoFriendly = twoMinutesAgo.from(); | ||
set(this, 'closedAt', twoMinutesAgo); | ||
|
||
renderPage(); | ||
|
||
let expectedText = `${author.username} closed this ${twoMinutesAgoFriendly}`; | ||
assert.equal(page.closedAt.text, expectedText, 'The closed at timestamp is rendered'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw a question that got marked as outdated, which caused me to think page objects might not be completely clear to you. They are only ever used in tests and they are defined in a way that provides us with information we need to answer questions in tests.
If a conversation thread lists multiple conversations of different
partType
values, we want to askWe know that a comment has a
conversation-part--coment
class, and we know that the other one has aconversation-part--closed
class, so we could askand that works, except it's not always completely clear what it is we're actually asking. Also, in multiple tests, we tend to ask the same or similar questions, so we have to repeat all of that. Then, if, for example, the class name changes, we have to change it in all of those places.
What page objects allow us to do is to specify
in just one place and use that.
That makes the question much clearer. Also, if the class changes, we change it in just that one place - in the page object.