Skip to content

Commit debd302

Browse files
authored
Merge branch 'master' into lesson-groups
2 parents e0d9ba3 + 3f774f3 commit debd302

63 files changed

Lines changed: 4476 additions & 1964 deletions

Some content is hidden

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

MAINTENANCE.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,19 @@ Reference PRs: [PR #3286](https://github.com/nusmodifications/nusmods/pull/3286)
4040

4141
- Before
4242
- [ ] Update `TERM` in `scrapers/cpex-scraper/src/index.ts` and `MPE_SEMESTER` in `website/src/views/mpe/constants.ts` to be the semester you're configuring CPEx for (usually the next semester)
43-
- [ ] Update the displayed dates in `website/src/views/mpe/MpeContainer.tsx` and any new requirements/descriptions
43+
- [ ] ~~Update the displayed dates in `website/src/views/mpe/MpeContainer.tsx` and any new requirements/descriptions~~ Auto-updated using dates in modreg-schedule.json
4444
- [ ] Update dates in the ModReg schedule in `website/src/data/modreg-schedule.json`
4545
- [ ] Enable the `enableCPExforProd` and `showCPExTab` flags in `website/src/featureFlags.ts`
4646
- [ ] Push onto `cpex-staging` branch (Ensure synced with `master` branch first), then visit https://cpex-staging.nusmods.com/cpex and verify that NUS authentication is working
47+
48+
```bash
49+
git checkout master
50+
git pull
51+
git switch cpex-staging
52+
git reset --hard master
53+
git push
54+
```
55+
4756
- During
4857
- [ ] Merge `cpex-staging` into `master`
4958
- [ ] Deploy latest `master` to `production`

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ All projects and packages in this repository are [MIT licensed](LICENSE).
6969

7070
[<img src="misc/1password-logo.png" width="200" />](1password)
7171

72-
[Netlify](netlify) automatically deploys our branches so we can easily test incoming Pull Requests.
72+
[Vercel](vercel) hosts our website, and automatically deploys our branches so we can easily test incoming Pull Requests.
7373

74-
[<img src="misc/netlify-logo.png" width="190" />](netlify)
74+
[<img src="misc/vercel-logo.png" width="200" />](vercel)
7575

7676
[browserstack]: https://www.browserstack.com/
7777
[1password]: https://1password.com/
78-
[netlify]: https://www.netlify.com
78+
[vercel]: https://vercel.com/

misc/netlify-logo.png

-13.5 KB
Binary file not shown.

misc/vercel-logo.png

35.1 KB
Loading

scrapers/cpex-scraper/src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import path from 'path';
44

55
import env from '../env.json';
66

7-
const TERM = '2510';
7+
const TERM = '2520';
88

99
// Sanity check to see if there are at least this many modules before overwriting cpexModules.json
1010
// The last time I ran this fully there were 3418 modules
@@ -86,8 +86,7 @@ async function scraper() {
8686
const department = departmentsData[i];
8787

8888
console.log(
89-
`[${i + 1}/${departmentsData.length}] Fetching modules for ${
90-
department.Description
89+
`[${i + 1}/${departmentsData.length}] Fetching modules for ${department.Description
9190
} with acadorg: ${department.AcademicOrganisation}...`,
9291
);
9392

website/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ If a community libdef is not available, you can try writing your own and placing
267267

268268
### Testing and Linting
269269

270-
We use [Jest][jest] with [Enzyme][enzyme] to test our code and React components, [TypeScript][ts] for typechecking, [Stylelint][stylelint] and [ESLint][eslint] using [Airbnb config][eslint-airbnb] and [Prettier][prettier] for linting and formatting.
270+
We use [Jest][jest] with [Enzyme][enzyme] and [Testing Library][testing-library] to test our code and React components, [TypeScript][ts] for typechecking, [Stylelint][stylelint] and [ESLint][eslint] using [Airbnb config][eslint-airbnb] and [Prettier][prettier] for linting and formatting.
271+
272+
**Note: The majority of React tests are written with Enzyme. For new unit tests, please try to use [Testing Library][testing-library] instead!**
271273

272274
```sh
273275
# Run all tests once with code coverage
@@ -295,7 +297,7 @@ $ yarn typecheck
295297

296298
We currently have some simple E2E tests set up courtesy of Browserstack using Nightwatch. The purpose of this is mainly to catch major regression in browsers at the older end of our browser support matrix (iOS 11, Safari 11, Edge, Firefox ESR) which can be difficult to test manually.
297299

298-
By default the tests are ran against http://staging.nusmods.com, although they can be configured to run against any host, including localhost if you use [Browserstack's local testing feature](https://www.browserstack.com/local-testing#command-line).
300+
By default the tests are ran against http://latest.nusmods.com, although they can be configured to run against any host, including localhost if you use [Browserstack's local testing feature](https://www.browserstack.com/docs/automate/javascript-testing/local-testing).
299301

300302
```sh
301303
# All commands must include BROWSERSTACK_USER and BROWSERSTACK_ACCESS_KEY env variables
@@ -305,7 +307,7 @@ By default the tests are ran against http://staging.nusmods.com, although they c
305307
yarn e2e
306308

307309
# Run against deploy preview
308-
LAUNCH_URL="https://deploy-preview-1024--nusmods.netlify.com" yarn e2e
310+
LAUNCH_URL="https://nusmods-website-example-modsbots-projects.vercel.app" yarn e2e
309311

310312
# Run against local development server
311313
yarn start # Start a local development server
@@ -404,6 +406,7 @@ Components should keep their styles and tests in the same directory with the sam
404406
[bootstrap]: https://getbootstrap.com/
405407
[jest]: https://facebook.github.io/jest/
406408
[enzyme]: http://airbnb.io/enzyme/
409+
[testing-library]: https://testing-library.com/docs/react-testing-library/intro/
407410
[ts]: https://www.typescriptlang.org/
408411
[eslint]: https://eslint.org/
409412
[svgr]: https://github.com/smooth-code/svgr

website/api/nus/auth/login.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ const handlePost: Handler = async (req, res) => {
2626

2727
res.redirect(301, userURL.toString());
2828
} catch (err) {
29-
if (err.message === errors.noRelayState) {
29+
if ((err as unknown as Error).message === errors.noRelayState) {
3030
res.json({
3131
message: 'Relay state not found in request',
3232
});
33-
} else if (err.message === errors.invalidRelayState) {
33+
} else if ((err as unknown as Error).message === errors.invalidRelayState) {
3434
res.json({
3535
message: 'Invalid relay state given. URL must be from a valid domain.',
3636
});

website/api/nus/auth/sso.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ const handleGet: Handler = async (req, res) => {
3131

3232
res.send(createLoginURL(callback));
3333
} catch (err) {
34-
if (err.message === errors.noCallbackUrl) {
34+
if ((err as unknown as Error).message === errors.noCallbackUrl) {
3535
res.json({
3636
message: 'Request needs a referer',
3737
});
38-
} else if (err.message === errors.invalidCallbackUrl) {
38+
} else if ((err as unknown as Error).message === errors.invalidCallbackUrl) {
3939
res.json({
4040
message: 'Invalid referer given. URL must be from a valid domain.',
4141
});

website/api/nus/mpe/submissions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const handleGet: Handler = async (req, res) => {
2424
}));
2525
res.json(existingSubmission);
2626
} catch (err) {
27-
if (err.response.status === 404) {
27+
if ((err as any).response.status === 404) {
2828
res.json(<MpeSubmission>{
2929
intendedMCs: 0,
3030
preferences: [],

website/nightwatch.conf.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,26 @@ const config = {
33
page_objects_path: 'src/e2e/page-objects',
44
output_folder: 'reports/junit/e2e',
55

6-
selenium: {
6+
webdriver: {
77
start_process: false,
88
host: 'hub-cloud.browserstack.com',
9-
port: 80,
9+
port: 443,
10+
ssl: true,
1011
},
1112

1213
test_settings: {
1314
default: {
14-
launch_url: process.env.LAUNCH_URL || 'http://staging.nusmods.com',
15-
desiredCapabilities: {
16-
'browserstack.user': process.env.BROWSERSTACK_USER,
17-
'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY,
18-
'browserstack.debug': true,
19-
'browserstack.console': 'errors',
15+
launch_url: process.env.LAUNCH_URL || 'http://latest.nusmods.com',
2016

21-
browser: 'Firefox',
17+
desiredCapabilities: {
18+
'bstack:options': {
19+
userName: process.env.BROWSERSTACK_USER,
20+
accessKey: process.env.BROWSERSTACK_ACCESS_KEY,
21+
debug: true,
22+
consoleLogs: 'errors'
23+
},
24+
25+
browserName: 'Firefox',
2226
// Latest ESR
2327
browserVersion: '78',
2428
},
@@ -35,26 +39,20 @@ const config = {
3539
safariDesktop: {
3640
desiredCapabilities: {
3741
os: 'OS X',
38-
browser: 'Safari',
42+
browserName: 'Safari',
3943
browserVersion: '11.1',
4044
},
4145
},
4246

4347
edge: {
44-
browser: 'Edge',
48+
browserName: 'Edge',
4549
browserVersion: '18.0',
4650
},
4751
},
4852
};
4953

50-
// Copy seleniumhost/port into test settings
51-
Object.values(config.test_settings).forEach((setting) => {
52-
setting.selenium_host = config.selenium.host;
53-
setting.selenium_port = config.selenium.port;
54-
});
55-
5654
if (process.env.LOCAL_TEST) {
57-
config.test_settings.default.desiredCapabilities['browserstack.local'] = true;
55+
config.test_settings.default.desiredCapabilities['bstack:options']['local'] = true;
5856
}
5957

6058
module.exports = config;

0 commit comments

Comments
 (0)