Skip to content

Commit 6a32fc5

Browse files
committed
Merge branch 'master' of github.com:isaacphysics/isaac-react-app into gh-actions-docker-build
2 parents 2209924 + 118f3ad commit 6a32fc5

File tree

9 files changed

+84
-39
lines changed

9 files changed

+84
-39
lines changed

src/app/components/navigation/IsaacApp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export const IsaacApp = () => {
187187
<TrackedRoute exact path="/progress" ifUser={isLoggedIn} component={MyProgress} />
188188
<TrackedRoute exact path="/progress/:userIdOfInterest" ifUser={isLoggedIn} component={MyProgress} />
189189
<TrackedRoute exact path={PATHS.MY_GAMEBOARDS} ifUser={isLoggedIn} component={MyGameboards} />
190-
<TrackedRoute exact path={PATHS.GAMEBOARD_FILTER} ifUser={isNotPartiallyLoggedIn} component={GameboardFilter} />
190+
<TrackedRoute exact path={PATHS.GAMEBOARD_FILTER} ifUser={isLoggedIn} component={GameboardFilter} />
191191
<TrackedRoute exact path={PATHS.QUESTION_FINDER} component={QuestionFinder} />
192192

193193
{/* Teacher pages */}

src/app/components/pages/AssignmentSchedule.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,11 @@ const DateAssignmentList = ({date, assignments}: {date: number; assignments: Val
342342
};
343343

344344
const monthHexagon = calculateHexagonProportions(12, 1);
345-
const shouldOpenMonth = (month: number) => {
346-
return (new Date()).getMonth() === month;
345+
const shouldOpenMonth = (year: number, month: number) => {
346+
return (new Date()).getMonth() === month && (new Date()).getFullYear() === year;
347347
};
348-
const MonthAssignmentList = ({month, datesAndAssignments}: {month: number, datesAndAssignments: [number, ValidAssignmentWithListingDate[]][]}) => {
349-
const [open, setOpen] = useState<boolean>(shouldOpenMonth(month));
348+
const MonthAssignmentList = ({year, month, datesAndAssignments}: {year: number, month: number, datesAndAssignments: [number, ValidAssignmentWithListingDate[]][]}) => {
349+
const [open, setOpen] = useState<boolean>(shouldOpenMonth(year, month));
350350
const assignmentCount = useMemo(() => datesAndAssignments.reduce((n, [_, as]) => n + as.length, 0), [datesAndAssignments]);
351351
const {collapsed, setCollapsed, viewBy} = useContext(AssignmentScheduleContext);
352352
useEffect(() => {
@@ -715,7 +715,7 @@ export const AssignmentSchedule = ({user}: {user: RegisteredUserDTO}) => {
715715
<h3 className="mb-n3">{`${y}`}</h3>
716716
<hr className="ms-4"/>
717717
</div>
718-
{ms.map(([m, ds]) => <MonthAssignmentList key={m} month={m} datesAndAssignments={ds}/>)}
718+
{ms.map(([m, ds]) => <MonthAssignmentList key={m} year={y} month={m} datesAndAssignments={ds}/>)}
719719
</Fragment>
720720
)}
721721
<div className={classNames("bg-timeline", {"fade-in": !notAllPastAssignmentsAreListed})}/>

src/app/components/pages/Gameboard.tsx

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,12 @@ import {
3131
useUserViewingContext
3232
} from "../../services";
3333
import {Redirect} from "react-router";
34-
import queryString from "query-string";
3534
import {StageAndDifficultySummaryIcons} from "../elements/StageAndDifficultySummaryIcons";
3635
import {Markup} from "../elements/markup";
3736
import classNames from "classnames";
3837
import {skipToken} from "@reduxjs/toolkit/query";
3938
import {ShowLoadingQuery} from "../handlers/ShowLoadingQuery";
4039

41-
function extractFilterQueryString(gameboard: GameboardDTO): string {
42-
const csvQuery: {[key: string]: string} = {};
43-
if (gameboard.gameFilter) {
44-
Object.entries(gameboard.gameFilter).forEach(([key, values]) => {
45-
csvQuery[key] = values.join(",");
46-
});
47-
}
48-
return queryString.stringify(csvQuery, {encode: false});
49-
}
50-
5140
const GameboardItemComponent = ({gameboard, question}: {gameboard: GameboardDTO, question: GameboardItem}) => {
5241
let itemClasses = classNames("content-summary-link text-info bg-white", {"p-3": isPhy, "p-0": isAda});
5342
const itemSubject = tags.getSpecifiedTag(TAG_LEVEL.subject, question.tags as TAG_ID[]);
@@ -109,7 +98,7 @@ const GameboardItemComponent = ({gameboard, question}: {gameboard: GameboardDTO,
10998
</div>}
11099
</div>
111100
{question.audience && <StageAndDifficultySummaryIcons stack={isAda && below['sm'](deviceSize)} audienceViews={
112-
isPhy && !isTutorOrAbove(currentUser) && uniqueStage ? [uniqueStage] : questionViewingContexts
101+
isPhy && !isTutorOrAbove(currentUser) && uniqueStage ? [uniqueStage] : questionViewingContexts
113102
} />}
114103
</div>
115104
{isAda && <div className={"list-caret vertical-center"}><img src={"/assets/common/icons/chevron_right.svg"} alt={"Go to question"}/></div>}
@@ -159,14 +148,6 @@ export const Gameboard = withRouter(({ location }) => {
159148
const { data: gameboard } = gameboardQuery;
160149
const user = useAppSelector(selectors.user.orNull);
161150

162-
// Show filter
163-
const {filter} = queryString.parse(location.search);
164-
let showFilter = false;
165-
if (filter) {
166-
const filterValue = filter instanceof Array ? filter[0] : filter;
167-
showFilter = isDefined(filterValue) && filterValue.toLowerCase() === "true";
168-
}
169-
170151
// Only log a gameboard view when we have a gameboard loaded:
171152
useEffect(() => {
172153
if (isDefined(gameboard) && isFound(gameboard)) {
@@ -180,25 +161,17 @@ export const Gameboard = withRouter(({ location }) => {
180161
<small>
181162
{`We're sorry, we were not able to find a ${siteSpecific("gameboard", "quiz")} with the id `}<code>{gameboardId}</code>{"."}
182163
</small>
183-
{isPhy && <div className="mt-4 text-center">
184-
<Button tag={Link} to={PATHS.GAMEBOARD_FILTER} color="primary" outline className="btn-lg">
185-
Generate a new gameboard
186-
</Button>
187-
</div>}
188164
</h3>
189165
</Container>;
190166

191167
return !gameboardId
192-
? <Redirect to={PATHS.GAMEBOARD_FILTER} />
168+
? <Redirect to={PATHS.QUESTION_FINDER} />
193169
: <Container className="mb-5">
194170
<ShowLoadingQuery
195171
query={gameboardQuery}
196172
defaultErrorTitle={`Error fetching ${siteSpecific("gameboard", "quiz")} with id: ${gameboardId}`}
197173
ifNotFound={notFoundComponent}
198174
thenRender={(gameboard) => {
199-
if (showFilter) {
200-
return <Redirect to={`${PATHS.GAMEBOARD_FILTER}?${extractFilterQueryString(gameboard)}#${gameboardId}`} />;
201-
}
202175
return <>
203176
<TitleAndBreadcrumb currentPageTitle={gameboard && gameboard.title || `Filter Generated ${siteSpecific("Gameboard", "Quiz")}`}/>
204177
<GameboardViewer gameboard={gameboard} className="mt-4 mt-lg-5" />

src/app/components/pages/MyGameboards.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ export const MyGameboards = () => {
185185
{boards && boards.totalResults == 0 ?
186186
<>
187187
<h3 className="text-center mt-4">You have no {siteSpecific("gameboards", "quizzes")} to view.</h3>
188-
{isPhy && <div className="text-center mt-3 mb-5">
189-
<Button color="secondary" tag={Link} to={PATHS.GAMEBOARD_FILTER}>Create a gameboard</Button>
190-
</div>}
191188
</>
192189
:
193190
<>

src/mocks/data.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4444,6 +4444,57 @@ export const mockQuestionFinderResults = {
44444444
"totalResults": 5
44454445
};
44464446

4447+
export const mockConceptPage =
4448+
{
4449+
"type": "isaacConceptPage",
4450+
"encoding": "markdown",
4451+
"title": "Mock concept page",
4452+
"children": [
4453+
{
4454+
"type": "content",
4455+
"encoding": "markdown",
4456+
"value": "This is some text on a concept page."
4457+
},
4458+
{
4459+
"type": "content",
4460+
"layout": "accordion",
4461+
"children": [
4462+
{
4463+
"type": "content",
4464+
"children": [
4465+
{
4466+
"type": "content",
4467+
"value": "This is some text within an accordion on a concept page.",
4468+
"encoding": "markdown"
4469+
}
4470+
],
4471+
"level": "2",
4472+
"title": "Accordion",
4473+
"id": "_mock_accordion_",
4474+
"audience": [
4475+
{
4476+
"stage": [
4477+
"a_level"
4478+
]
4479+
}
4480+
]
4481+
}
4482+
]
4483+
}
4484+
],
4485+
"id": "_mock_concept_page_",
4486+
"summary": "A mock concept page",
4487+
"tags": [
4488+
"physics",
4489+
"thermal"
4490+
],
4491+
"published": false,
4492+
"relatedContent": [
4493+
"cc_ideal_gas"
4494+
],
4495+
"subtitle": "Mock concept page"
4496+
};
4497+
44474498
export const mockSetAssignments = [
44484499
{
44494500
id: 37,

src/mocks/handlers.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
mockUserAuthSettings,
1414
mockUserPreferences,
1515
mockRegressionTestQuestions,
16-
mockQuestionFinderResults
16+
mockQuestionFinderResults,
17+
mockConceptPage
1718
} from "./data";
1819
import {API_PATH} from "../app/services";
1920
import {produce} from "immer";
@@ -160,6 +161,11 @@ export const handlers = [
160161
status: 200,
161162
});
162163
}),
164+
http.get(API_PATH + "/pages/concepts/_mock_concept_page_", () => {
165+
return HttpResponse.json(mockConceptPage, {
166+
status: 200,
167+
});
168+
}),
163169
http.get(API_PATH + "/pages/:pageId", ({params}) => {
164170
const {pageId} = params;
165171

src/test/pages/Concept.cy.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from "react";
2+
import { Concept } from "../../app/components/pages/Concept";
3+
4+
it('Concept pages should have no visual regressions', () => {
5+
6+
// @ts-ignore
7+
cy.mountWithStoreAndRouter(<Concept conceptIdOverride="_mock_concept_page_"/>, ["/concepts/_mock_concept_page_"]);
8+
9+
cy.get('[data-testid="loading"]').should('not.exist');
10+
11+
// open accordion
12+
cy.get('.accordion-header > button:not(.active)').scrollIntoView();
13+
cy.get('.accordion-header > button:not(.active)').click();
14+
15+
cy.scrollTo('top');
16+
17+
cy.matchImage();
18+
});
Loading
Loading

0 commit comments

Comments
 (0)