Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/IsaacApiTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ export interface GroupMembershipDTO {
created?: Date;
}

export type Stage = "year_7_and_8" | "year_9" | "gcse" | "a_level" | "further_a" | "university" | "scotland_national_5" | "scotland_higher" | "scotland_advanced_higher" | "core" | "advanced" | "all";
export type Stage = "year_7_and_8" | "year_9" | "gcse" | "a_level" | "further_a" | "university" | "scotland_national_5" | "scotland_higher" | "scotland_advanced_higher" | "core" | "advanced" | "post_18" | "all";

export type ExamBoard = "aqa" | "cie" | "edexcel" | "eduqas" | "ocr" | "wjec" | "sqa" | "ada" | "all";

Expand Down
1 change: 1 addition & 0 deletions src/app/components/pages/ExamSpecifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const ExamSpecifications = ({stageFilter, examBoardFilter, title}: ExamSp
[STAGE.SCOTLAND_ADVANCED_HIGHER]: "Discover our free Advanced Higher computer science topics and questions. Learn or revise for your exams with us today.",
[STAGE.CORE]: "Discover our free Core computer science topics and questions. Learn or revise for your exams with us today.",
[STAGE.ADVANCED]: "Discover our free Advanced computer science topics and questions. Learn or revise for your exams with us today.",
[STAGE.POST_18]: "Discover our free Post-18 computer science topics and questions. Learn or revise for your exams with us today.", // Not used, but needed for typing
})[stageTab];

const examBoardTabs = Object.keys(FILTERED_EXAM_BOARDS_BY_STAGE).reduce((acc: {[stage: string]: React.JSX.Element}, stage) => ({
Expand Down
8 changes: 6 additions & 2 deletions src/app/services/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,12 @@ export enum STAGE {
SCOTLAND_ADVANCED_HIGHER = "scotland_advanced_higher",
CORE = "core",
ADVANCED = "advanced",
POST_18 = "post_18",
ALL = "all",
}
export const STAGE_NULL_OPTIONS = [STAGE.ALL];
export const STAGES_PHY = [STAGE.YEAR_7_AND_8, STAGE.YEAR_9, STAGE.GCSE, STAGE.A_LEVEL, STAGE.FURTHER_A, STAGE.UNIVERSITY] as const;
export const STAGES_CS = [STAGE.GCSE, STAGE.A_LEVEL, STAGE.SCOTLAND_NATIONAL_5, STAGE.SCOTLAND_HIGHER, STAGE.SCOTLAND_ADVANCED_HIGHER, STAGE.CORE, STAGE.ADVANCED] as const;
export const STAGES_CS = [STAGE.GCSE, STAGE.A_LEVEL, STAGE.SCOTLAND_NATIONAL_5, STAGE.SCOTLAND_HIGHER, STAGE.SCOTLAND_ADVANCED_HIGHER, STAGE.CORE, STAGE.ADVANCED, STAGE.POST_18] as const;
export const stagesOrdered: Stage[] = [...siteSpecific(STAGES_PHY, STAGES_CS), STAGE.ALL];
export const stageLabelMap: {[stage in Stage]: string} = {
year_7_and_8: "Year\u00A07&8",
Expand All @@ -295,6 +296,7 @@ export const stageLabelMap: {[stage in Stage]: string} = {
scotland_advanced_higher: "Adv Higher",
core: "Core",
advanced: "Advanced",
post_18: "Post-18",
all: "All stages",
};

Expand Down Expand Up @@ -330,6 +332,7 @@ export const CS_EXAM_BOARDS_BY_STAGE: {[stage in typeof STAGES_CS[number]]: Exam
scotland_advanced_higher: [EXAM_BOARD.SQA],
core: [EXAM_BOARD.ADA],
advanced: [EXAM_BOARD.ADA],
post_18: [EXAM_BOARD.ADA],
};

export const EXAM_BOARD_NULL_OPTIONS = [EXAM_BOARD.ALL];
Expand Down Expand Up @@ -470,13 +473,14 @@ export const STAGE_TO_LEARNING_STAGE: {[stage in STAGE]: LearningStage | undefin
scotland_advanced_higher: "a_level",
core: "gcse",
advanced: "a_level",
post_18: "university",
};

export const LEARNING_STAGE_TO_STAGES: {[stage in LearningStage]: STAGE[]} = {
"11_14": [STAGE.YEAR_7_AND_8, STAGE.YEAR_9],
gcse: [STAGE.GCSE, STAGE.SCOTLAND_NATIONAL_5, STAGE.CORE],
a_level: [STAGE.A_LEVEL, STAGE.FURTHER_A, STAGE.SCOTLAND_HIGHER, STAGE.SCOTLAND_ADVANCED_HIGHER, STAGE.ADVANCED],
university: [STAGE.UNIVERSITY],
university: [STAGE.UNIVERSITY, STAGE.POST_18],
};

export const HUMAN_STAGES: {[key: string]: string} = {
Expand Down
16 changes: 9 additions & 7 deletions src/app/services/userViewingContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ const _STAGE_ITEM_OPTIONS = siteSpecific([ /* best not to export - use getFilter
{label: "All Stages (Default)", value: STAGE.ALL},
{label: "Core", value: STAGE.CORE},
{label: "Advanced", value: STAGE.ADVANCED},
{label: "Post-18", value: STAGE.POST_18},
{label: "GCSE", value: STAGE.GCSE},
{label: "A Level", value: STAGE.A_LEVEL},
{label: "National 5", value: STAGE.SCOTLAND_NATIONAL_5},
Expand Down Expand Up @@ -471,8 +472,8 @@ export function audienceStyle(audienceString: string): string {
case stageLabelMap.scotland_advanced_higher:
return "stage-label-advanced";

case stageLabelMap.post_18:
case stageLabelMap.scotland_higher:
// Scotland higher has a unique styling
return "stage-label-higher";

default:
Expand Down Expand Up @@ -508,14 +509,15 @@ export function stringifyAudience(audience: ContentDTO["audience"], userContext:
// - Advanced Higher
// with intra-group separation by commas, inter-group separation by newlines

const coreOrAdvanced = audienceStages.includes(STAGE.CORE) ? [STAGE.CORE] : [STAGE.ADVANCED];
const defaultStage = (audienceStages.includes(STAGE.CORE) && audienceStages.includes(STAGE.ADVANCED)) ? [STAGE.CORE, STAGE.ADVANCED] : coreOrAdvanced;
const adaStages = [STAGE.CORE, STAGE.ADVANCED, STAGE.POST_18];
const adaAudienceStages = audienceStages.filter(s => adaStages.includes(s as STAGE));

stagesToView = userContext.hasDefaultPreferences || !intendedAudience
? defaultStage
? adaAudienceStages
: stagesFilteredByUserContext.length > 0
? stagesFilteredByUserContext
// only show Core and Advanced intentionally
: audienceStages.filter(s => ![STAGE.CORE, STAGE.ADVANCED].includes(s as STAGE));
// only show Ada exam board stages intentionally
: audienceStages.filter(s => !adaStages.includes(s as STAGE));

const result = stagesToView.reduce((acc, label) => {
if ([STAGE.GCSE, STAGE.A_LEVEL].includes(label as STAGE)) {
Expand All @@ -524,7 +526,7 @@ export function stringifyAudience(audience: ContentDTO["audience"], userContext:
acc[1].push(label);
} else if ([STAGE.SCOTLAND_ADVANCED_HIGHER].includes(label as STAGE)) {
acc[2].push(label);
} else if ([STAGE.CORE, STAGE.ADVANCED].includes(label as STAGE)) {
} else if (adaStages.includes(label as STAGE)) {
acc[3].push(label);
}
return acc;
Expand Down
3 changes: 3 additions & 0 deletions src/mocks/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4929,6 +4929,9 @@ export const mockConceptPage =
"id": "_mock_accordion_",
"audience": [
{
"examBoard": [
"aqa"
],
"stage": [
"a_level"
]
Expand Down
5 changes: 5 additions & 0 deletions src/test/pages/Concept.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import React from "react";
import { Concept } from "../../app/components/pages/Concept";
import { isAda } from "../../app/services";

it('Concept pages should have no visual regressions', () => {

// @ts-ignore
cy.mountWithStoreAndRouter(<Concept conceptIdOverride="_mock_concept_page_"/>, ["/concepts/_mock_concept_page_"]);

if (isAda) {
cy.get('select[id="uc-exam-board-select"]').select('All Exam Boards');
}

cy.get('[data-testid="loading"]').should('not.exist');

// open accordion
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably this Advanced context label shouldn't have even shown up in the first place, since "advanced" wasn't a labelled stage for the accordion section (and it's a content problem if "core" or "advanced" is not present, which it is in the vast majority of cases according to my searching).

That said, I think we should be testing this stage-label anyway. Could we either change the mock data so that it does include "advanced", or perhaps switch to "All exam boards" in the context switcher?

Copy link
Contributor Author

@axlewin axlewin Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, and agreed; I can't see why we should ever default to "advanced", but it would be nice to still test the labels somehow. I'll add "advanced" to the mock data.

(Edit: Changed to your second suggestion ("all exam boards") instead, to avoid needing separate mock contexts for each site)

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.