Compare commits

...

24 Commits

Author SHA1 Message Date
sundasnoreen12
1005541e8d refactor: added url changes 2023-03-13 11:51:43 +05:00
sundasnoreen12
562db39c24 refactor: fixed changes for code optimization 2023-03-13 11:51:33 +05:00
sundasnoreen12
d6a38ae6d7 test: added test cases for learner view 2023-03-13 11:51:33 +05:00
Mashal Malik
91cb347456 refactor: remove unused tranisfex v2 url (#463) 2023-03-13 10:41:40 +05:00
Jenkins
04745d6429 chore(i18n): update translations 2023-03-12 16:26:50 -04:00
Muhammad Adeel Tajamul
aad6702339 feat: sort comments based on sort order dropdown (#468)
Co-authored-by: adeel.tajamul <adeel.tajamul@arbisoft.com>
2023-03-10 21:38:05 +05:00
Ahtisham Shahid
d39a196cdf feat: added product tour for response sort (#462)
* feat: added product tour for response sort
2023-03-10 12:23:13 +05:00
SaadYousaf
7b000f1974 feat: send enableInContextSidebar param to backend to identify source of content for events 2023-03-09 09:02:10 +05:00
sundasnoreen12
627390c4e3 test: added testcases of redux, selector and api (#459)
* test: added testcases of redux, selector and api

* refactor: fixe recommanded issue and improve code cov

* refactor: added cases for filter statuses

* refactor: updated test description

* refactor: add common method of mock data for learner and post

* refactor: code and moved test utils in learners folder

---------

Co-authored-by: sundasnoreen12 <sundasnoreen12@ggmail.com>
Co-authored-by: Awais Ansari <awais.ansari63@gmail.com>
2023-03-08 14:25:54 +05:00
Muhammad Adeel Tajamul
1db94718c8 fix: more actions dropdown was not visible (#461) 2023-03-07 06:22:31 +05:00
ayesha waris
24d02350a8 fix: fix topic info for course-wide discussion topics (#458)
* fix: fix topic info for course-wide discussion topics

* refactor: removed const and used url directly

* test: adds test cases for topic info

* test: updated test cases
2023-03-06 21:10:49 +05:00
Jenkins
f66cdda1b6 chore(i18n): update translations 2023-03-05 15:26:48 -05:00
ayesha waris
07b56e6070 style: add border on focused post (#460) 2023-03-03 16:14:52 +05:00
ayesha waris
be1a2ccaab fix: fixed post coment actions menu accessibilty for keyboard (#456) 2023-03-01 21:46:23 +05:00
Sarina Canelake
ed0c73e051 Merge pull request #454 from openedx/repo_checks/ensure_workflows
Update standard workflow files.
2023-02-28 09:40:08 -05:00
Feanil Patel
1041b3e45f build: Updating a missing workflow file add-depr-ticket-to-depr-board.yml.
The .github/workflows/add-depr-ticket-to-depr-board.yml workflow is missing or needs an update to stay in
sync with the current standard for this workflow as defined in the
`.github` repo of the `openedx` GitHub org.
2023-02-28 09:34:03 -05:00
Feanil Patel
493a0610ca build: Creating a missing workflow file add-remove-label-on-comment.yml.
The .github/workflows/add-remove-label-on-comment.yml workflow is missing or needs an update to stay in
sync with the current standard for this workflow as defined in the
`.github` repo of the `openedx` GitHub org.
2023-02-28 09:34:03 -05:00
Feanil Patel
679e21c270 build: Creating a missing workflow file self-assign-issue.yml.
The .github/workflows/self-assign-issue.yml workflow is missing or needs an update to stay in
sync with the current standard for this workflow as defined in the
`.github` repo of the `openedx` GitHub org.
2023-02-28 09:34:03 -05:00
sundasnoreen12
62eb9f5e02 test: Added test cases for noncourseware and courseware topic posts (#452)
* test: Added test cases for noncourseware and courseware topic posts

* refactor: optimized code for post view list

* refactor: updated selector tag

---------

Co-authored-by: sundasnoreen12 <sundasnoreen12@ggmail.com>
2023-02-24 12:39:46 +05:00
Muhammad Adeel Tajamul
dedbc25358 fix: incontext crashing (#453)
Co-authored-by: adeel.tajamul <adeel.tajamul@arbisoft.com>
2023-02-23 19:05:39 +05:00
Mehak Nasir
0f2ad8b7b4 fix: conditionally skipped some API calls and deffered script loading to improve performance 2023-02-23 14:26:02 +05:00
Ahtisham Shahid
61581ff474 fix: resolved data retention issue in add a post form (#451)
* fix: resolved data retention issue in adding a post form

* test: added unit test for post editor
2023-02-22 22:58:23 +05:00
Ahtisham Shahid
3afce17a32 feat: added event tracking on load more response (#442)
* feat: added event tracking on load more response
2023-02-21 16:30:30 +05:00
Muhammad Adeel Tajamul
7e36e9f14c fix: post loading slow (#447)
Co-authored-by: adeel.tajamul <adeel.tajamul@arbisoft.com>
2023-02-21 15:09:44 +05:00
59 changed files with 1406 additions and 368 deletions

View File

@@ -16,4 +16,4 @@ jobs:
secrets:
GITHUB_APP_ID: ${{ secrets.GRAPHQL_AUTH_APP_ID }}
GITHUB_APP_PRIVATE_KEY: ${{ secrets.GRAPHQL_AUTH_APP_PEM }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_ISSUE_BOT_TOKEN }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_ISSUE_BOT_TOKEN }}

View File

@@ -0,0 +1,20 @@
# This workflow runs when a comment is made on the ticket
# If the comment starts with "label: " it tries to apply
# the label indicated in rest of comment.
# If the comment starts with "remove label: ", it tries
# to remove the indicated label.
# Note: Labels are allowed to have spaces and this script does
# not parse spaces (as often a space is legitimate), so the command
# "label: really long lots of words label" will apply the
# label "really long lots of words label"
name: Allows for the adding and removing of labels via comment
on:
issue_comment:
types: [created]
jobs:
add_remove_labels:
uses: openedx/.github/.github/workflows/add-remove-label-on-comment.yml@master

12
.github/workflows/self-assign-issue.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
# This workflow runs when a comment is made on the ticket
# If the comment starts with "assign me" it assigns the author to the
# ticket (case insensitive)
name: Assign comment author to ticket if they say "assign me"
on:
issue_comment:
types: [created]
jobs:
self_assign_by_comment:
uses: openedx/.github/.github/workflows/self-assign-issue.yml@master

View File

@@ -5,8 +5,6 @@ transifex_langs = "ar,fr,es_419,zh_CN,tr_TR,pl,fr_CA,fr_FR,de_DE,it_IT"
transifex_utils = ./node_modules/.bin/transifex-utils.js
i18n = ./src/i18n
transifex_input = $(i18n)/transifex_input.json
tx_url1 = https://www.transifex.com/api/2/project/edx-platform/resource/$(transifex_resource)/translation/en/strings/
tx_url2 = https://www.transifex.com/api/2/project/edx-platform/resource/$(transifex_resource)/source/
# This directory must match .babelrc .
transifex_temp = ./temp/babel-plugin-react-intl

View File

@@ -45,7 +45,7 @@
};
</script>
<script
async
defer
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"
id="MathJax-script"
></script>
@@ -54,7 +54,7 @@
<div id="root" class="small"></div>
<!-- begin usabilla live embed code -->
<script type="text/javascript">
<script defer type="text/javascript">
window.lightningjs ||
(function (n) {
var e = "lightningjs";

View File

@@ -13,12 +13,12 @@ const defaultSanitizeOptions = {
};
function HTMLLoader({
htmlNode, componentId, cssClassName, testId,
htmlNode, componentId, cssClassName, testId, delay,
}) {
const sanitizedMath = DOMPurify.sanitize(htmlNode, { ...defaultSanitizeOptions });
const previewRef = useRef();
const debouncedPostContent = useDebounce(htmlNode, 500);
const debouncedPostContent = useDebounce(htmlNode, delay);
useEffect(() => {
let promise = Promise.resolve(); // Used to hold chain of typesetting calls
@@ -45,6 +45,7 @@ HTMLLoader.propTypes = {
componentId: PropTypes.string,
cssClassName: PropTypes.string,
testId: PropTypes.string,
delay: PropTypes.number,
};
HTMLLoader.defaultProps = {
@@ -52,6 +53,7 @@ HTMLLoader.defaultProps = {
componentId: null,
cssClassName: '',
testId: '',
delay: 0,
};
export default HTMLLoader;

View File

@@ -29,7 +29,13 @@ function PostPreviewPane({
className="float-right p-3"
iconClassNames="icon-size"
/>
<HTMLLoader htmlNode={htmlNode} cssClassName="text-primary" componentId="post-preview" testId="post-preview" />
<HTMLLoader
htmlNode={htmlNode}
cssClassName="text-primary"
componentId="post-preview"
testId="post-preview"
delay={500}
/>
</div>
)}
<div className="d-flex justify-content-end">

View File

@@ -72,6 +72,7 @@ function Search({ intl }) {
<Icon
src={SearchIcon}
onClick={() => onSubmit(searchValue)}
data-testid="search-icon"
/>
</span>
</SearchField.Advanced>

View File

@@ -1,4 +1,4 @@
import React, { useContext, useState } from 'react';
import React, { useCallback, useRef, useState } from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
@@ -16,7 +16,6 @@ import messages from '../messages';
import { commentShape } from '../post-comments/comments/comment/proptypes';
import { postShape } from '../posts/post/proptypes';
import { inBlackoutDateRange, useActions } from '../utils';
import { DiscussionContext } from './context';
function ActionsDropdown({
intl,
@@ -26,41 +25,54 @@ function ActionsDropdown({
iconSize,
dropDownIconSize,
}) {
const buttonRef = useRef();
const [isOpen, open, close] = useToggle(false);
const [target, setTarget] = useState(null);
const actions = useActions(commentOrPost);
const { enableInContextSidebar } = useContext(DiscussionContext);
const handleActions = (action) => {
const handleActions = useCallback((action) => {
const actionFunction = actionHandlers[action];
if (actionFunction) {
actionFunction();
} else {
logError(`Unknown or unimplemented action ${action}`);
}
};
}, [actionHandlers]);
const blackoutDateRange = useSelector(selectBlackoutDate);
// Find and remove edit action if in blackout date range.
if (inBlackoutDateRange(blackoutDateRange)) {
actions.splice(actions.findIndex(action => action.id === 'edit'), 1);
}
const onClickButton = useCallback(() => {
setTarget(buttonRef.current);
open();
}, [open]);
const onCloseModal = useCallback(() => {
close();
setTarget(null);
}, [close]);
return (
<>
<IconButton
onClick={open}
onClick={onClickButton}
alt={intl.formatMessage(messages.actionsAlt)}
src={MoreHoriz}
iconAs={Icon}
disabled={disabled}
size={iconSize}
ref={setTarget}
ref={buttonRef}
iconClassNames={dropDownIconSize ? 'dropdown-icon-dimentions' : ''}
/>
<div className="actions-dropdown">
<ModalPopup
onClose={close}
onClose={onCloseModal}
positionRef={target}
isOpen={isOpen}
placement={enableInContextSidebar ? 'left' : 'auto-start'}
placement="bottom-end"
>
<div
className="bg-white p-1 shadow d-flex flex-column"

View File

@@ -27,7 +27,8 @@ const threadsApiUrl = getThreadsApiUrl();
const discussionPostId = 'thread-1';
const questionPostId = 'thread-2';
const courseId = 'course-v1:edX+TestX+Test_Course';
const reverseOrder = false;
const reverseOrder = true;
const enableInContextSidebar = false;
let store;
let axiosMock;
let container;
@@ -45,6 +46,7 @@ function mockAxiosReturnPagedComments() {
requested_fields: 'profile_image',
endorsed,
reverse_order: reverseOrder,
enable_in_context_sidebar: enableInContextSidebar,
},
})
.reply(200, Factory.build('commentsResult', { can_delete: true }, {

View File

@@ -8,14 +8,13 @@ ensureConfig([
], 'Posts API service');
export const getCourseConfigApiUrl = () => `${getConfig().LMS_BASE_URL}/api/discussion/v1/courses/`;
export const getDiscussionsConfigUrl = (courseId) => `${getCourseConfigApiUrl()}${courseId}/`;
/**
* Get discussions course config
* @param {string} courseId
*/
export async function getDiscussionsConfig(courseId) {
const url = `${getCourseConfigApiUrl()}${courseId}/`;
const { data } = await getAuthenticatedHttpClient().get(url);
const { data } = await getAuthenticatedHttpClient().get(getDiscussionsConfigUrl(courseId));
return data;
}
@@ -24,7 +23,7 @@ export async function getDiscussionsConfig(courseId) {
* @param {string} courseId
*/
export async function getDiscussionsSettings(courseId) {
const url = `${getCourseConfigApiUrl()}${courseId}/settings`;
const url = `${getDiscussionsConfigUrl(courseId)}settings`;
const { data } = await getAuthenticatedHttpClient().get(url);
return data;
}

View File

@@ -217,7 +217,7 @@ export const useTourConfiguration = (intl) => {
advanceButtonText: intl.formatMessage(messages.advanceButtonText),
dismissButtonText: intl.formatMessage(messages.dismissButtonText),
endButtonText: intl.formatMessage(messages.endButtonText),
enabled: tour && Boolean(tour.showTour && !enableInContextSidebar),
enabled: tour && Boolean(tour.enabled && tour.showTour && !enableInContextSidebar),
onDismiss: () => dispatch(updateTourShowStatus(tour.id)),
onEnd: () => dispatch(updateTourShowStatus(tour.id)),
checkpoints: tourCheckpoints(intl)[camelToConstant(tour.tourName)],

View File

@@ -124,7 +124,7 @@ export default function DiscussionsHome() {
</Switch>
)}
</div>
<DiscussionsProductTour />
{!enableInContextSidebar && <DiscussionsProductTour />}
</main>
{!enableInContextSidebar && <Footer />}
</DiscussionContext.Provider>

View File

@@ -0,0 +1,255 @@
import {
fireEvent, render, screen, waitFor, within,
} from '@testing-library/react';
import MockAdapter from 'axios-mock-adapter';
import { act } from 'react-dom/test-utils';
import { IntlProvider } from 'react-intl';
import { generatePath, MemoryRouter, Route } from 'react-router';
import { Factory } from 'rosie';
import { initializeMockApp } from '@edx/frontend-platform';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { AppProvider } from '@edx/frontend-platform/react';
import { PostActionsBar } from '../../components';
import { Routes } from '../../data/constants';
import { initializeStore } from '../../store';
import { executeThunk } from '../../test-utils';
import { DiscussionContext } from '../common/context';
import { getThreadsApiUrl } from '../posts/data/api';
import { fetchThreads } from '../posts/data/thunks';
import { getCourseTopicsApiUrl } from './data/api';
import { selectCoursewareTopics } from './data/selectors';
import { fetchCourseTopicsV3 } from './data/thunks';
import TopicPostsView from './TopicPostsView';
import TopicsView from './TopicsView';
import './data/__factories__';
import '../posts/data/__factories__/threads.factory';
const courseId = 'course-v1:edX+DemoX+Demo_Course';
const threadsApiUrl = getThreadsApiUrl();
const topicsApiUrl = getCourseTopicsApiUrl();
let store;
let axiosMock;
let lastLocation;
let container;
async function renderComponent({ topicId, category } = { }) {
let path = `/${courseId}/topics`;
if (topicId) {
path = generatePath(Routes.POSTS.PATH, { courseId, topicId });
} else if (category) {
path = generatePath(Routes.TOPICS.CATEGORY, { courseId, category });
}
const wrapper = await render(
<IntlProvider locale="en">
<AppProvider store={store}>
<DiscussionContext.Provider value={{
courseId,
topicId,
category,
page: 'topics',
}}
>
<MemoryRouter initialEntries={[path]}>
<Route exact path={[Routes.POSTS.PATH, Routes.TOPICS.CATEGORY]}>
<TopicPostsView />
</Route>
<Route exact path={[Routes.TOPICS.ALL]}>
<PostActionsBar />
<TopicsView />
</Route>
<Route
render={({ location }) => {
lastLocation = location;
return null;
}}
/>
</MemoryRouter>
</DiscussionContext.Provider>
</AppProvider>
</IntlProvider>,
);
container = wrapper.container;
}
describe('InContext Topic Posts View', () => {
let coursewareTopics;
beforeEach(() => {
initializeMockApp({
authenticatedUser: {
userId: 3,
username: 'abc123',
administrator: true,
roles: [],
},
});
store = initializeStore({
config: {
enableInContext: true,
provider: 'openedx',
hasModerationPrivileges: true,
blackouts: [],
},
});
Factory.resetAll();
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
lastLocation = undefined;
});
async function setupTopicsMockResponse() {
axiosMock.onGet(`${topicsApiUrl}${courseId}`)
.reply(200, (Factory.buildList('topic', 1, null, {
topicPrefix: 'noncourseware-topic',
enabledInContext: true,
topicNamePrefix: 'general-topic',
usageKey: '',
courseware: false,
discussionCount: 1,
questionCount: 1,
})
.concat(Factory.buildList('section', 2, null, { topicPrefix: 'courseware' })))
.concat(Factory.buildList('archived-topics', 2, null)));
await executeThunk(fetchCourseTopicsV3(courseId), store.dispatch, store.getState);
const state = store.getState();
coursewareTopics = selectCoursewareTopics(state);
}
async function setupPostsMockResponse(topicId, numOfResponses = 3) {
axiosMock.onGet(threadsApiUrl)
.reply(() => {
const threadAttrs = { previewBody: 'thread preview body' };
return [200, Factory.build('threadsResult', {}, {
topicId,
threadAttrs,
count: numOfResponses,
})];
});
await executeThunk(fetchThreads(courseId), store.dispatch, store.getState);
}
test.each([
{ parentId: 'noncourseware-topic-1', parentTitle: 'general-topic-1', topicType: 'NonCourseware' },
{ parentId: 'courseware-topic-1-v3-1', parentTitle: 'Introduction Introduction 1-1-1', topicType: 'Courseware' },
])('\'$topicType\' topic should have a required number of post lengths.', async ({ parentId, parentTitle }) => {
await setupTopicsMockResponse();
await setupPostsMockResponse(parentId, 3);
await act(async () => {
renderComponent({ topicId: parentId });
});
await waitFor(async () => {
const posts = await container.querySelectorAll('.discussion-post');
const backButton = screen.getByLabelText('Back to topics list');
const parentHeader = await screen.findByText(parentTitle);
expect(lastLocation.pathname.endsWith(`/topics/${parentId}`)).toBeTruthy();
expect(posts).toHaveLength(3);
expect(backButton).toBeInTheDocument();
expect(parentHeader).toBeInTheDocument();
});
});
it('A back button should redirect from list of posts to list of units.', async () => {
await setupTopicsMockResponse();
const subSection = coursewareTopics[0].children[0];
const unit = subSection.children[0];
await act(async () => {
setupPostsMockResponse(unit.id, 2);
renderComponent({ topicId: unit.id });
});
const backButton = await screen.getByLabelText('Back to topics list');
await act(async () => fireEvent.click(backButton));
await waitFor(async () => {
renderComponent({ category: subSection.id });
const subSectionList = await container.querySelector('.list-group');
const units = subSectionList.querySelectorAll('.discussion-topic');
const unitHeader = within(subSectionList).queryByText(unit.name);
expect(lastLocation.pathname.endsWith(`/category/${subSection.id}`)).toBeTruthy();
expect(unitHeader).toBeInTheDocument();
expect(units).toHaveLength(4);
});
});
it('A back button should redirect from units to the parent/selected subsection.', async () => {
await setupTopicsMockResponse();
const subSection = coursewareTopics[0].children[0];
renderComponent({ category: subSection.id });
const backButton = await screen.getByLabelText('Back to topics list');
await act(async () => fireEvent.click(backButton));
await waitFor(async () => {
renderComponent();
const sectionList = await container.querySelector('.list-group');
const subSections = sectionList.querySelectorAll('.discussion-topic-group');
const subSectionHeader = within(sectionList).queryByText(subSection.displayName);
expect(lastLocation.pathname.endsWith('/topics')).toBeTruthy();
expect(subSectionHeader).toBeInTheDocument();
expect(subSections).toHaveLength(3);
});
});
test.each([
{ searchText: 'hello world', output: 'Showing 0 results for', resultCount: 0 },
{ searchText: 'introduction', output: 'Showing 8 results for', resultCount: 8 },
])('It should have a search bar with a clear button and \'$output\' results found text.',
async ({ searchText, output, resultCount }) => {
await setupTopicsMockResponse();
await renderComponent();
const searchField = await within(container).getByPlaceholderText('Search topics');
const searchButton = await within(container).getByTestId('search-icon');
fireEvent.change(searchField, { target: { value: searchText } });
await waitFor(async () => expect(searchField).toHaveValue(searchText));
await act(async () => fireEvent.click(searchButton));
await waitFor(async () => {
const clearButton = await within(container).queryByText('Clear results');
const searchMessage = within(container).queryByText(`${output} "${searchText}"`);
const units = container.querySelectorAll('.discussion-topic');
expect(searchMessage).toBeInTheDocument();
expect(clearButton).toBeInTheDocument();
expect(units).toHaveLength(resultCount);
});
});
it('When click on the clear button it should move to main topics pages.', async () => {
await setupTopicsMockResponse();
await renderComponent();
const searchText = 'hello world';
const searchField = await within(container).getByPlaceholderText('Search topics');
const searchButton = await within(container).getByTestId('search-icon');
fireEvent.change(searchField, { target: { value: searchText } });
await waitFor(async () => expect(searchField).toHaveValue(searchText));
await act(async () => fireEvent.click(searchButton));
await waitFor(async () => {
const clearButton = await within(container).queryByText('Clear results');
await act(async () => fireEvent.click(clearButton));
await waitFor(async () => {
const coursewareTopicList = await container.querySelectorAll('.discussion-topic-group');
expect(coursewareTopicList).toHaveLength(3);
expect(within(container).queryByText('Clear results')).not.toBeInTheDocument();
});
});
});
});

View File

@@ -50,6 +50,7 @@ function TopicSearchBar({ intl }) {
<Icon
src={SearchIcon}
onClick={() => onSubmit(searchValue)}
data-testid="search-icon"
/>
</span>
</SearchField.Advanced>

View File

@@ -1,6 +1,8 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import {
fireEvent, render, screen, waitFor, within,
} from '@testing-library/react';
import MockAdapter from 'axios-mock-adapter';
import { act } from 'react-dom/test-utils';
import { IntlProvider } from 'react-intl';
@@ -11,11 +13,13 @@ import { initializeMockApp } from '@edx/frontend-platform';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { AppProvider } from '@edx/frontend-platform/react';
import { PostActionsBar } from '../../components';
import { initializeStore } from '../../store';
import { executeThunk } from '../../test-utils';
import { getCourseConfigApiUrl } from '../data/api';
import { DiscussionContext } from '../common/context';
import { getDiscussionsConfigUrl } from '../data/api';
import { fetchCourseConfig } from '../data/thunks';
import { getCoursesApiUrl, getUserProfileApiUrl } from './data/api';
import { getUserProfileApiUrl, learnersApiUrl } from './data/api';
import { fetchLearners } from './data/thunks';
import LearnersView from './LearnersView';
@@ -23,27 +27,31 @@ import './data/__factories__';
let store;
let axiosMock;
const coursesApiUrl = getCoursesApiUrl();
const courseConfigApiUrl = getCourseConfigApiUrl();
const userProfileApiUrl = getUserProfileApiUrl();
const courseId = 'course-v1:edX+TestX+Test_Course';
let container;
function renderComponent() {
return render(
const wrapper = render(
<IntlProvider locale="en">
<AppProvider store={store}>
<MemoryRouter initialEntries={[`/${courseId}/`]}>
<Route path="/:courseId/">
<LearnersView />
</Route>
</MemoryRouter>
<DiscussionContext.Provider value={{
page: 'learners',
}}
>
<MemoryRouter initialEntries={[`/${courseId}/`]}>
<Route path="/:courseId/">
<PostActionsBar />
<LearnersView />
</Route>
</MemoryRouter>
</DiscussionContext.Provider>
</AppProvider>
</IntlProvider>,
);
container = wrapper.container;
}
describe('LearnersView', () => {
const learnerCount = 3;
beforeEach(async () => {
initializeMockApp({
authenticatedUser: {
@@ -53,41 +61,190 @@ describe('LearnersView', () => {
roles: [],
},
});
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
store = initializeStore();
Factory.resetAll();
const learnersData = Factory.build('learnersResult', {}, {
count: learnerCount,
pageSize: 6,
});
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
axiosMock.onGet(`${coursesApiUrl}${courseId}/activity_stats/`)
.reply(() => [200, learnersData]);
const learnersProfile = Factory.build('learnersProfile', {}, {
username: ['leaner-1', 'leaner-2', 'leaner-3'],
});
axiosMock.onGet(`${userProfileApiUrl}?username=leaner-1,leaner-2,leaner-3`)
.reply(() => [200, learnersProfile.profiles]);
await executeThunk(fetchLearners(courseId), store.dispatch, store.getState);
});
describe('Basic', () => {
test('Learners tab is disabled by default', async () => {
await act(async () => {
await renderComponent();
});
expect(screen.queryByText(/Last active/i)).toBeFalsy();
async function setUpLearnerMockResponse(
count = 3,
pageSize = 6,
page = 1,
username = ['learner-1', 'learner-2', 'learner-3'],
searchText,
) {
Factory.resetAll();
const learnersData = Factory.build('learnersResult', {}, {
count,
pageSize,
page,
});
test('Learners tab is enabled', async () => {
axiosMock.onGet(`${courseConfigApiUrl}${courseId}/`).reply(200, {
learners_tab_enabled: true,
user_is_privileged: true,
});
axiosMock.onGet(`${courseConfigApiUrl}${courseId}/settings`).reply(200, {});
await executeThunk(fetchCourseConfig(courseId), store.dispatch, store.getState);
axiosMock.onGet(learnersApiUrl(courseId))
.reply(() => [200, learnersData]);
axiosMock.onGet(`${getUserProfileApiUrl()}?username=${username.join()}`)
.reply(() => [200, Factory.build('learnersProfile', {}, {
username,
}).profiles]);
await executeThunk(fetchLearners(courseId, { usernameSearch: searchText }), store.dispatch, store.getState);
}
async function assignPrivilages() {
axiosMock.onGet(getDiscussionsConfigUrl(courseId)).reply(200, {
learners_tab_enabled: true,
user_is_privileged: true,
});
await executeThunk(fetchCourseConfig(courseId), store.dispatch, store.getState);
}
test('Learners tab is disabled by default', async () => {
await setUpLearnerMockResponse();
await renderComponent();
expect(screen.queryByText('learner-1')).not.toBeInTheDocument();
});
test('Learners tab is enabled', async () => {
await setUpLearnerMockResponse();
await assignPrivilages();
await waitFor(() => {
renderComponent();
});
expect(screen.queryByText('learner-1')).toBeInTheDocument();
});
test('Most activity should be selected by default for the non-moderator role.', async () => {
await setUpLearnerMockResponse();
await renderComponent();
const filterBar = container.querySelector('.collapsible-trigger');
await act(async () => {
fireEvent.click(filterBar);
});
await waitFor(() => {
const mostActivity = screen.getByTestId('activity selected');
expect(mostActivity).toBeInTheDocument();
});
});
it.each([
{ searchBy: 'sort-recency', result: 0 },
{ searchBy: 'sort-activity', result: 3 },
])('successfully display learners by %s.', async ({ searchBy, result }) => {
await setUpLearnerMockResponse();
await assignPrivilages();
await renderComponent();
const filterBar = container.querySelector('.collapsible-trigger');
await act(async () => {
fireEvent.click(filterBar);
});
await waitFor(async () => {
const activity = container.querySelector(`#${searchBy}`);
await act(async () => {
await renderComponent();
fireEvent.click(activity);
});
await waitFor(() => {
const learners = container.querySelectorAll('.discussion-post');
expect(learners).toHaveLength(result);
});
});
});
it('should display a learner\'s list.', async () => {
await setUpLearnerMockResponse();
await assignPrivilages();
await waitFor(() => {
renderComponent();
});
const learners = await container.querySelectorAll('.discussion-post');
const firstLearner = learners.item(0);
const learnerAvatar = firstLearner.querySelector('[alt=learner-1]');
const learnerTitle = within(firstLearner).queryByText('learner-1');
const stats = firstLearner.querySelectorAll('.icon-size');
expect(learners).toHaveLength(3);
expect(learnerAvatar).toBeInTheDocument();
expect(learnerTitle).toBeInTheDocument();
expect(stats).toHaveLength(2);
});
it.each([
{
searchText: 'hello world',
output: 'Showing 0 results for',
learnersCount: 0,
username: [],
},
{
searchText: 'learner',
output: 'Showing 2 results for',
learnersCount: 2,
username:
['learner-1', 'learner-2'],
},
])('should have a search bar with a clear button and \'$output\' results found text.',
async ({
searchText, output, learnersCount, username,
}) => {
await setUpLearnerMockResponse();
await assignPrivilages();
await renderComponent();
const searchField = within(container).getByPlaceholderText('Search learners');
const searchButton = within(container).getByTestId('search-icon');
await fireEvent.change(searchField, { target: { value: searchText } });
await act(async () => {
fireEvent.click(searchButton);
setUpLearnerMockResponse(learnersCount, learnersCount, 1, username, searchText);
});
await waitFor(() => {
const clearButton = within(container).queryByText('Clear results');
const searchMessage = within(container).queryByText(`${output} "${searchText}"`);
const leaners = container.querySelectorAll('.discussion-post') ?? [];
expect(searchMessage).toBeInTheDocument();
expect(clearButton).toBeInTheDocument();
expect(leaners).toHaveLength(learnersCount);
});
});
test('When click on the clear button it should move to a list of all learners.', async () => {
await setUpLearnerMockResponse();
await assignPrivilages();
await renderComponent();
const searchField = within(container).getByPlaceholderText('Search learners');
const searchButton = within(container).getByTestId('search-icon');
let clearButton;
await fireEvent.change(searchField, { target: { value: 'learner' } });
await act(async () => {
fireEvent.click(searchButton);
setUpLearnerMockResponse(2, 2, 1, ['learner-1', 'learner-2'], 'learner');
});
await waitFor(() => {
clearButton = within(container).queryByText('Clear results');
});
await act(async () => fireEvent.click(clearButton));
await waitFor(() => {
setUpLearnerMockResponse();
});
const learners = container.querySelectorAll('.discussion-post');
expect(learners).toHaveLength(3);
});
});

View File

@@ -2,7 +2,7 @@ import { Factory } from 'rosie';
Factory.define('learner')
.sequence('id')
.attr('username', ['id'], (id) => `leaner-${id}`)
.attr('username', ['id'], (id) => `learner-${id}`)
.option('activeFlags', null, null)
.attr('active_flags', ['activeFlags'], (activeFlags) => activeFlags)
.attrs({
@@ -13,9 +13,9 @@ Factory.define('learner')
});
Factory.define('learnersResult')
.option('count', null, 3)
.option('page', null, 1)
.option('pageSize', null, 5)
.option('count', null)
.option('page', null)
.option('pageSize', null)
.option('courseId', null, 'course-v1:Test+TestX+Test_Course')
.option('activeFlags', null, 0)
.attr(
@@ -23,14 +23,8 @@ Factory.define('learnersResult')
['courseId', 'count', 'page', 'pageSize'],
(courseId, count, page, pageSize) => {
const numPages = Math.ceil(count / pageSize);
const next = page < numPages
? `http://test.site/api/discussion/v1/courses/course-v1:edX+DemoX+Demo_Course/activity_stats?page=${page + 1
}`
: null;
const prev = page > 1
? `http://test.site/api/discussion/v1/courses/course-v1:edX+DemoX+Demo_Course/activity_stats?page=${page - 1
}`
: null;
const next = page < numPages ? page + 1 : null;
const prev = page > 1 ? page - 1 : null;
return {
next,
prev,
@@ -65,7 +59,7 @@ Factory.define('learnersResult')
);
Factory.define('learnersProfile')
.option('usernames', null, ['leaner-1', 'leaner-2', 'leaner-3'])
.option('usernames', null, ['learner-1', 'learner-2', 'learner-3'])
.attr('profiles', ['usernames'], (usernames) => {
const profiles = usernames.map((user) => ({
account_privacy: 'private',

View File

@@ -10,6 +10,8 @@ ensureConfig([
export const getCoursesApiUrl = () => `${getConfig().LMS_BASE_URL}/api/discussion/v1/courses/`;
export const getUserProfileApiUrl = () => `${getConfig().LMS_BASE_URL}/api/user/v1/accounts`;
export const learnerPostsApiUrl = (courseId) => `${getCoursesApiUrl()}${courseId}/learner/`;
export const learnersApiUrl = (courseId) => `${getCoursesApiUrl()}${courseId}/activity_stats/`;
/**
* Fetches all the learners in the given course.
@@ -18,8 +20,7 @@ export const getUserProfileApiUrl = () => `${getConfig().LMS_BASE_URL}/api/user/
* @returns {Promise<{}>}
*/
export async function getLearners(courseId, params) {
const url = `${getCoursesApiUrl()}${courseId}/activity_stats/`;
const { data } = await getAuthenticatedHttpClient().get(url, { params });
const { data } = await getAuthenticatedHttpClient().get(learnersApiUrl(courseId), { params });
return data;
}
@@ -65,8 +66,6 @@ export async function getUserPosts(courseId, {
countFlagged,
cohort,
} = {}) {
const learnerPostsApiUrl = `${getCoursesApiUrl()}${courseId}/learner/`;
const params = snakeCaseObject({
page,
pageSize,
@@ -81,6 +80,6 @@ export async function getUserPosts(courseId, {
});
const { data } = await getAuthenticatedHttpClient()
.get(learnerPostsApiUrl, { params });
.get(learnerPostsApiUrl(courseId), { params });
return data;
}

View File

@@ -0,0 +1,79 @@
import MockAdapter from 'axios-mock-adapter';
import { Factory } from 'rosie';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { initializeMockApp } from '@edx/frontend-platform/testing';
import { setupLearnerMockResponse, setupPostsMockResponse } from '../test-utils';
import './__factories__';
const courseId2 = 'course-v1:edX+TestX+Test_Course2';
let axiosMock;
describe('Learner api test cases', () => {
beforeEach(async () => {
initializeMockApp({
authenticatedUser: {
userId: 3,
username: 'abc123',
administrator: true,
roles: [],
},
});
Factory.resetAll();
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
});
afterEach(() => {
axiosMock.reset();
});
it('Successfully get and store API response for the learner\'s list and learners posts in redux',
async () => {
const learners = await setupLearnerMockResponse();
const threads = await setupPostsMockResponse();
expect(learners.status).toEqual('successful');
expect(Object.values(learners.learnerProfiles)).toHaveLength(3);
expect(threads.status).toEqual('successful');
expect(Object.values(threads.threadsById)).toHaveLength(2);
});
it.each([
{ status: 'statusUnread', search: 'Title', cohort: 'post' },
{ status: 'statusUnanswered', search: 'Title', cohort: 'post' },
{ status: 'statusReported', search: 'Title', cohort: 'post' },
{ status: 'statusUnresponded', search: 'Title', cohort: 'post' },
])('Successfully fetch user posts based on %s filters',
async ({ status, search, cohort }) => {
const threads = await setupPostsMockResponse({ filters: { status, search, cohort } });
expect(threads.status).toEqual('successful');
expect(Object.values(threads.threadsById)).toHaveLength(2);
});
it('Failed to fetch learners', async () => {
const learners = await setupLearnerMockResponse({ learnerCourseId: courseId2 });
expect(learners.status).toEqual('failed');
});
it('Denied to fetch learners', async () => {
const learners = await setupLearnerMockResponse({ statusCode: 403 });
expect(learners.status).toEqual('denied');
});
it('Failed to fetch learnerPosts', async () => {
const threads = await setupPostsMockResponse({ learnerCourseId: courseId2 });
expect(threads.status).toEqual('failed');
});
it('Denied to fetch learnerPosts', async () => {
const threads = await setupPostsMockResponse({ statusCode: 403 });
expect(threads.status).toEqual('denied');
});
});

View File

@@ -0,0 +1,120 @@
import MockAdapter from 'axios-mock-adapter';
import { Factory } from 'rosie';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { initializeMockApp } from '@edx/frontend-platform/testing';
import { initializeStore } from '../../../store';
import { executeThunk } from '../../../test-utils';
import { setupLearnerMockResponse } from '../test-utils';
import { setPostFilter, setSortedBy, setUsernameSearch } from './slices';
import { fetchLearners } from './thunks';
import './__factories__';
let axiosMock;
let store;
describe('Learner redux test cases', () => {
beforeEach(async () => {
initializeMockApp({
authenticatedUser: {
userId: 3,
username: 'abc123',
administrator: true,
roles: [],
},
});
Factory.resetAll();
store = initializeStore();
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
});
afterEach(() => {
axiosMock.reset();
});
test('Successfully load initial states in redux', async () => {
executeThunk(
fetchLearners('course-v1:edX+DemoX+Demo_Course', { usernameSearch: 'learner-1' }),
store.dispatch, store.getState,
);
const { learners } = store.getState();
expect(learners.status).toEqual('in-progress');
expect(learners.learnerProfiles).toEqual({});
expect(learners.pages).toHaveLength(0);
expect(learners.nextPage).toBeNull();
expect(learners.totalPages).toBeNull();
expect(learners.totalLearners).toBeNull();
expect(learners.sortedBy).toEqual('activity');
expect(learners.usernameSearch).toBeNull();
expect(learners.postFilter.postType).toEqual('all');
expect(learners.postFilter.status).toEqual('statusAll');
expect(learners.postFilter.orderBy).toEqual('lastActivityAt');
expect(learners.postFilter.cohort).toEqual('');
});
test('Successfully store a learner posts stats data as pages object in redux',
async () => {
const learners = await setupLearnerMockResponse();
const page = learners.pages[0];
const statsObject = page[0];
expect(page).toHaveLength(3);
expect(statsObject.responses).toEqual(3);
expect(statsObject.threads).toEqual(1);
expect(statsObject.replies).toEqual(0);
});
test('Successfully store the nextPage, totalPages, totalLearners, and sortedBy data in redux',
async () => {
const learners = await setupLearnerMockResponse();
expect(learners.nextPage).toEqual(2);
expect(learners.totalPages).toEqual(2);
expect(learners.totalLearners).toEqual(6);
expect(learners.sortedBy).toEqual('activity');
});
test('Successfully updated the learner\'s sort data in redux', async () => {
const learners = await setupLearnerMockResponse();
expect(learners.sortedBy).toEqual('activity');
expect(learners.pages[0]).toHaveLength(3);
await store.dispatch(setSortedBy('recency'));
const updatedLearners = store.getState().learners;
expect(updatedLearners.sortedBy).toEqual('recency');
expect(updatedLearners.pages).toHaveLength(0);
});
test('Successfully updated the post-filter data in redux', async () => {
const learners = await setupLearnerMockResponse();
const filter = {
...learners.postFilter,
postType: 'discussion',
};
expect(learners.postFilter.postType).toEqual('all');
await store.dispatch(setPostFilter(filter));
const updatedLearners = store.getState().learners;
expect(updatedLearners.postFilter.postType).toEqual('discussion');
expect(updatedLearners.pages).toHaveLength(0);
});
test('Successfully update the learner\'s search query in redux when searching for a learner',
async () => {
const learners = await setupLearnerMockResponse();
expect(learners.usernameSearch).toBeNull();
await store.dispatch(setUsernameSearch('learner-2'));
const updatedLearners = store.getState().learners;
expect(updatedLearners.usernameSearch).toEqual('learner-2');
});
});

View File

@@ -0,0 +1,81 @@
import MockAdapter from 'axios-mock-adapter';
import { Factory } from 'rosie';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { initializeMockApp } from '@edx/frontend-platform/testing';
import { initializeStore } from '../../../store';
import { executeThunk } from '../../../test-utils';
import { getUserProfileApiUrl, learnersApiUrl } from './api';
import {
learnersLoadingStatus,
selectLearnerNextPage,
selectLearnerSorting,
selectUsernameSearch,
} from './selectors';
import { fetchLearners } from './thunks';
import './__factories__';
const courseId = 'course-v1:edX+DemoX+Demo_Course';
const userProfileApiUrl = getUserProfileApiUrl();
let axiosMock;
let store;
const username = 'abc123';
const learnerCount = 6;
let state;
describe('Learner selectors test cases', () => {
beforeEach(async () => {
initializeMockApp({
authenticatedUser: {
userId: 3,
username,
administrator: true,
roles: [],
},
});
Factory.resetAll();
store = initializeStore();
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
axiosMock.onGet(learnersApiUrl(courseId))
.reply(() => [200, Factory.build('learnersResult', {}, {
count: learnerCount,
pageSize: 3,
})]);
axiosMock.onGet(`${userProfileApiUrl}?username=learner-1,learner-2,learner-3`)
.reply(() => [200, Factory.build('learnersProfile', {}, {
username: ['learner-1', 'learner-2', 'learner-3'],
}).profiles]);
await executeThunk(fetchLearners(courseId), store.dispatch, store.getState);
state = store.getState();
});
afterEach(() => {
axiosMock.reset();
});
test('learnersLoadingStatus should return learners list loading status.', async () => {
const status = learnersLoadingStatus()(state);
expect(status).toEqual('successful');
});
test('selectUsernameSearch should return a learner search query.', async () => {
const userNameSearch = selectUsernameSearch()(state);
expect(userNameSearch).toBeNull();
});
test('selectLearnerSorting should return learner sortedBy.', async () => {
const learnerSorting = selectLearnerSorting()(state);
expect(learnerSorting).toEqual('activity');
});
test('selectLearnerNextPage should return learners next page.', async () => {
const learnerNextPage = selectLearnerNextPage()(state);
expect(learnerNextPage).toEqual(2);
});
});

View File

@@ -24,7 +24,7 @@ const ActionItem = ({
<label
htmlFor={id}
className="focus border-bottom-0 d-flex align-items-center w-100 py-2 m-0 font-weight-500 filter-menu"
data-testid={value === selected ? 'selected' : null}
data-testid={value === selected ? `${value} selected` : null}
style={{ cursor: 'pointer' }}
aria-checked={value === selected}
>

View File

@@ -0,0 +1,52 @@
import MockAdapter from 'axios-mock-adapter';
import { Factory } from 'rosie';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { initializeStore } from '../../store';
import { executeThunk } from '../../test-utils';
import { getUserProfileApiUrl, learnerPostsApiUrl, learnersApiUrl } from './data/api';
import { fetchLearners, fetchUserPosts } from './data/thunks';
const courseId = 'course-v1:edX+DemoX+Demo_Course';
export async function setupLearnerMockResponse({
learnerCourseId = courseId,
statusCode = 200,
learnerCount = 6,
} = {}) {
const store = initializeStore();
const axiosMock = new MockAdapter(getAuthenticatedHttpClient());
axiosMock.onGet(learnersApiUrl(learnerCourseId))
.reply(() => [statusCode, Factory.build('learnersResult', {}, {
count: learnerCount,
pageSize: 3,
})]);
axiosMock.onGet(`${getUserProfileApiUrl()}?username=learner-1,learner-2,learner-3`)
.reply(() => [statusCode, Factory.build('learnersProfile', {}, {
username: ['learner-1', 'learner-2', 'learner-3'],
}).profiles]);
await executeThunk(fetchLearners(courseId), store.dispatch, store.getState);
return store.getState().learners;
}
export async function setupPostsMockResponse({
learnerCourseId = courseId,
statusCode = 200,
username = 'abc123',
filters = { status: 'all' },
} = {}) {
const store = initializeStore();
const axiosMock = new MockAdapter(getAuthenticatedHttpClient());
axiosMock.onGet(learnerPostsApiUrl(learnerCourseId), { username, count_flagged: true })
.reply(() => [statusCode, Factory.build('learnerPosts', {}, {
abuseFlaggedCount: 1,
})]);
await executeThunk(fetchUserPosts(courseId, { filters }), store.dispatch, store.getState);
return store.getState().threads;
}

View File

@@ -1,6 +1,5 @@
import React, { useContext, useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import { useParams } from 'react-router';
import { useHistory, useLocation } from 'react-router-dom';
@@ -10,9 +9,7 @@ import {
} from '@edx/paragon';
import { ArrowBack } from '@edx/paragon/icons';
import {
EndorsementStatus, PostsPages, RequestStatus, ThreadType,
} from '../../data/constants';
import { EndorsementStatus, PostsPages, ThreadType } from '../../data/constants';
import { useDispatchWithState } from '../../data/hooks';
import { DiscussionContext } from '../common/context';
import { useIsOnDesktop } from '../data/hooks';
@@ -24,14 +21,12 @@ import { ResponseEditor } from './comments/comment';
import CommentsSort from './comments/CommentsSort';
import CommentsView from './comments/CommentsView';
import { useCommentsCount, usePost } from './data/hooks';
import { selectCommentsStatus } from './data/selectors';
import messages from './messages';
function PostCommentsView({ intl }) {
const [isLoading, submitDispatch] = useDispatchWithState();
const { postId } = useParams();
const thread = usePost(postId);
const commentsStatus = useSelector(selectCommentsStatus);
const commentsCount = useCommentsCount(postId);
const history = useHistory();
const location = useLocation();
@@ -40,7 +35,6 @@ function PostCommentsView({ intl }) {
const {
courseId, learnerUsername, category, topicId, page, enableInContextSidebar,
} = useContext(DiscussionContext);
const enableCommentsSort = false;
useEffect(() => {
if (!thread) { submitDispatch(fetchThread(postId, courseId, true)); }
@@ -99,7 +93,7 @@ function PostCommentsView({ intl }) {
)
)}
<div
className="discussion-comments d-flex flex-column card border-0 post-card-margin post-card-padding"
className="discussion-comments d-flex flex-column card border-0 post-card-margin post-card-padding on-focus"
>
<Post post={thread} handleAddResponseButton={() => setAddingResponse(true)} />
{!thread.closed && (
@@ -110,7 +104,7 @@ function PostCommentsView({ intl }) {
/>
)}
</div>
{!!commentsCount && commentsStatus === RequestStatus.SUCCESSFUL && enableCommentsSort && <CommentsSort />}
{!!commentsCount && <CommentsSort />}
{thread.type === ThreadType.DISCUSSION && (
<CommentsView
postId={postId}

View File

@@ -10,6 +10,7 @@ import { camelCaseObject, initializeMockApp } from '@edx/frontend-platform';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { AppProvider } from '@edx/frontend-platform/react';
import { getApiBaseUrl } from '../../data/constants';
import { initializeStore } from '../../store';
import { executeThunk } from '../../test-utils';
import { DiscussionContext } from '../common/context';
@@ -17,11 +18,18 @@ import { getCourseConfigApiUrl } from '../data/api';
import { fetchCourseConfig } from '../data/thunks';
import DiscussionContent from '../discussions-home/DiscussionContent';
import { getThreadsApiUrl } from '../posts/data/api';
import { fetchThreads } from '../posts/data/thunks';
import { fetchThread, fetchThreads } from '../posts/data/thunks';
import { fetchCourseTopics } from '../topics/data/thunks';
import { getDiscussionTourUrl } from '../tours/data/api';
import { selectTours } from '../tours/data/selectors';
import { fetchDiscussionTours } from '../tours/data/thunks';
import discussionTourFactory from '../tours/data/tours.factory';
import { getCommentsApiUrl } from './data/api';
import { removeComment } from './data/thunks';
import '../posts/data/__factories__';
import './data/__factories__';
import '../topics/data/__factories__';
const courseConfigApiUrl = getCourseConfigApiUrl();
const commentsApiUrl = getCommentsApiUrl();
@@ -30,10 +38,14 @@ const discussionPostId = 'thread-1';
const questionPostId = 'thread-2';
const closedPostId = 'thread-2';
const courseId = 'course-v1:edX+TestX+Test_Course';
const reverseOrder = false;
const topicsApiUrl = `${getApiBaseUrl()}/api/discussion/v1/course_topics/${courseId}`;
const reverseOrder = true;
const enableInContextSidebar = false;
let store;
let axiosMock;
let testLocation;
let container;
let unmount;
function mockAxiosReturnPagedComments() {
[null, false, true].forEach(endorsed => {
@@ -48,6 +60,7 @@ function mockAxiosReturnPagedComments() {
requested_fields: 'profile_image',
endorsed,
reverse_order: reverseOrder,
enable_in_context_sidebar: enableInContextSidebar,
},
})
.reply(200, Factory.build('commentsResult', { can_delete: true }, {
@@ -69,6 +82,7 @@ function mockAxiosReturnPagedCommentsResponses() {
page: undefined,
page_size: undefined,
requested_fields: 'profile_image',
reverse_order: true,
};
for (let page = 1; page <= 2; page++) {
@@ -83,6 +97,12 @@ function mockAxiosReturnPagedCommentsResponses() {
}
}
async function getThreadAPIResponse(threadId, topicId) {
axiosMock.onGet(`${threadsApiUrl}${discussionPostId}/`)
.reply(200, Factory.build('thread', { id: threadId, topic_id: topicId }));
await executeThunk(fetchThread(discussionPostId), store.dispatch, store.getState);
}
function renderComponent(postId) {
const wrapper = render(
<IntlProvider locale="en">
@@ -104,9 +124,49 @@ function renderComponent(postId) {
</AppProvider>
</IntlProvider>,
);
return wrapper;
container = wrapper.container;
unmount = wrapper.unmount;
}
describe('PostView', () => {
beforeEach(() => {
initializeMockApp({
authenticatedUser: {
userId: 3,
username: 'abc123',
administrator: true,
roles: [],
},
});
store = initializeStore();
Factory.resetAll();
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
axiosMock.onGet(topicsApiUrl)
.reply(200, {
non_courseware_topics: Factory.buildList('topic', 1, {}, { topicPrefix: 'non-courseware-' }),
courseware_topics: Factory.buildList('category', 1, {}, { name: 'courseware' }),
});
executeThunk(fetchCourseTopics(courseId), store.dispatch, store.getState);
});
it('should show Topic Info for non-courseware topics', async () => {
await getThreadAPIResponse('thread-1', 'non-courseware-topic-1');
renderComponent(discussionPostId);
expect(await screen.findByText('Related to')).toBeInTheDocument();
expect(await screen.findByText('non-courseware-topic 1')).toBeInTheDocument();
});
it('should show Topic Info for courseware topics with category', async () => {
await getThreadAPIResponse('thread-2', 'courseware-topic-2');
renderComponent('thread-2');
expect(await screen.findByText('Related to')).toBeInTheDocument();
expect(await screen.findByText('category-1 / courseware-topic 2')).toBeInTheDocument();
});
});
describe('ThreadView', () => {
beforeEach(() => {
initializeMockApp({
@@ -681,19 +741,87 @@ describe('ThreadView', () => {
});
});
describe('for comments replies', () => {
describe('For comments replies', () => {
it('shows delete confirmation modal', async () => {
renderComponent(discussionPostId);
const reply = await waitFor(() => screen.findByTestId('reply-comment-7'));
await act(async () => {
fireEvent.click(
within(reply).getByRole('button', { name: /actions menu/i }),
);
});
await act(async () => {
fireEvent.click(screen.queryByRole('button', { name: /Delete/i }));
});
await act(async () => { fireEvent.click(within(reply).getByRole('button', { name: /actions menu/i })); });
await act(async () => { fireEvent.click(screen.queryByRole('button', { name: /Delete/i })); });
expect(screen.queryByRole('dialog', { name: /Delete/i, exact: false })).toBeInTheDocument();
});
});
describe('for comments sort', () => {
const getCommentSortDropdown = async () => {
renderComponent(discussionPostId);
await waitFor(() => screen.findByTestId('comment-comment-1'));
await act(async () => { fireEvent.click(screen.getByRole('button', { name: /Newest first/i })); });
return waitFor(() => screen.findByTestId('comment-sort-dropdown-modal-popup'));
};
it('should show sort dropdown if there are endorse or unendorsed comments', async () => {
renderComponent(discussionPostId);
const comment = await waitFor(() => screen.findByTestId('comment-comment-1'));
const sortWrapper = container.querySelector('.comments-sort');
const sortDropDown = within(sortWrapper).getByRole('button', { name: /Newest first/i });
expect(comment).toBeInTheDocument();
expect(sortDropDown).toBeInTheDocument();
});
it('should not show sort dropdown if there is no response', async () => {
const commentId = 'comment-1';
renderComponent(discussionPostId);
await waitFor(() => screen.findByTestId('comment-comment-1'));
axiosMock.onDelete(`${commentsApiUrl}${commentId}/`).reply(201);
await executeThunk(removeComment(commentId, discussionPostId), store.dispatch, store.getState);
expect(await waitFor(() => screen.findByText('No responses', { exact: true }))).toBeInTheDocument();
expect(container.querySelector('.comments-sort')).not.toBeInTheDocument();
});
it('should have only two options', async () => {
const dropdown = await getCommentSortDropdown();
expect(dropdown).toBeInTheDocument();
expect(await within(dropdown).getAllByRole('button')).toHaveLength(2);
});
it('should be selected Newest first and auto focus', async () => {
const dropdown = await getCommentSortDropdown();
expect(within(dropdown).getByRole('button', { name: /Newest first/i })).toBeInTheDocument();
expect(within(dropdown).getByRole('button', { name: /Newest first/i })).toHaveFocus();
expect(within(dropdown).getByRole('button', { name: /Oldest first/i })).not.toHaveFocus();
});
test('successfully handles sort state update', async () => {
const dropdown = await getCommentSortDropdown();
expect(store.getState().comments.sortOrder).toBeTruthy();
await act(async () => { fireEvent.click(within(dropdown).getByRole('button', { name: /Oldest first/i })); });
expect(store.getState().comments.sortOrder).toBeFalsy();
});
test('successfully handles tour state update', async () => {
const tourName = 'response_sort';
await axiosMock.onGet(getDiscussionTourUrl(), {}).reply(200, [discussionTourFactory.build({ tourName })]);
await executeThunk(fetchDiscussionTours(), store.dispatch, store.getState);
renderComponent(discussionPostId);
await waitFor(() => screen.findByTestId('comment-comment-1'));
const responseSortTour = () => selectTours(store.getState()).find(item => item.tourName === 'response_sort');
expect(responseSortTour().enabled).toBeTruthy();
await unmount();
expect(responseSortTour().enabled).toBeFalsy();
});
});
});

View File

@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
@@ -6,31 +6,43 @@ import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import {
Button, Dropdown, ModalPopup, useToggle,
} from '@edx/paragon';
import {
ExpandLess, ExpandMore,
} from '@edx/paragon/icons';
import { ExpandLess, ExpandMore } from '@edx/paragon/icons';
import { updateUserDiscussionsTourByName } from '../../tours/data';
import { selectCommentSortOrder } from '../data/selectors';
import { setCommentSortOrder } from '../data/slices';
import messages from '../messages';
function CommentSortDropdown({
intl,
}) {
function CommentSortDropdown({ intl }) {
const dispatch = useDispatch();
const sortedOrder = useSelector(selectCommentSortOrder);
const [isOpen, open, close] = useToggle(false);
const [target, setTarget] = useState(null);
const handleActions = (reverseOrder) => {
close();
dispatch(setCommentSortOrder(reverseOrder));
};
const enableCommentsSortTour = useCallback((enabled) => {
const data = {
enabled,
tourName: 'response_sort',
};
dispatch(updateUserDiscussionsTourByName(data));
}, []);
useEffect(() => {
enableCommentsSortTour(true);
return () => {
enableCommentsSortTour(false);
};
}, []);
return (
<>
<div className="comments-sort d-flex justify-content-end mx-4 mt-2">
<Button
id="comment-sort"
alt={intl.formatMessage(messages.actionsAlt)}
ref={setTarget}
variant="tertiary"

View File

@@ -1,4 +1,7 @@
import React, { useContext, useEffect, useState } from 'react';
import React, {
useCallback,
useContext, useEffect, useMemo, useState,
} from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
@@ -16,7 +19,12 @@ import { useUserCanAddThreadInBlackoutDate } from '../../../data/hooks';
import { fetchThread } from '../../../posts/data/thunks';
import LikeButton from '../../../posts/post/LikeButton';
import { useActions } from '../../../utils';
import { selectCommentCurrentPage, selectCommentHasMorePages, selectCommentResponses } from '../../data/selectors';
import {
selectCommentCurrentPage,
selectCommentHasMorePages,
selectCommentResponses,
selectCommentSortOrder,
} from '../../data/selectors';
import { editComment, fetchCommentResponses, removeComment } from '../../data/thunks';
import messages from '../../messages';
import CommentEditor from './CommentEditor';
@@ -43,28 +51,32 @@ function Comment({
const hasMorePages = useSelector(selectCommentHasMorePages(comment.id));
const currentPage = useSelector(selectCommentCurrentPage(comment.id));
const userCanAddThreadInBlackoutDate = useUserCanAddThreadInBlackoutDate();
const {
courseId,
} = useContext(DiscussionContext);
const { courseId } = useContext(DiscussionContext);
const sortedOrder = useSelector(selectCommentSortOrder);
useEffect(() => {
// If the comment has a parent comment, it won't have any children, so don't fetch them.
if (hasChildren && !currentPage && showFullThread) {
dispatch(fetchCommentResponses(comment.id, { page: 1 }));
if (hasChildren && showFullThread) {
dispatch(fetchCommentResponses(comment.id, {
page: 1,
reverseOrder: sortedOrder,
}));
}
}, [comment.id]);
}, [comment.id, sortedOrder]);
const actions = useActions({
...comment,
postType,
});
const endorseIcons = actions.find(({ action }) => action === EndorsementStatus.ENDORSED);
const handleAbusedFlag = () => {
const handleAbusedFlag = useCallback(() => {
if (comment.abuseFlagged) {
dispatch(editComment(comment.id, { flagged: !comment.abuseFlagged }));
} else {
showReportConfirmation();
}
};
}, [comment.abuseFlagged, comment.id, dispatch, showReportConfirmation]);
const handleDeleteConfirmation = () => {
dispatch(removeComment(comment.id));
@@ -76,7 +88,7 @@ function Comment({
hideReportConfirmation();
};
const actionHandlers = {
const actionHandlers = useMemo(() => ({
[ContentActions.EDIT_CONTENT]: () => setEditing(true),
[ContentActions.ENDORSE]: async () => {
await dispatch(editComment(comment.id, { endorsed: !comment.endorsed }, ContentActions.ENDORSE));
@@ -84,10 +96,13 @@ function Comment({
},
[ContentActions.DELETE]: showDeleteConfirmation,
[ContentActions.REPORT]: () => handleAbusedFlag(),
};
}), [showDeleteConfirmation, dispatch, comment.id, comment.endorsed, comment.threadId, courseId, handleAbusedFlag]);
const handleLoadMoreComments = () => (
dispatch(fetchCommentResponses(comment.id, { page: currentPage + 1 }))
dispatch(fetchCommentResponses(comment.id, {
page: currentPage + 1,
reverseOrder: sortedOrder,
}))
);
return (
@@ -119,7 +134,7 @@ function Comment({
/>
)}
<EndorsedAlertBanner postType={postType} content={comment} />
<div className="d-flex flex-column post-card-comment px-4 pt-3.5 pb-10px" aria-level={5}>
<div className="d-flex flex-column post-card-comment px-4 pt-3.5 pb-10px" tabIndex="0">
<HoverCard
commentOrPost={comment}
actionHandlers={actionHandlers}

View File

@@ -13,6 +13,7 @@ import { TinyMCEEditor } from '../../../../components';
import FormikErrorFeedback from '../../../../components/FormikErrorFeedback';
import PostPreviewPane from '../../../../components/PostPreviewPane';
import { useDispatchWithState } from '../../../../data/hooks';
import { DiscussionContext } from '../../../common/context';
import {
selectModerationSettings,
selectUserHasModerationPrivileges,
@@ -32,6 +33,7 @@ function CommentEditor({
}) {
const editorRef = useRef(null);
const { authenticatedUser } = useContext(AppContext);
const { enableInContextSidebar } = useContext(DiscussionContext);
const userHasModerationPrivileges = useSelector(selectUserHasModerationPrivileges);
const userIsGroupTa = useSelector(selectUserIsGroupTa);
const userIsStaff = useSelector(selectUserIsStaff);
@@ -71,7 +73,7 @@ function CommentEditor({
};
await dispatch(editComment(comment.id, payload));
} else {
await dispatch(addComment(values.comment, comment.threadId, comment.parentId));
await dispatch(addComment(values.comment, comment.threadId, comment.parentId, enableInContextSidebar));
}
/* istanbul ignore if: TinyMCE is mocked so this cannot be easily tested */
if (editorRef.current) {

View File

@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useCallback, useMemo, useState } from 'react';
import PropTypes from 'prop-types';
import { useDispatch, useSelector } from 'react-redux';
@@ -31,13 +31,13 @@ function Reply({
const [isDeleting, showDeleteConfirmation, hideDeleteConfirmation] = useToggle(false);
const [isReporting, showReportConfirmation, hideReportConfirmation] = useToggle(false);
const handleAbusedFlag = () => {
const handleAbusedFlag = useCallback(() => {
if (reply.abuseFlagged) {
dispatch(editComment(reply.id, { flagged: !reply.abuseFlagged }));
} else {
showReportConfirmation();
}
};
}, [dispatch, reply.abuseFlagged, reply.id, showReportConfirmation]);
const handleDeleteConfirmation = () => {
dispatch(removeComment(reply.id));
@@ -49,7 +49,7 @@ function Reply({
hideReportConfirmation();
};
const actionHandlers = {
const actionHandlers = useMemo(() => ({
[ContentActions.EDIT_CONTENT]: () => setEditing(true),
[ContentActions.ENDORSE]: () => dispatch(editComment(
reply.id,
@@ -58,7 +58,8 @@ function Reply({
)),
[ContentActions.DELETE]: showDeleteConfirmation,
[ContentActions.REPORT]: () => handleAbusedFlag(),
};
}), [dispatch, handleAbusedFlag, reply.endorsed, reply.id, showDeleteConfirmation]);
const authorAvatars = useSelector(selectAuthorAvatars(reply.author));
const colorClass = AvatarOutlineAndLabelColors[reply.authorLabel];
const hasAnyAlert = useAlertBannerVisible(reply);

View File

@@ -16,6 +16,8 @@ export const getCommentsApiUrl = () => `${getConfig().LMS_BASE_URL}/api/discussi
* @param {EndorsementStatus} endorsed
* @param {number=} page
* @param {number=} pageSize
* @param reverseOrder
* @param enableInContextSidebar
* @returns {Promise<{}>}
*/
export async function getThreadComments(
@@ -24,6 +26,7 @@ export async function getThreadComments(
page,
pageSize,
reverseOrder,
enableInContextSidebar = false,
} = {},
) {
const params = snakeCaseObject({
@@ -33,6 +36,7 @@ export async function getThreadComments(
pageSize,
reverseOrder,
requestedFields: 'profile_image',
enableInContextSidebar,
});
const { data } = await getAuthenticatedHttpClient()
@@ -51,6 +55,7 @@ export async function getCommentResponses(
commentId, {
page,
pageSize,
reverseOrder,
} = {},
) {
const url = `${getCommentsApiUrl()}${commentId}/`;
@@ -58,6 +63,7 @@ export async function getCommentResponses(
page,
pageSize,
requestedFields: 'profile_image',
reverseOrder,
});
const { data } = await getAuthenticatedHttpClient()
.get(url, { params });
@@ -69,11 +75,14 @@ export async function getCommentResponses(
* @param {string} comment Raw comment data to post.
* @param {string} threadId Thread ID for thread in which to post comment.
* @param {string=} parentId ID for a comments parent.
* @param {boolean} enableInContextSidebar
* @returns {Promise<{}>}
*/
export async function postComment(comment, threadId, parentId = null) {
export async function postComment(comment, threadId, parentId = null, enableInContextSidebar = false) {
const { data } = await getAuthenticatedHttpClient()
.post(getCommentsApiUrl(), snakeCaseObject({ threadId, raw_body: comment, parentId }));
.post(getCommentsApiUrl(), snakeCaseObject({
threadId, raw_body: comment, parentId, enableInContextSidebar,
}));
return data;
}

View File

@@ -1,9 +1,12 @@
import { useEffect } from 'react';
import { useContext, useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import { EndorsementStatus } from '../../../data/constants';
import { useDispatchWithState } from '../../../data/hooks';
import { DiscussionContext } from '../../common/context';
import { selectThread } from '../../posts/data/selectors';
import { markThreadAsRead } from '../../posts/data/thunks';
import {
@@ -11,6 +14,16 @@ import {
} from './selectors';
import { fetchThreadComments } from './thunks';
function trackLoadMoreEvent(postId, params) {
sendTrackEvent(
'edx.forum.responses.loadMore',
{
postId,
params,
},
);
}
export function usePost(postId) {
const dispatch = useDispatch();
const thread = useSelector(selectThread(postId));
@@ -30,18 +43,24 @@ export function usePostComments(postId, endorsed = null) {
const reverseOrder = useSelector(selectCommentSortOrder);
const hasMorePages = useSelector(selectThreadHasMorePages(postId, endorsed));
const currentPage = useSelector(selectThreadCurrentPage(postId, endorsed));
const { enableInContextSidebar } = useContext(DiscussionContext);
const handleLoadMoreResponses = async () => dispatch(fetchThreadComments(postId, {
endorsed,
page: currentPage + 1,
reverseOrder,
}));
const handleLoadMoreResponses = async () => {
const params = {
endorsed,
page: currentPage + 1,
reverseOrder,
};
await dispatch(fetchThreadComments(postId, params));
trackLoadMoreEvent(postId, params);
};
useEffect(() => {
dispatch(fetchThreadComments(postId, {
endorsed,
page: 1,
reverseOrder,
enableInContextSidebar,
}));
}, [postId, reverseOrder]);

View File

@@ -22,7 +22,7 @@ const commentsSlice = createSlice({
postStatus: RequestStatus.SUCCESSFUL,
pagination: {},
responsesPagination: {},
sortOrder: false,
sortOrder: true,
},
reducers: {
fetchCommentsRequest: (state) => {
@@ -75,12 +75,16 @@ const commentsSlice = createSlice({
},
fetchCommentResponsesSuccess: (state, { payload }) => {
state.status = RequestStatus.SUCCESSFUL;
state.commentsInComments[payload.commentId] = [
...new Set([
...(state.commentsInComments[payload.commentId] || []),
...(payload.commentsInComments[payload.commentId] || []),
]),
];
if (payload.page === 1) {
state.commentsInComments[payload.commentId] = payload.commentsInComments[payload.commentId] || [];
} else {
state.commentsInComments[payload.commentId] = [
...new Set([
...(state.commentsInComments[payload.commentId] || []),
...(payload.commentsInComments[payload.commentId] || []),
]),
];
}
state.commentsById = { ...state.commentsById, ...payload.commentsById };
state.responsesPagination[payload.commentId] = {
currentPage: payload.page,

View File

@@ -80,12 +80,15 @@ export function fetchThreadComments(
page = 1,
reverseOrder,
endorsed = EndorsementStatus.DISCUSSION,
enableInContextSidebar,
} = {},
) {
return async (dispatch) => {
try {
dispatch(fetchCommentsRequest());
const data = await getThreadComments(threadId, { page, reverseOrder, endorsed });
const data = await getThreadComments(threadId, {
page, reverseOrder, endorsed, enableInContextSidebar,
});
dispatch(fetchCommentsSuccess({
...normaliseComments(camelCaseObject(data)),
endorsed,
@@ -103,11 +106,11 @@ export function fetchThreadComments(
};
}
export function fetchCommentResponses(commentId, { page = 1 } = {}) {
export function fetchCommentResponses(commentId, { page = 1, reverseOrder = true } = {}) {
return async (dispatch) => {
try {
dispatch(fetchCommentResponsesRequest({ commentId }));
const data = await getCommentResponses(commentId, { page });
const data = await getCommentResponses(commentId, { page, reverseOrder });
dispatch(fetchCommentResponsesSuccess({
...normaliseComments(camelCaseObject(data)),
page,
@@ -144,7 +147,7 @@ export function editComment(commentId, comment, action = null) {
};
}
export function addComment(comment, threadId, parentId = null) {
export function addComment(comment, threadId, parentId = null, enableInContextSidebar = false) {
return async (dispatch) => {
try {
dispatch(postCommentRequest({
@@ -152,7 +155,7 @@ export function addComment(comment, threadId, parentId = null) {
threadId,
parentId,
}));
const data = await postComment(comment, threadId, parentId);
const data = await postComment(comment, threadId, parentId, enableInContextSidebar);
dispatch(postCommentSuccess(camelCaseObject(data)));
} catch (error) {
if (getHttpErrorStatus(error) === 403) {

View File

@@ -160,9 +160,9 @@ describe('PostsView', () => {
test('displays a list of posts in a topic', async () => {
setupStore();
await act(async () => {
await renderComponent({ topicId: 'some-topic-1' });
await renderComponent({ topicId: 'test-topic-1' });
});
expect(screen.getAllByText(/this is thread-\d+ in topic some-topic-1/i)).toHaveLength(Math.ceil(threadCount / 3));
expect(screen.getAllByText(/this is thread-\d+ in topic test-topic-1/i)).toHaveLength(Math.ceil(threadCount / 3));
});
test.each([true, false])(
@@ -173,10 +173,10 @@ describe('PostsView', () => {
blocks: {
'test-usage-key': {
type: 'vertical',
topics: ['some-topic-2', 'some-topic-0'],
topics: ['test-topic-2', 'test-topic-0'],
parent: 'test-seq-key',
},
'test-seq-key': { type: 'sequential', topics: ['some-topic-0', 'some-topic-1', 'some-topic-2'] },
'test-seq-key': { type: 'sequential', topics: ['test-topic-0', 'test-topic-1', 'test-topic-2'] },
},
},
config: { groupAtSubsection: grouping, hasModerationPrivileges: true, provider: 'openedx' },
@@ -185,12 +185,12 @@ describe('PostsView', () => {
await renderComponent({ category: 'test-usage-key', enableInContextSidebar: true, p: true });
});
const topicThreadCount = Math.ceil(threadCount / 3);
expect(screen.queryAllByText(/this is thread-\d+ in topic some-topic-2/i))
expect(screen.queryAllByText(/this is thread-\d+ in topic test-topic-2/i))
.toHaveLength(topicThreadCount);
expect(screen.queryAllByText(/this is thread-\d+ in topic some-topic-0/i))
expect(screen.queryAllByText(/this is thread-\d+ in topic test-topic-0/i))
.toHaveLength(topicThreadCount);
// When grouping is enabled, topic 1 will be shown, but not otherwise.
expect(screen.queryAllByText(/this is thread-\d+ in topic some-topic-1/i))
expect(screen.queryAllByText(/this is thread-\d+ in topic test-topic-1/i))
.toHaveLength(grouping ? topicThreadCount : 2);
},
);

View File

@@ -7,7 +7,7 @@ Factory.define('thread')
.sequence('rendered_body', (idx) => `Some contents for <b>thread number ${idx}</b>.`)
.sequence('type', (idx) => (idx % 2 === 1 ? 'discussion' : 'question'))
.sequence('pinned', idx => (idx < 3))
.sequence('topic_id', idx => `some-topic-${(idx % 3)}`)
.sequence('topic_id', idx => `test-topic-${(idx % 3)}`)
.sequence('closed', idx => Boolean(idx % 3 === 2)) // Mark every 3rd post closed
.attr('comment_list_url', ['id'], (threadId) => `http://test.site/api/discussion/v1/comments/?thread_id=${threadId}`)
.attrs({

View File

@@ -87,6 +87,7 @@ export async function getThread(threadId, courseId) {
* @param {boolean} following Follow the thread after creating
* @param {boolean} anonymous Should the thread be anonymous to all users
* @param {boolean} anonymousToPeers Should the thread be anonymous to peers
* @param {boolean} enableInContextSidebar
* @returns {Promise<{}>}
*/
export async function postThread(
@@ -101,6 +102,7 @@ export async function postThread(
anonymous,
anonymousToPeers,
} = {},
enableInContextSidebar = false,
) {
const postData = snakeCaseObject({
courseId,
@@ -112,8 +114,8 @@ export async function postThread(
anonymous,
anonymousToPeers,
groupId: cohort,
enableInContextSidebar,
});
const { data } = await getAuthenticatedHttpClient()
.post(getThreadsApiUrl(), postData);
return data;

View File

@@ -102,7 +102,7 @@ describe('Threads/Posts data layer tests', () => {
expect(store.getState().threads.threadsById['thread-1'])
.toHaveProperty('topicId');
expect(store.getState().threads.threadsById['thread-1'].topicId)
.toEqual('some-topic-1');
.toEqual('test-topic-1');
});
test('successfully handles thread creation', async () => {

View File

@@ -204,6 +204,7 @@ export function createNewThread({
anonymous,
anonymousToPeers,
cohort,
enableInContextSidebar,
}) {
return async (dispatch) => {
try {
@@ -223,7 +224,7 @@ export function createNewThread({
following,
anonymous,
anonymousToPeers,
});
}, enableInContextSidebar);
dispatch(postThreadSuccess(camelCaseObject(data)));
} catch (error) {
if (getHttpErrorStatus(error) === 403) {

View File

@@ -106,7 +106,7 @@ function PostEditor({
const nonCoursewareIds = useSelector(enableInContext ? inContextCoursewareIds : selectNonCoursewareIds);
const coursewareTopics = useSelector(enableInContext ? inContextCourseware : selectCoursewareTopics);
const cohorts = useSelector(selectCourseCohorts);
const post = useSelector(selectThread(postId));
const post = useSelector(editExisting ? selectThread(postId) : () => ({}));
const userHasModerationPrivileges = useSelector(selectUserHasModerationPrivileges);
const userIsGroupTa = useSelector(selectUserIsGroupTa);
const settings = useSelector(selectDivisionSettings);
@@ -187,6 +187,7 @@ function PostEditor({
anonymous: allowAnonymous ? values.anonymous : undefined,
anonymousToPeers: allowAnonymousToPeers ? values.anonymousToPeers : undefined,
cohort,
enableInContextSidebar,
}));
}
/* istanbul ignore if: TinyMCE is mocked so this cannot be easily tested */

View File

@@ -141,6 +141,16 @@ describe('PostEditor', () => {
}
},
);
test('selectThread is not called while creating a new post', async () => {
const mockSelectThread = jest.fn();
jest.mock('../data/selectors', () => ({
selectThread: mockSelectThread,
}));
await renderComponent();
expect(mockSelectThread)
.not
.toHaveBeenCalled();
});
});
describe('cohorting', () => {

View File

@@ -1,10 +1,11 @@
import React, { useContext } from 'react';
import React, { useCallback, useContext, useMemo } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { useDispatch, useSelector } from 'react-redux';
import { useHistory, useLocation } from 'react-router-dom';
import { getConfig } from '@edx/frontend-platform';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { Hyperlink, useToggle } from '@edx/paragon';
@@ -41,13 +42,14 @@ function Post({
const [isDeleting, showDeleteConfirmation, hideDeleteConfirmation] = useToggle(false);
const [isReporting, showReportConfirmation, hideReportConfirmation] = useToggle(false);
const [isClosing, showClosePostModal, hideClosePostModal] = useToggle(false);
const handleAbusedFlag = () => {
const handleAbusedFlag = useCallback(() => {
if (post.abuseFlagged) {
dispatch(updateExistingThread(post.id, { flagged: !post.abuseFlagged }));
} else {
showReportConfirmation();
}
};
}, [dispatch, post.abuseFlagged, post.id, showReportConfirmation]);
const handleDeleteConfirmation = async () => {
await dispatch(removeThread(post.id));
@@ -63,7 +65,7 @@ function Post({
hideReportConfirmation();
};
const actionHandlers = {
const actionHandlers = useMemo(() => ({
[ContentActions.EDIT_CONTENT]: () => history.push({
...location,
pathname: `${location.pathname}/edit`,
@@ -81,17 +83,34 @@ function Post({
[ContentActions.COPY_LINK]: () => { navigator.clipboard.writeText(`${window.location.origin}/${courseId}/posts/${post.id}`); },
[ContentActions.PIN]: () => dispatch(updateExistingThread(post.id, { pinned: !post.pinned })),
[ContentActions.REPORT]: () => handleAbusedFlag(),
};
}), [
showDeleteConfirmation,
history,
location,
post.closed,
post.id,
post.pinned,
reasonCodesEnabled,
dispatch,
showClosePostModal,
courseId,
handleAbusedFlag,
]);
const getTopicCategoryName = topicData => (
topicData.usageKey ? getTopicSubsection(topicData.usageKey)?.displayName : topicData.categoryId
);
const getTopicInfo = topicData => (
getTopicCategoryName(topicData) ? `${getTopicCategoryName(topicData)} / ${topicData.name}` : `${topicData.name}`
);
return (
<div
className="d-flex flex-column w-100 mw-100 post-card-comment"
aria-level={5}
data-testid={`post-${post.id}`}
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex="0"
>
<Confirmation
isOpen={isDeleting}
@@ -126,7 +145,7 @@ function Post({
<div className="d-flex mt-14px text-break font-style text-primary-500">
<HTMLLoader htmlNode={post.renderedBody} componentId="post" cssClassName="html-loader" testId={post.id} />
</div>
{topicContext && (
{(topicContext || topic) && (
<div
className={classNames('mt-14px mb-1 font-style font-size-12',
{ 'w-100': enableInContextSidebar })}
@@ -134,7 +153,7 @@ function Post({
>
<span className="text-gray-500" style={{ lineHeight: '20px' }}>{intl.formatMessage(messages.relatedTo)}{' '}</span>
<Hyperlink
destination={topicContext.unitLink}
destination={topicContext ? topicContext.unitLink : `${getConfig().BASE_URL}/${courseId}/topics/${post.topicId}`}
target="_top"
>
{(topicContext && !topic)
@@ -147,7 +166,7 @@ function Post({
<span className="w-auto">{topicContext.unitName}</span>
</>
)
: `${getTopicCategoryName(topic)} / ${topic.name}`}
: getTopicInfo(topic)}
</Hyperlink>
</div>
)}

View File

@@ -10,5 +10,13 @@ export default function tourCheckpoints(intl) {
title: intl.formatMessage(messages.notRespondedFilterTourTitle),
},
],
RESPONSE_SORT: [
{
body: intl.formatMessage(messages.responseSortTourBody),
placement: 'left',
target: '#comment-sort',
title: intl.formatMessage(messages.responseSortTourTitle),
},
],
};
}

View File

@@ -5,29 +5,25 @@ import { initializeMockApp } from '@edx/frontend-platform/testing';
import { RequestStatus } from '../../../data/constants';
import { initializeStore } from '../../../store';
import { executeThunk } from '../../../test-utils';
import { getDiscussionTourUrl } from './api';
import { selectTours } from './selectors';
import {
discussionsTourRequest,
discussionsToursRequestError,
fetchUserDiscussionsToursSuccess,
toursReducer,
updateUserDiscussionsTourByName,
updateUserDiscussionsTourSuccess,
} from './slices';
import { fetchDiscussionTours, updateTourShowStatus } from './thunks';
import discussionTourFactory from './tours.factory';
let mockAxios;
// eslint-disable-next-line no-unused-vars
let store;
const url = getDiscussionTourUrl();
describe('DiscussionToursThunk', () => {
let actualActions;
const dispatch = (action) => {
actualActions.push(action);
};
let actualActions;
let mockAxios;
let store;
describe('DiscussionTours data layer', () => {
beforeEach(() => {
initializeMockApp({
authenticatedUser: {
@@ -46,168 +42,147 @@ describe('DiscussionToursThunk', () => {
mockAxios.reset();
});
it('dispatches get request, success actions', async () => {
const mockData = discussionTourFactory.buildList(2);
mockAxios.onGet(url)
.reply(200, mockData);
describe('DiscussionToursThunk', () => {
const dispatch = (action) => {
actualActions.push(action);
};
const expectedActions = [
{
const getExpectedAction = (mockData) => ({
request: {
payload: undefined,
type: 'userDiscussionsTours/discussionsTourRequest',
},
{
fetch: {
type: 'userDiscussionsTours/fetchUserDiscussionsToursSuccess',
payload: mockData,
},
];
await fetchDiscussionTours()(dispatch);
expect(actualActions)
.toEqual(expectedActions);
});
it('dispatches request, and error actions', async () => {
mockAxios.onGet('/api/discussion-tours/')
.reply(500);
const errorAction = [{
payload: undefined,
type: 'userDiscussionsTours/discussionsTourRequest',
}, {
payload: undefined,
type: 'userDiscussionsTours/discussionsToursRequestError',
}];
await fetchDiscussionTours()(dispatch);
expect(actualActions)
.toEqual(errorAction);
});
it('dispatches put request, success actions', async () => {
const mockData = discussionTourFactory.build();
mockAxios.onPut(`${url}${1}`)
.reply(200, mockData);
const expectedActions = [
{
payload: undefined,
type: 'userDiscussionsTours/discussionsTourRequest',
},
{
update: {
type: 'userDiscussionsTours/updateUserDiscussionsTourSuccess',
payload: mockData,
},
];
await updateTourShowStatus(1)(dispatch);
expect(actualActions)
.toEqual(expectedActions);
error: {
payload: undefined,
type: 'userDiscussionsTours/discussionsToursRequestError',
},
});
it('dispatches get request, success actions', async () => {
const mockData = discussionTourFactory.buildList(2);
mockAxios.onGet(url).reply(200, mockData);
const expectedActions = [getExpectedAction().request, getExpectedAction(mockData).fetch];
await fetchDiscussionTours()(dispatch);
expect(actualActions).toEqual(expectedActions);
});
it('dispatches request, and error actions', async () => {
mockAxios.onGet('/api/discussion-tours/').reply(500);
const expectedActions = [getExpectedAction().request, getExpectedAction().error];
await fetchDiscussionTours()(dispatch);
expect(actualActions).toEqual(expectedActions);
});
it('dispatches put request, success actions', async () => {
const mockData = discussionTourFactory.build();
mockAxios.onPut(`${url}${1}`).reply(200, mockData);
const expectedActions = [getExpectedAction().request, getExpectedAction(mockData).update];
await updateTourShowStatus(1)(dispatch);
expect(actualActions).toEqual(expectedActions);
});
it('dispatches update request, and error actions', async () => {
mockAxios.onPut(`${url}${1}`).reply(500);
const expectedActions = [getExpectedAction().request, getExpectedAction().error];
await updateTourShowStatus(1)(dispatch);
expect(actualActions).toEqual(expectedActions);
});
});
it('dispatches update request, and error actions', async () => {
mockAxios.onPut(`${url}${1}`)
.reply(500);
const errorAction = [{
payload: undefined,
type: 'userDiscussionsTours/discussionsTourRequest',
}, {
payload: undefined,
type: 'userDiscussionsTours/discussionsToursRequestError',
}];
describe('toursReducer', () => {
it('handles the discussionsToursRequest action', async () => {
store.dispatch(discussionsTourRequest());
const { tours } = store.getState();
await updateTourShowStatus(1)(dispatch);
expect(actualActions)
.toEqual(errorAction);
});
});
expect(tours.tours).toEqual([]);
expect(tours.error).toBeNull();
expect(tours.loading).toEqual(RequestStatus.IN_PROGRESS);
});
describe('toursReducer', () => {
it('handles the discussionsToursRequest action', () => {
const initialState = {
tours: [],
loading: false,
error: null,
};
const state = toursReducer(initialState, discussionsTourRequest());
expect(state)
.toEqual({
tours: [],
loading: RequestStatus.IN_PROGRESS,
error: null,
});
});
it('handles the fetchUserDiscussionsToursSuccess action', async () => {
const mockData = [{ id: 1 }, { id: 2 }];
await store.dispatch(fetchUserDiscussionsToursSuccess(mockData));
const { tours } = store.getState();
it('handles the fetchUserDiscussionsToursSuccess action', () => {
const initialState = {
tours: [],
loading: true,
error: null,
};
const mockData = [{ id: 1 }, { id: 2 }];
const state = toursReducer(initialState, fetchUserDiscussionsToursSuccess(mockData));
expect(state)
.toEqual({
expect(tours).toEqual({
tours: mockData,
loading: RequestStatus.SUCCESSFUL,
error: null,
});
});
});
it('handles the updateUserDiscussionsTourSuccess action', () => {
const initialState = {
tours: [
{ id: 1 },
{ id: 2 },
],
};
const updatedTour = {
id: 2,
name: 'Updated Tour',
};
const state = toursReducer(initialState, updateUserDiscussionsTourSuccess(updatedTour));
expect(state.tours)
.toEqual([{ id: 1 }, updatedTour]);
});
it('handles the updateUserDiscussionsTourSuccess action', async () => {
const updatedTour = { id: 2, name: 'Updated Tour' };
await store.dispatch(fetchUserDiscussionsToursSuccess([{ id: 1 }, { id: 2 }]));
await store.dispatch(updateUserDiscussionsTourSuccess(updatedTour));
const { tours } = store.getState();
it('handles the discussionsToursRequestError action', () => {
const initialState = {
tours: [],
loading: true,
error: null,
};
const mockError = new Error('Something went wrong');
const state = toursReducer(initialState, discussionsToursRequestError(mockError));
expect(state)
.toEqual({
expect(tours.tours).toEqual([{ id: 1 }, updatedTour]);
});
it('handles the discussionsToursRequestError action', async () => {
const errorMessage = 'Something went wrong';
await store.dispatch(discussionsToursRequestError(errorMessage));
const { tours } = store.getState();
expect(tours).toEqual({
tours: [],
loading: RequestStatus.FAILED,
error: mockError,
error: errorMessage,
});
});
});
});
describe('tourSelector', () => {
it('returns the tours list from state', () => {
const state = {
tours: {
tours: [
{ id: 1, tourName: 'not_responded_filter' },
{ id: 2, tourName: 'other_filter' },
],
},
};
const expectedResult = [
{ id: 1, tourName: 'not_responded_filter' },
{ id: 2, tourName: 'other_filter' },
];
expect(selectTours(state)).toEqual(expectedResult);
it('handles the updateUserDiscussionsTourByName action', async () => {
const tourName = 'response_sort';
const updatedTour = {
tourName: 'response_sort',
enabled: false,
};
await mockAxios.onGet(getDiscussionTourUrl(), {}).reply(200, [discussionTourFactory.build({ tourName })]);
await executeThunk(fetchDiscussionTours(), store.dispatch, store.getState);
store.dispatch(updateUserDiscussionsTourByName(updatedTour));
expect(store.getState().tours.tours).toEqual([{
id: 4,
tourName: 'response_sort',
enabled: false,
description: 'This is the description for Discussion Tour 4.',
}]);
});
});
it('returns an empty list if the tours state is not defined', () => {
const state = {
tours: {
tours: [],
},
};
expect(selectTours(state))
.toEqual([]);
describe('tourSelector', () => {
it('returns the tours list from state', async () => {
await mockAxios.onGet(getDiscussionTourUrl(), {}).reply(200, [
discussionTourFactory.build({ tourName: 'other_filter' }),
]);
await executeThunk(fetchDiscussionTours(), store.dispatch, store.getState);
expect(selectTours(store.getState())).toEqual([{
id: 5,
tourName: 'other_filter',
description: 'This is the description for Discussion Tour 5.',
enabled: true,
}]);
});
it('returns an empty list if the tours state is not defined', async () => {
await executeThunk(fetchDiscussionTours(), store.dispatch, store.getState);
expect(selectTours(store.getState())).toEqual([]);
});
});
});

View File

@@ -31,6 +31,12 @@ const userDiscussionsToursSlice = createSlice({
state.loading = RequestStatus.SUCCESSFUL;
state.error = null;
},
updateUserDiscussionsTourByName: (state, action) => {
const tourIndex = state.tours.findIndex(tour => tour.tourName === action.payload.tourName);
state.tours[tourIndex] = { ...state.tours[tourIndex], ...action.payload };
state.loading = RequestStatus.SUCCESSFUL;
state.error = null;
},
},
});
@@ -39,6 +45,7 @@ export const {
fetchUserDiscussionsToursSuccess,
discussionsToursRequestError,
updateUserDiscussionsTourSuccess,
updateUserDiscussionsTourByName,
} = userDiscussionsToursSlice.actions;
export const toursReducer = userDiscussionsToursSlice.reducer;

View File

@@ -9,6 +9,10 @@ import {
updateUserDiscussionsTourSuccess,
} from './slices';
function normaliseTourData(data) {
return data.map(tour => ({ ...tour, enabled: true }));
}
/**
* Action thunk to fetch the list of discussion tours for the current user.
* @returns {function} - Thunk that dispatches the request, success, and error actions.
@@ -18,7 +22,7 @@ export function fetchDiscussionTours() {
try {
dispatch(discussionsTourRequest());
const data = await getDiscssionTours();
dispatch(fetchUserDiscussionsToursSuccess(camelCaseObject(data)));
dispatch(fetchUserDiscussionsToursSuccess(camelCaseObject(normaliseTourData(data))));
} catch (error) {
dispatch(discussionsToursRequestError());
logError(error);

View File

@@ -2,7 +2,8 @@ import { Factory } from 'rosie';
const discussionTourFactory = new Factory()
.sequence('id')
.attr('name', ['id'], (id) => `Discussion Tour ${id}`)
.attr('description', ['id'], (id) => `This is the description for Discussion Tour ${id}.`);
.attr('tourName', ['id'], (id) => `Discussion Tour ${id}`)
.attr('description', ['id'], (id) => `This is the description for Discussion Tour ${id}.`)
.attr('enabled', ['id'], true);
export default discussionTourFactory;

View File

@@ -26,6 +26,16 @@ const messages = defineMessages({
defaultMessage: 'New filtering option!',
description: 'Title of the tour for the not responded filter',
},
responseSortTourBody: {
id: 'tour.body.responseSortTour',
defaultMessage: 'Responses and comments are now sorted by newest first. Please use this option to change the sort order',
description: 'Body of the tour for the response sort',
},
responseSortTourTitle: {
id: 'tour.title.responseSortTour',
defaultMessage: 'Sort Responses!',
description: 'Title of the tour for the response sort',
},
});
export default messages;

View File

@@ -208,5 +208,7 @@
"tour.action.dismiss": "Dismiss",
"tour.action.end": "Okay",
"tour.body.notRespondedFilter": "Now you can filter discussions to find posts with no response.",
"tour.title.notRespondedFilter": "New filtering option!"
"tour.title.notRespondedFilter": "New filtering option!",
"tour.body.responseSortTour": "Responses and comments are now sorted by newest first. Please use this option to change the sort order",
"tour.title.responseSortTour": "Sort Responses!"
}

View File

@@ -208,5 +208,7 @@
"tour.action.dismiss": "Abgewiesen",
"tour.action.end": "okay",
"tour.body.notRespondedFilter": "Jetzt können Sie Diskussionen filtern, um Beiträge ohne Antwort zu finden.",
"tour.title.notRespondedFilter": "Neue Filteroption!"
"tour.title.notRespondedFilter": "Neue Filteroption!",
"tour.body.responseSortTour": "Responses and comments are now sorted by newest first. Please use this option to change the sort order",
"tour.title.responseSortTour": "Sort Responses!"
}

View File

@@ -208,5 +208,7 @@
"tour.action.dismiss": "Descartar",
"tour.action.end": "Okey",
"tour.body.notRespondedFilter": "Ahora puede filtrar debates para encontrar publicaciones sin respuesta.",
"tour.title.notRespondedFilter": "¡Nueva opción de filtrado!"
"tour.title.notRespondedFilter": "¡Nueva opción de filtrado!",
"tour.body.responseSortTour": "Responses and comments are now sorted by newest first. Please use this option to change the sort order",
"tour.title.responseSortTour": "Sort Responses!"
}

View File

@@ -1,61 +1,61 @@
{
"navigation.course.tabs.label": "Course Material",
"navigation.course.tabs.label": "Matériel de cours",
"learn.course.tabs.navigation.overflow.menu": "Plus...",
"discussions.topics.backAlt": "Back to topics list",
"discussions.topics.backAlt": "Retour à la liste des sujets",
"discussions.topics.discussions": "{count, plural,\n =0 {Discussion}\n one {# Discussion}\n other {# Discussions}\n }",
"discussions.topics.questions": "{count, plural,\n =0 {Question}\n one {# Question}\n other {# Questions}\n }",
"discussions.topics.reported": "{reported} reported",
"discussions.topics.previouslyReported": "{previouslyReported} previously reported",
"discussions.topics.find.label": "Search topics",
"discussions.topics.unnamed.section.label": "Unnamed Section",
"discussions.topics.unnamed.subsection.label": "Unnamed Subsection",
"discussions.subtopics.unnamed.topic.label": "Unnamed Topic",
"discussions.topics.title": "No topic exists",
"discussions.topics.createTopic": "Please contact you admin to create a topic",
"discussions.topics.reported": "{reported} signalé",
"discussions.topics.previouslyReported": "{previouslyReported} signalé précédemment",
"discussions.topics.find.label": "Rechercher des sujets",
"discussions.topics.unnamed.section.label": "Section sans nom",
"discussions.topics.unnamed.subsection.label": "Sous-section sans nom",
"discussions.subtopics.unnamed.topic.label": "Sujet sans nom",
"discussions.topics.title": "Aucun sujet n'existe",
"discussions.topics.createTopic": "Veuillez contacter votre administrateur pour créer un sujet",
"discussions.topics.nothing": "Nothing here yet",
"discussions.topics.archived.label": "Archived",
"discussions.topics.archived.label": "Archivé",
"discussions.learner.reported": "{reported} signalé",
"discussions.learner.previouslyReported": "{previouslyReported} previously reported",
"discussions.learner.lastLogin": "Last active {lastActiveTime}",
"discussions.learner.previouslyReported": "{previouslyReported} signalé précédemment",
"discussions.learner.lastLogin": "Dernier actif {lastActiveTime}",
"discussions.learner.loadMostLearners": "Charger plus",
"discussions.learner.back": "Retour",
"discussions.learner.activityForLearner": "Activité pour {username}",
"discussions.learner.mostActivity": "Most activity",
"discussions.learner.reportedActivity": "Reported activity",
"discussions.learner.recentActivity": "Recent activity",
"discussions.learner.mostActivity": "La plupart des activités",
"discussions.learner.reportedActivity": "Activité signalée",
"discussions.learner.recentActivity": "Activité récente",
"discussions.learner.sortFilterStatus": "All learners sorted by {sort, select,\n flagged {reported activity}\n activity {most activity}\n other {{sort}}\n }",
"discussion.learner.allActivity": "All activity",
"discussion.learner.allActivity": "Toutes les activités",
"discussion.learner.posts": "Posts",
"discussions.actions.button.alt": "Actions menu",
"discussions.actions.copylink": "Copy link",
"discussions.actions.button.alt": "Menu Actions",
"discussions.actions.copylink": "Copier le lien",
"discussions.actions.edit": "Modifier",
"discussions.actions.pin": "Épingler",
"discussions.actions.unpin": "Unpin",
"discussions.actions.delete": "Delete",
"discussions.confirmation.button.confirm": "Confirm",
"discussions.actions.close": "Close",
"discussions.actions.reopen": "Reopen",
"discussions.actions.unpin": "Ne plus épingler",
"discussions.actions.delete": "Supprimer",
"discussions.confirmation.button.confirm": "Confirmer",
"discussions.actions.close": "Fermer",
"discussions.actions.reopen": "Réouvrir",
"discussions.actions.report": "Report",
"discussions.actions.unreport": "Unreport",
"discussions.actions.endorse": "Endorse",
"discussions.actions.unendorse": "Unendorse",
"discussions.actions.markAnswered": "Mark as answered",
"discussions.actions.endorse": "Approuver",
"discussions.actions.unendorse": "Ne plus approuver",
"discussions.actions.markAnswered": "Marquer comme répondu",
"discussions.actions.unMarkAnswered": "Unmark as answered",
"discussions.modal.confirmation.button.cancel": "Cancel",
"discussions.modal.confirmation.button.cancel": "Annuler",
"discussions.empty.allTopics": "All discussion activity for these topics will show up here.",
"discussions.empty.allPosts": "All discussion activity for your course will show up here.",
"discussions.empty.myPosts": "Posts you've interacted with will show up here.",
"discussions.empty.topic": "All discussion activity for this topic will show up here.",
"discussions.empty.title": "Nothing here yet",
"discussions.empty.title": "Rien ici encore",
"discussions.empty.noPostSelected": "No post selected",
"discussions.empty.noTopicSelected": "No topic selected",
"discussions.sidebar.noResultsFound": "No results found",
"discussions.empty.noTopicSelected": "Aucun sujet sélectionné",
"discussions.sidebar.noResultsFound": "Aucun résultat trouvé",
"discussions.sidebar.differentKeywords": "Try searching different keywords",
"discussions.sidebar.removeKeywords": "Try searching different keywords or removing some filters",
"discussions.sidebar.removeKeywordsOnly": "Try searching different keywords",
"discussions.sidebar.removeFilters": "Try removing some filters",
"discussions.empty.iconAlt": "Empty",
"discussions.authors.label.staff": "Staff",
"discussions.empty.iconAlt": "Vide",
"discussions.authors.label.staff": "Équipe",
"discussions.authors.label.ta": "TA",
"discussions.learner.loadMostPosts": "Load more posts",
"discussions.post.anonymous.author": "anonymous",
@@ -208,5 +208,7 @@
"tour.action.dismiss": "Dismiss",
"tour.action.end": "Okay",
"tour.body.notRespondedFilter": "Now you can filter discussions to find posts with no response.",
"tour.title.notRespondedFilter": "New filtering option!"
"tour.title.notRespondedFilter": "New filtering option!",
"tour.body.responseSortTour": "Responses and comments are now sorted by newest first. Please use this option to change the sort order",
"tour.title.responseSortTour": "Sort Responses!"
}

View File

@@ -208,5 +208,7 @@
"tour.action.dismiss": "Rejeter",
"tour.action.end": "Okay",
"tour.body.notRespondedFilter": "Vous pouvez maintenant filtrer les discussions pour trouver les messages sans réponse.",
"tour.title.notRespondedFilter": "Nouvelle option de filtrage!"
"tour.title.notRespondedFilter": "Nouvelle option de filtrage!",
"tour.body.responseSortTour": "Les réponses et les commentaires sont désormais triés par les plus récents en premier. Veuillez utiliser cette option pour modifier l'ordre de tri",
"tour.title.responseSortTour": "Triez les réponses !"
}

View File

@@ -208,5 +208,7 @@
"tour.action.dismiss": "Dismiss",
"tour.action.end": "Okay",
"tour.body.notRespondedFilter": "Now you can filter discussions to find posts with no response.",
"tour.title.notRespondedFilter": "New filtering option!"
"tour.title.notRespondedFilter": "New filtering option!",
"tour.body.responseSortTour": "Responses and comments are now sorted by newest first. Please use this option to change the sort order",
"tour.title.responseSortTour": "Sort Responses!"
}

View File

@@ -208,5 +208,7 @@
"tour.action.dismiss": "Dismiss",
"tour.action.end": "Okay",
"tour.body.notRespondedFilter": "Now you can filter discussions to find posts with no response.",
"tour.title.notRespondedFilter": "New filtering option!"
"tour.title.notRespondedFilter": "New filtering option!",
"tour.body.responseSortTour": "Responses and comments are now sorted by newest first. Please use this option to change the sort order",
"tour.title.responseSortTour": "Sort Responses!"
}

View File

@@ -208,5 +208,7 @@
"tour.action.dismiss": "Dismiss",
"tour.action.end": "Okay",
"tour.body.notRespondedFilter": "Now you can filter discussions to find posts with no response.",
"tour.title.notRespondedFilter": "New filtering option!"
"tour.title.notRespondedFilter": "New filtering option!",
"tour.body.responseSortTour": "Responses and comments are now sorted by newest first. Please use this option to change the sort order",
"tour.title.responseSortTour": "Sort Responses!"
}

View File

@@ -208,5 +208,7 @@
"tour.action.dismiss": "İptal",
"tour.action.end": "Tamam",
"tour.body.notRespondedFilter": "Artık yanıt vermeyen iletileri bulmak için tartışmaları filtreleyebilirsiniz.",
"tour.title.notRespondedFilter": "Yeni filtreleme seçeneği!"
"tour.title.notRespondedFilter": "Yeni filtreleme seçeneği!",
"tour.body.responseSortTour": "Responses and comments are now sorted by newest first. Please use this option to change the sort order",
"tour.title.responseSortTour": "Sort Responses!"
}

View File

@@ -208,5 +208,7 @@
"tour.action.dismiss": "Dismiss",
"tour.action.end": "Okay",
"tour.body.notRespondedFilter": "Now you can filter discussions to find posts with no response.",
"tour.title.notRespondedFilter": "New filtering option!"
"tour.title.notRespondedFilter": "New filtering option!",
"tour.body.responseSortTour": "Responses and comments are now sorted by newest first. Please use this option to change the sort order",
"tour.title.responseSortTour": "Sort Responses!"
}

View File

@@ -433,7 +433,7 @@ header {
pointer-events: none;
}
.on-focus:focus-visible {
.on-focus:focus-within {
outline: 2px solid black;
}
@@ -442,6 +442,8 @@ header {
}
.post-card-comment {
outline: none;
&:not(:hover),
&:not(:focus) {
.hover-card {
@@ -450,7 +452,7 @@ header {
}
&:hover,
&:focus {
&:focus-within {
.hover-card {
display: flex;
}

View File

@@ -1,4 +1,5 @@
/* eslint-disable import/prefer-default-export */
export const executeThunk = async (thunk, dispatch, getState) => {
await thunk(dispatch, getState);
await new Promise(setImmediate);