Skip to content

Commit

Permalink
Adds a basic test of the conversation view
Browse files Browse the repository at this point in the history
  • Loading branch information
cbothner committed Dec 12, 2017
1 parent 215c9df commit 300d5bc
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
18 changes: 13 additions & 5 deletions app/javascript/comments/CommentThreadsCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import React from 'react'
import { connect } from 'react-redux'
import { injectIntl } from 'react-intl'
import styled from 'styled-components'
import { Portal } from '@blueprintjs/core'

Expand Down Expand Up @@ -41,14 +42,15 @@ function mapStateToProps (state: State, { cardId, location }: OwnProps) {
}

const CommentThreadsCard = ({
cardId,
commentThreads,
acceptSelection,
closeCommentThreadsPath,
addCommentThread,
cardId,
closeCommentThreadsPath,
commentThreads,
history,
intl,
location,
match,
history,
}) => {
if (commentThreads == null) return null

Expand All @@ -59,6 +61,10 @@ const CommentThreadsCard = ({
<Header>
<CloseButton
replace
aria-label={intl.formatMessage({
id: 'close',
defaultMessage: 'Close',
})}
to={closeCommentThreadsPath}
onClick={() => acceptSelection(false)}
/>
Expand Down Expand Up @@ -107,7 +113,9 @@ const CommentThreadsCard = ({
)
}

export default connect(mapStateToProps, { acceptSelection })(CommentThreadsCard)
export default injectIntl(
connect(mapStateToProps, { acceptSelection })(CommentThreadsCard)
)

const List = styled.ol`
margin: 0;
Expand Down
8 changes: 5 additions & 3 deletions app/javascript/redux/reducers/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,17 @@ export default function ui (state: ?UIState, action: Action): UIState {
mostRecentCommentThreads: action.mostRecentCommentThreads,
}

case 'ADD_COMMENT_THREAD':
case 'ADD_COMMENT_THREAD': {
const id = `${action.data.id}`
return {
...state,
acceptingSelection: false,
mostRecentCommentThreads: [
String(action.data.id),
...(state.mostRecentCommentThreads || []),
id,
...(state.mostRecentCommentThreads || []).filter(x => x !== id),
],
}
}

case 'REMOVE_COMMENT_THREAD':
return {
Expand Down
13 changes: 13 additions & 0 deletions spec/features/leaving_a_comment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@
page.driver.browser.action.send_keys('Test reply').perform
click_button 'Submit'
expect(page).to have_selector 'blockquote', text: 'Test reply'

find('[aria-label="Close"]').click
click_button 'Overview'
click_button 'Conversation'
click_link 'Test reply'
reply_placeholder = find('.public-DraftEditorPlaceholder-root',
text: 'Write a reply...')
.native
page.driver.browser.action.move_to(reply_placeholder).click.perform
page.driver.browser.action.send_keys('Conversation view works!').perform
find('button[aria-label="Respond"]').click
expect(page).to have_content 'Conversation view works!'
expect(page).to have_content 'Write a reply...'
end

scenario 'is not possible with a non-unique selection' do
Expand Down
7 changes: 6 additions & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
Capybara.server = :puma

Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new app, browser: :chrome
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chrome_options: { args: %w[window-size=1440,900] }
)
Capybara::Selenium::Driver.new app,
browser: :chrome,
desired_capabilities: capabilities
end

Capybara.register_driver :headless_chrome do |app|
Expand Down

0 comments on commit 300d5bc

Please sign in to comment.