Skip to content

Commit

Permalink
feat: departures multi-section auto-sizing
Browse files Browse the repository at this point in the history
* Update departures widget generation to pass layout parameters from
  configuration to the frontend.

* Replace existing auto-sizing implementation, which only worked for a
  single section, with a version that handles multiple sections using
  the layout parameters.

* The auto-sizing itself (independent of the React component) is
  unit-tested. These are the first real frontend tests in Screens, so
  we take the opportunity to:

  * Update Jest to its latest version.

  * Replace the third-party `@types/jest` package with a direct
    dependency on `@jest/globals`, which is already part of Jest. The
    only advantage of the former is that it allows using `describe`,
    `test`, etc. without importing them.

  * Add `eslint-plugin-jest` to our ESLint setup.

  * Add `fishery` for defining factories to build test data.
  • Loading branch information
digitalcora committed May 20, 2024
1 parent e00c977 commit 6593dd0
Show file tree
Hide file tree
Showing 23 changed files with 8,353 additions and 16,847 deletions.
1 change: 1 addition & 0 deletions assets/css/bus_eink_v2.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@import "v2/eink/link_footer";
@import "v2/eink/fare_info_footer";
@import "v2/eink/free_text";
@import "v2/eink/departures";
@import "v2/eink/departures/alert";
@import "v2/eink/no_data";
@import "v2/eink/page_load_no_data";
Expand Down
1 change: 1 addition & 0 deletions assets/css/gl_eink_v2.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@import "v2/eink/departures_no_data";
@import "v2/eink/subway_status";

@import "v2/eink/departures";
@import "v2/eink/departures/overnight";
@import "v2/eink/no_data";
@import "v2/eink/page_load_no_data";
Expand Down
3 changes: 3 additions & 0 deletions assets/css/v2/eink/departures.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.departures-container {
height: 100%;
}
5 changes: 5 additions & 0 deletions assets/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginReactConfig from "eslint-plugin-react/configs/recommended.js";
import eslintConfigPrettier from "eslint-config-prettier";
import jestPlugin from "eslint-plugin-jest";

export default [
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReactConfig,
eslintConfigPrettier,
{
files: ["test/**"],
...jestPlugin.configs["flat/style"],
},
{
settings: { react: { version: "detect" } },
rules: {
Expand Down
18 changes: 18 additions & 0 deletions assets/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// https://jestjs.io/docs/configuration

/* eslint-disable @typescript-eslint/no-var-requires */
/* global require, module */

const requireJSON5 = require("require-json5");
const { pathsToModuleNameMapper } = require("ts-jest");
const { compilerOptions } = requireJSON5("./tsconfig");

/** @type {import('jest').Config} */
module.exports = {
preset: "ts-jest",
errorOnDeprecated: true,
resetMocks: true,
roots: ["<rootDir>"],
modulePaths: [compilerOptions.baseUrl],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths),
};
Loading

0 comments on commit 6593dd0

Please sign in to comment.