Skip to content

Commit a9cca52

Browse files
committed
Merge branch 'master' of https://github.com/source-academy/frontend into HEAD
2 parents 9d51e95 + c7d6078 commit a9cca52

File tree

103 files changed

+7229
-11067
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+7229
-11067
lines changed

.github/workflows/build-development.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ on:
33
push:
44
branches:
55
- master
6+
workflow_dispatch:
7+
inputs:
8+
ref:
9+
description: Branch/Tag/SHA to checkout
10+
required: true
11+
default: master
612

713
jobs:
814
deploy:
@@ -11,6 +17,8 @@ jobs:
1117
steps:
1218
- name: Checkout repository
1319
uses: actions/checkout@v4
20+
with:
21+
ref: ${{ github.event.inputs.ref }}
1422
# Has to be run before actions/setup-node.
1523
# See: https://github.com/actions/setup-node/issues/480
1624
- name: Enable corepack for Yarn

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ env:
1515
concurrency:
1616
group: ${{ github.workflow }}-${{ github.ref }}
1717
cancel-in-progress: true
18-
18+
1919
jobs:
2020
lint:
2121
if: github.event.pull_request.draft == false

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ To start contributing, create a fork from our repo and send a PR. Refer to [this
1616

1717
The frontend comes with an extensive test suite. To run the tests after you made your modifications, run
1818
`yarn test`. Regression tests are run automatically when you want to push changes to this repository.
19-
The regression tests are generated using `jest` and stored as snapshots in `src/\_\_tests\_\_`. After modifying the frontend, carefully inspect any failing regression tests reported in red in the command line. If you are convinced that the regression tests and not your changes are at fault, you can update the regression tests by running:
19+
The regression tests are generated using `jest` and stored as snapshots in `src/\_\_tests\_\_`. After modifying the frontend, carefully inspect any failing regression tests reported in red in the command line. If you are convinced that the regression tests and not your changes are at fault, you can update the regression tests by running:
2020

2121
```bash
2222
yarn test --updateSnapshot

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The Source Academy (<https://sourceacademy.org/>) is an immersive online experie
2424

2525
1. Clone this repository and navigate to it using your command line
2626

27-
1. Install the version of `yarn` as specified in `package.json`, `packageManager`.
27+
1. Install the version of `yarn` as specified in `package.json`, `packageManager`.
2828

2929
> We recommend using `corepack` to manage the version of `yarn`, you may simply run `corepack enable` to complete this step.
3030

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
theme: jekyll-theme-cayman
1+
theme: jekyll-theme-cayman

craco.config.js

Lines changed: 0 additions & 182 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { config, configs } from 'typescript-eslint';
55
import reactPlugin from 'eslint-plugin-react';
66
import reactHooksPlugin from 'eslint-plugin-react-hooks';
7-
import simpleImportSort from 'eslint-plugin-simple-import-sort'
7+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
88
// import reactRefresh from 'eslint-plugin-react-refresh';
99

1010
export default config(
@@ -24,7 +24,7 @@ export default config(
2424
files: ['**/*.ts*'],
2525
plugins: {
2626
'react-hooks': reactHooksPlugin,
27-
'react': reactPlugin,
27+
react: reactPlugin,
2828
'simple-import-sort': simpleImportSort
2929
},
3030
rules: {

jest.config.js

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// @ts-check
2+
3+
const ignoreModulePaths = (...paths) => {
4+
const moduleRoot = replaceSlashes('/node_modules/');
5+
const modulePaths = paths
6+
.map(replaceSlashes)
7+
.map(path => `(${path}[/\\\\.*])`)
8+
.join('|');
9+
return moduleRoot + '(?!' + modulePaths + ').*.(js|jsx|ts|tsx)$';
10+
};
11+
const replaceSlashes = target => {
12+
return target.replaceAll('/', '[/\\\\]');
13+
};
14+
15+
/** @type {import('jest').Config} */
16+
export default {
17+
moduleDirectories: ['<rootDir>', 'node_modules'],
18+
testEnvironment: './jsdom-env.js',
19+
transform: {
20+
'^.+\\.(t|j)sx?$': [
21+
'@swc/jest',
22+
{
23+
sourceMaps: true,
24+
jsc: {
25+
parser: {
26+
syntax: 'typescript',
27+
tsx: true,
28+
decorators: false,
29+
dynamicImport: false
30+
},
31+
baseUrl: '.',
32+
transform: {
33+
react: {
34+
runtime: 'automatic'
35+
}
36+
}
37+
}
38+
}
39+
]
40+
},
41+
transformIgnorePatterns: [
42+
// Will give something like
43+
// '[/\\\\]node_modules[/\\\\]
44+
// (?!
45+
// ( @ion-phaser[/\\\\]react[/\\\\.*] )|
46+
// ( js-slang[/\\\\.*] )|
47+
// ( array-move[/\\\\.*] )|
48+
// ...
49+
// ( comma-separated-tokens[/\\\\.*] )
50+
// ).*.(js|jsx|ts|tsx)$'
51+
ignoreModulePaths(
52+
'@ion-phaser/react',
53+
'js-slang',
54+
'array-move',
55+
'konva',
56+
'react-konva',
57+
'react-debounce-render',
58+
'devlop',
59+
'hastscript',
60+
'hast-to-hyperscript',
61+
'hast-util-.+',
62+
'mdast-util-.+',
63+
'micromark',
64+
'micromark-.+',
65+
'vfile',
66+
'vfile-message',
67+
'unist-util-.+',
68+
'web-namespaces',
69+
'rehype-react',
70+
'unified',
71+
'bail',
72+
'is-plain-obj',
73+
'trough',
74+
'decode-named-character-reference',
75+
'character-entities',
76+
'trim-lines',
77+
'property-information',
78+
'space-separated-tokens',
79+
'comma-separated-tokens',
80+
'query-string',
81+
'decode-uri-component',
82+
'split-on-first',
83+
'filter-obj',
84+
'@sourceacademy/c-slang',
85+
'java-parser',
86+
'conductor'
87+
),
88+
'^.+\\.module\\.(css|sass|scss)$'
89+
],
90+
moduleNameMapper: {
91+
'\\.(jpg|jpeg)$': '<rootDir>/src/fileMock.ts',
92+
'\\.svg$': 'identity-obj-proxy',
93+
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
94+
'unist-util-visit-parents/do-not-use-color':
95+
'<rootDir>/node_modules/unist-util-visit-parents/lib',
96+
'vfile/do-not-use-conditional-minpath': '<rootDir>/node_modules/vfile/lib',
97+
'vfile/do-not-use-conditional-minproc': '<rootDir>/node_modules/vfile/lib',
98+
'vfile/do-not-use-conditional-minurl': '<rootDir>/node_modules/vfile/lib'
99+
},
100+
setupFilesAfterEnv: [
101+
'./src/setupTests.ts', // Setup file for Jest
102+
'./src/i18n/i18n.ts' // Setup i18next configuration
103+
]
104+
};

jsdom-env.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import JSDOMEnvironment from 'jest-environment-jsdom';
2+
3+
// https://stackoverflow.com/a/78051351
4+
export default class FixJSDOMEnvironment extends JSDOMEnvironment {
5+
constructor(...args) {
6+
super(...args);
7+
this.global.fetch = fetch;
8+
this.global.Request = Request;
9+
this.global.Response = Response;
10+
// And any other missing globals
11+
}
12+
}

0 commit comments

Comments
 (0)