From 6bc0065259c7eba9650944b0c4536819a5f94d84 Mon Sep 17 00:00:00 2001 From: Kshitij Sobti Date: Wed, 30 Mar 2022 16:40:42 +0530 Subject: [PATCH] feat: use resize postmessage API to send size hints to parent (#100) When the post list is resized, send a size hint to the parent window (LMS/Learning MFE) so it can resize the discussions MFE iframe dynamically. --- .env | 1 + .env.development | 1 + .env.test | 1 + .../comments/CommentsView.test.jsx | 88 ++++++++++--------- src/discussions/data/hooks.js | 62 ++++++++++++- src/discussions/data/hooks.test.jsx | 67 ++++++++++++++ .../discussions-home/DiscussionContent.jsx | 14 +-- src/setupTest.js | 43 ++++++++- 8 files changed, 226 insertions(+), 51 deletions(-) create mode 100644 src/discussions/data/hooks.test.jsx diff --git a/.env b/.env index 9fc7c719..5bc31041 100644 --- a/.env +++ b/.env @@ -6,6 +6,7 @@ CSRF_TOKEN_API_PATH='' ECOMMERCE_BASE_URL='' LANGUAGE_PREFERENCE_COOKIE_NAME='' LMS_BASE_URL='' +LEARNING_BASE_URL='' LOGIN_URL='' LOGOUT_URL='' LOGO_URL='' diff --git a/.env.development b/.env.development index 5266dd5d..af61c869 100644 --- a/.env.development +++ b/.env.development @@ -7,6 +7,7 @@ CSRF_TOKEN_API_PATH='/csrf/api/v1/token' ECOMMERCE_BASE_URL='http://localhost:18130' LANGUAGE_PREFERENCE_COOKIE_NAME='openedx-language-preference' LMS_BASE_URL='http://localhost:18000' +LEARNING_BASE_URL='http://localhost:2000' LOGIN_URL='http://localhost:18000/login' LOGOUT_URL='http://localhost:18000/logout' LOGO_URL=https://edx-cdn.org/v3/default/logo.svg diff --git a/.env.test b/.env.test index e6a9bc01..cfb9b321 100644 --- a/.env.test +++ b/.env.test @@ -5,6 +5,7 @@ CSRF_TOKEN_API_PATH='/csrf/api/v1/token' ECOMMERCE_BASE_URL='http://localhost:18130' LANGUAGE_PREFERENCE_COOKIE_NAME='openedx-language-preference' LMS_BASE_URL='http://localhost:18000' +LEARNING_BASE_URL='http://localhost:2000' LOGIN_URL='http://localhost:18000/login' LOGOUT_URL='http://localhost:18000/logout' LOGO_URL=https://edx-cdn.org/v3/default/logo.svg diff --git a/src/discussions/comments/CommentsView.test.jsx b/src/discussions/comments/CommentsView.test.jsx index 3854fac4..2d10d4be 100644 --- a/src/discussions/comments/CommentsView.test.jsx +++ b/src/discussions/comments/CommentsView.test.jsx @@ -1,11 +1,9 @@ -import PropTypes from 'prop-types'; - import { act, fireEvent, render, screen, waitFor, within, } from '@testing-library/react'; import MockAdapter from 'axios-mock-adapter'; import { IntlProvider } from 'react-intl'; -import { MemoryRouter, Route } from 'react-router'; +import { MemoryRouter } from 'react-router'; import { Factory } from 'rosie'; import { camelCaseObject, initializeMockApp } from '@edx/frontend-platform'; @@ -16,10 +14,10 @@ import { initializeStore } from '../../store'; import { executeThunk } from '../../test-utils'; import { courseConfigApiUrl } from '../data/api'; import { fetchCourseConfig } from '../data/thunks'; +import DiscussionContent from '../discussions-home/DiscussionContent'; import { threadsApiUrl } from '../posts/data/api'; import { fetchThreads } from '../posts/data/thunks'; import { commentsApiUrl } from './data/api'; -import CommentsView from './CommentsView'; import '../posts/data/__factories__'; import './data/__factories__'; @@ -30,37 +28,6 @@ const courseId = 'course-v1:edX+TestX+Test_Course'; let store; let axiosMock; -// Provides a mock editor component that functions like tinyMCE without the overhead -function MockEditor({ - onBlur, - onEditorChange, -}) { - return ( -