Hide replies when topic is unavailable
refs VICE-1995 flag=react_discussions_post Test Plan: - turn discussion redesign ff on - create a discussion with unlock date in the future - reply to the discussion topic - enter student view > replies should be hidden Change-Id: I347e5c5260507b1b2280b085e98b9c747745cb91 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277460 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Caleb Guanzon <cguanzon@instructure.com> QA-Review: Caleb Guanzon <cguanzon@instructure.com> Product-Review: Caleb Guanzon <cguanzon@instructure.com>
This commit is contained in:
parent
e7d7990b91
commit
0ceabbea9e
|
@ -244,18 +244,26 @@ const DiscussionTopicManager = props => {
|
|||
(searchTerm || filter === 'unread') ? (
|
||||
<NoResultsFound />
|
||||
) : (
|
||||
<DiscussionTopicRepliesContainer
|
||||
discussionTopic={discussionTopicQuery.data.legacyNode}
|
||||
updateDraftCache={updateDraftCache}
|
||||
removeDraftFromDiscussionCache={removeDraftFromDiscussionCache}
|
||||
onOpenIsolatedView={(discussionEntryId, isolatedId, withRCE, relativeId, highlightId) => {
|
||||
setHighlightEntryId(highlightId)
|
||||
openIsolatedView(discussionEntryId, isolatedId, withRCE, relativeId)
|
||||
}}
|
||||
goToTopic={goToTopic}
|
||||
highlightEntryId={highlightEntryId}
|
||||
isSearchResults={!!searchTerm}
|
||||
/>
|
||||
discussionTopicQuery.data.legacyNode.availableForUser && (
|
||||
<DiscussionTopicRepliesContainer
|
||||
discussionTopic={discussionTopicQuery.data.legacyNode}
|
||||
updateDraftCache={updateDraftCache}
|
||||
removeDraftFromDiscussionCache={removeDraftFromDiscussionCache}
|
||||
onOpenIsolatedView={(
|
||||
discussionEntryId,
|
||||
isolatedId,
|
||||
withRCE,
|
||||
relativeId,
|
||||
highlightId
|
||||
) => {
|
||||
setHighlightEntryId(highlightId)
|
||||
openIsolatedView(discussionEntryId, isolatedId, withRCE, relativeId)
|
||||
}}
|
||||
goToTopic={goToTopic}
|
||||
highlightEntryId={highlightEntryId}
|
||||
isSearchResults={!!searchTerm}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
{ENV.isolated_view && isolatedEntryId && (
|
||||
<IsolatedViewContainer
|
||||
|
|
|
@ -310,6 +310,51 @@ describe('DiscussionFullPage', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('AvailableForUser', () => {
|
||||
describe('Topic is unavailable', () => {
|
||||
it('should show locked discussion topic', async () => {
|
||||
const mocks = getDiscussionQueryMock()
|
||||
mocks[0].result.data.legacyNode.availableForUser = false
|
||||
const container = setup(mocks)
|
||||
expect(await container.findByTestId('locked-discussion')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should show available discussion topic alert', async () => {
|
||||
const mocks = getDiscussionQueryMock()
|
||||
mocks[0].result.data.legacyNode.availableForUser = false
|
||||
const container = setup(mocks)
|
||||
expect(await container.findByTestId('locked-for-user')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should not show root replies', async () => {
|
||||
const mocks = getDiscussionQueryMock()
|
||||
mocks[0].result.data.legacyNode.availableForUser = false
|
||||
const container = setup(mocks)
|
||||
expect(container.queryByTestId('discussion-root-entry-container')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('Topic is available', () => {
|
||||
it('should not show locked discussion topic', async () => {
|
||||
const mocks = getDiscussionQueryMock()
|
||||
const container = setup(mocks)
|
||||
expect(container.queryByTestId('locked-discussion')).toBeNull()
|
||||
})
|
||||
|
||||
it('should not show available discussion topic alert', () => {
|
||||
const mocks = getDiscussionQueryMock()
|
||||
const container = setup(mocks)
|
||||
expect(container.queryByTestId('locked-for-user')).toBeNull()
|
||||
})
|
||||
|
||||
it('should show root replies', async () => {
|
||||
const mocks = getDiscussionQueryMock()
|
||||
const container = setup(mocks)
|
||||
expect(await container.findByTestId('discussion-root-entry-container')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('error handling', () => {
|
||||
it('should render generic error page when DISCUSSION_QUERY returns errors', async () => {
|
||||
const container = setup(getDiscussionQueryMock({shouldError: true}))
|
||||
|
|
|
@ -98,7 +98,7 @@ export const DiscussionTopicRepliesContainer = props => {
|
|||
}
|
||||
|
||||
return (
|
||||
<View as="div">
|
||||
<View as="div" data-testid="discussion-root-entry-container">
|
||||
{searchTerm && <SearchResultsCount resultsFound={props.discussionTopic.searchEntryCount} />}
|
||||
{props.discussionTopic.discussionEntriesConnection.nodes.map(thread => {
|
||||
return (
|
||||
|
|
Loading…
Reference in New Issue