Skip to content

Commit

Permalink
Revert renaming of levels const (will fix later)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswilty committed Apr 25, 2024
1 parent 50df906 commit 3917a97
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@testing-library/react';
import { describe, expect, test, vi } from 'vitest';

import { Levels } from '@src/levels';
import { LEVELS } from '@src/levels';
import { LEVEL_NAMES } from '@src/models/level';

import LevelMissionInfoBanner from './LevelMissionInfoBanner';
Expand All @@ -23,7 +23,7 @@ describe('LevelMissionInfoBanner component tests', () => {
/>
);

const expectedContent = Levels[currentLevel].missionInfoShort;
const expectedContent = LEVELS[currentLevel].missionInfoShort;

if (!expectedContent)
throw new Error(`No missionInfoShort found for level ${currentLevel}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ThemedButton from '@src/components/ThemedButtons/ThemedButton';
import { Levels } from '@src/levels';
import { LEVELS } from '@src/levels';
import { LEVEL_NAMES } from '@src/models/level';

import './LevelMissionInfoBanner.css';
Expand All @@ -23,7 +23,7 @@ function LevelMissionInfoBanner({
<h2 className="level-title-area">{`Level ${currentLevel + 1}`}</h2>
<p
dangerouslySetInnerHTML={{
__html: Levels[currentLevel].missionInfoShort ?? '',
__html: LEVELS[currentLevel].missionInfoShort ?? '',
}}
></p>
<div className="banner-button-container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { render, screen } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import { describe, expect, test, vi } from 'vitest';

import { Levels } from '@src/levels';
import { LEVELS } from '@src/levels';
import { LEVEL_NAMES } from '@src/models/level';

import LevelSelectionBox, { LevelSelectionBoxProps } from './LevelSelectionBox';

const defaultProps: LevelSelectionBoxProps = {
currentLevel: Levels[0].id,
currentLevel: LEVELS[0].id,
numCompletedLevels: 0,
setCurrentLevel: () => {},
};
Expand All @@ -19,7 +19,7 @@ function renderComponent(props: LevelSelectionBoxProps = defaultProps) {
return { user };
}

const levels = Levels.map(({ id, name }) => ({
const levels = LEVELS.map(({ id, name }) => ({
id,
name: id === LEVEL_NAMES.SANDBOX ? name : `Level ${id + 1}`,
}));
Expand Down Expand Up @@ -50,7 +50,7 @@ describe('LevelSelectionBox component tests', () => {

test('renders buttons disabled ahead of highest level completed, except for sandbox', () => {
const numCompletedLevels = 1;
const currentLevel = Levels[numCompletedLevels];
const currentLevel = LEVELS[numCompletedLevels];
const setCurrentLevel = vi.fn();

renderComponent({
Expand All @@ -70,7 +70,7 @@ describe('LevelSelectionBox component tests', () => {

test('clicking aria-disabled button does not trigger level change', async () => {
const numCompletedLevels = 0;
const currentLevel = Levels[numCompletedLevels];
const currentLevel = LEVELS[numCompletedLevels];
const setCurrentLevel = vi.fn();

const { user } = renderComponent({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { clsx } from 'clsx';

import ThemedButton from '@src/components/ThemedButtons/ThemedButton';
import { Levels } from '@src/levels';
import { LEVELS } from '@src/levels';
import { LEVEL_NAMES } from '@src/models/level';

import './LevelSelectionBox.css';
Expand All @@ -17,7 +17,7 @@ function LevelSelectionBox({
numCompletedLevels,
setCurrentLevel,
}: LevelSelectionBoxProps) {
const displayLevels = Levels.map(({ id, name }) => ({
const displayLevels = LEVELS.map(({ id, name }) => ({
id,
displayName: id === LEVEL_NAMES.SANDBOX ? name : `${id + 1}`,
}));
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/Overlay/MissionInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Handler from '@src/assets/images/handler.png';
import Lawyer from '@src/assets/images/lawyer.png';
import Manager from '@src/assets/images/manager.png';
import OverlayButton from '@src/components/ThemedButtons/OverlayButton';
import { Levels } from '@src/levels';
import { LEVELS } from '@src/levels';
import { LEVEL_NAMES } from '@src/models/level';

import MultipageOverlay from './MultipageOverlay';
Expand All @@ -14,9 +14,9 @@ function MissionInformation({
currentLevel: LEVEL_NAMES;
closeOverlay: () => void;
}) {
const heading = `${Levels[currentLevel].name} Mission Info`;
const heading = `${LEVELS[currentLevel].name} Mission Info`;

const pages = Levels[currentLevel].missionInfoDialogue.map(
const pages = LEVELS[currentLevel].missionInfoDialogue.map(
({ speaker, text }, index, source) => {
return {
content: (
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/levels.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Level, LEVEL_NAMES } from './models/level';

const Levels: Level[] = [
const LEVELS: Level[] = [
{
id: LEVEL_NAMES.LEVEL_1,
name: 'Level 1',
Expand Down Expand Up @@ -93,4 +93,4 @@ const Levels: Level[] = [
},
];

export { Levels };
export { LEVELS };

0 comments on commit 3917a97

Please sign in to comment.