-
Notifications
You must be signed in to change notification settings - Fork 21
FC-86 feat: Empty page templates #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
brian-smith-tcril
merged 5 commits into
openedx:master
from
raccoongang:keblysh/feat/empty-page-templates
Jun 3, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c8dc06b
feat: add empty page templates
vladislavkeblysh 46017bd
feat: update test
vladislavkeblysh 1ed63c6
feat: refactor after review
vladislavkeblysh 6c0f09d
feat: refactor after review
vladislavkeblysh f39ac73
feat: refactor after review
vladislavkeblysh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| const CourseAboutPage = () => ( | ||
| // TODO: remove it when will start develop page | ||
| <div data-testid="course-about-page" /> | ||
| ); | ||
|
|
||
| export default CourseAboutPage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| const HomePage = () => ( | ||
| // TODO: remove it when will start develop page | ||
| <div data-testid="home-page" /> | ||
| ); | ||
|
|
||
| export default HomePage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import React from 'react'; | ||
| import { Routes, Route } from 'react-router-dom'; | ||
| import { AppProvider } from '@edx/frontend-platform/react'; | ||
|
|
||
| import HomePage from './home/HomePage'; | ||
| import CatalogPage from './сatalog/CatalogPage'; | ||
| import CourseAboutPage from './course-about/CourseAboutPage'; | ||
| import { render } from './setupTest'; | ||
|
|
||
| jest.mock('@edx/frontend-platform', () => ({ | ||
| ...jest.requireActual('@edx/frontend-platform'), | ||
| getAuthenticatedUser: () => ({ username: 'test_user', roles: [] }), | ||
| })); | ||
|
|
||
| jest.mock('@edx/frontend-platform/react', () => { | ||
| const original = jest.requireActual('@edx/frontend-platform/react'); | ||
| return { | ||
| ...original, | ||
| useAuthenticatedUser: () => ({ username: 'test_user', roles: [] }), | ||
| // eslint-disable-next-line react/prop-types | ||
| AppProvider: ({ children }) => <div>{children}</div>, | ||
| }; | ||
| }); | ||
|
|
||
| jest.mock('@edx/frontend-component-header', () => ( | ||
| <header>Header</header> | ||
| )); | ||
|
|
||
| jest.mock('@edx/frontend-component-footer', () => ({ | ||
| FooterSlot: () => <footer>Footer</footer>, | ||
| })); | ||
|
|
||
| const renderWithProviders = (path = '/') => { | ||
| // eslint-disable-next-line no-underscore-dangle | ||
| window._testHistory = [path]; | ||
|
|
||
| return render( | ||
| <AppProvider> | ||
| <Routes> | ||
| <Route path="/" element={<HomePage />} /> | ||
| <Route path="/courses" element={<CatalogPage />} /> | ||
| <Route path="/courses/:courseId/about" element={<CourseAboutPage />} /> | ||
| </Routes> | ||
| </AppProvider>, | ||
| ); | ||
| }; | ||
|
|
||
| describe('App routing', () => { | ||
| it('renders HomePage at route /', () => { | ||
| const { getByTestId } = renderWithProviders('/'); | ||
|
|
||
| expect(getByTestId('home-page')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders CatalogPage at route /courses', () => { | ||
| const { getByTestId } = renderWithProviders('/courses'); | ||
|
|
||
| expect(getByTestId('catalog-page')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders CourseAboutPage at route /courses/123/about', () => { | ||
| const { getByTestId } = renderWithProviders('/courses/123/about'); | ||
|
|
||
| expect(getByTestId('course-about-page')).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,40 @@ | ||
| import 'core-js/stable'; | ||
| import 'regenerator-runtime/runtime'; | ||
| import '@testing-library/jest-dom'; | ||
| import { IntlProvider } from '@edx/frontend-platform/i18n'; | ||
| import { render as rtlRender } from '@testing-library/react'; | ||
| import PropTypes from 'prop-types'; | ||
| import { MemoryRouter } from 'react-router-dom'; | ||
| import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
|
|
||
| function render(ui) { | ||
| const queryClient = new QueryClient({ | ||
| defaultOptions: { | ||
| queries: { | ||
| retry: false, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| const Wrapper = ({ children }) => ( | ||
| // eslint-disable-next-line react/jsx-filename-extension | ||
| <QueryClientProvider client={queryClient}> | ||
| {/* eslint-disable-next-line no-underscore-dangle */} | ||
| <MemoryRouter initialEntries={window._testHistory || ['/']}> | ||
| <IntlProvider locale="en"> | ||
| {children} | ||
| </IntlProvider> | ||
| </MemoryRouter> | ||
| </QueryClientProvider> | ||
| ); | ||
|
|
||
| Wrapper.propTypes = { | ||
| children: PropTypes.node.isRequired, | ||
| }; | ||
|
|
||
| return rtlRender(ui, { wrapper: Wrapper }); | ||
| } | ||
|
|
||
| export { | ||
| render, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| const CatalogPage = () => ( | ||
| // TODO: remove it when will start develop page | ||
| <div data-testid="catalog-page" /> | ||
| ); | ||
|
|
||
| export default CatalogPage; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some spacing between these lines jest.mocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed