Skip to content

Conversation

@belanglos
Copy link
Contributor

@belanglos belanglos commented Nov 4, 2025

📌 Summary

This has to be merged after #370

Adds possibility to filter by KTH Periods to course search.

When visiting the page in spring, this years KTHPeriods and next years spring KTHPeriods should be available as filters.
When visiting the page in autumn, this years Autumn KTHPeriods and next years KTHPeriods should be available as filters.

Fixes https://kth-se.atlassian.net/browse/KP-433


🔍 Changes

  • updated code to use updated Search.searchCourseInstances endpoint from @kth/om-kursen-ladok-client
  • extracted functions into /shared to get TS help
  • added testing-library/user-event which is the preferred way to test UIs (as opposed to fireEvent)
  • removed deprecated defaultProps
  • renames ListView to StandardView in code
  • fixes layout in Search Table/Compact view
  • iterated on build and DX after ts-shared
  • minor typing improvements

✅ Checklist (Author)

  • Code builds locally without errors
  • Tests added/updated and passing
  • Linting/formatting applied
  • No sensitive data in the diff
  • No stray console.logs in the diff
  • No stray comments in the diff
  • Docs/README/CHANGELOG updated (if needed) (not applicable)
  • Sufficient logging
  • Errors are handled accordingly

🧪 Testing & Verification

  1. Added unit tests for SearchFilters, which test which filters are displayed in spring and autumn. It also tests that clicking the filters calls the expected functions
  2. Tested locally against new updated om-kursen-ladok-client

⚠️ Impact / Risks


🚧 Out of Scope

We could benefit from integration tests at this level.
Also, we do not have working cypress-E2E-tests for course search.


Copilot Summary

This pull request introduces several improvements and refactorings across the codebase, focusing on simplifying prop handling in React components, updating search parameter logic, enhancing internationalization, and improving development tooling. The most significant changes are grouped below.

Refactoring and Simplification of React Component Props

  • Removed unnecessary defaultProps assignments for Alert, Article, KoppsData, and LadokData components, instead setting default values directly in function parameters. This streamlines component definitions and reduces boilerplate. [1] [2] [3] [4] [5] [6] [7] [8]
  • Updated SearchDepartmentsProps to use the correct type for departmentCode, improving type safety.

Search Parameter Logic and Test Improvements

  • Refactored domain/searchParams.js to simplify period handling, remove unused functions, and utilize shared utilities for period configuration. This makes the search logic more maintainable and consistent. [1] [2]
  • Updated SearchFilters.test.tsx to use the correct types, improve test clarity, and switch to user-event for more realistic user interaction simulation. [1] [2] [3] [4] [5]

Internationalization Updates

  • Changed toggle button labels from list to standard in both English and Swedish message files to ensure consistency in UI terminology. [1] [2]

Development Tooling Enhancements

  • Updated the dev:shared script to clean the build directory before compiling TypeScript, preventing stale artifacts.
  • Added @testing-library/user-event as a dependency to support improved testing practices.

Cleanup

  • Removed completed and outdated items from the SearchTodos.MD file, keeping documentation current.

@belanglos belanglos requested a review from Copilot November 4, 2025 09:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the course search functionality to improve period/semester handling by:

  • Replacing semester-based search parameters (semesters: ['HT2024', 'VT2024']) with KTH period-based parameters (period: ['2024:P1', '2024:summer'])
  • Moving shared search logic from JavaScript to TypeScript in the shared/ directory
  • Consolidating type definitions and removing duplicated code
  • Updating the webpack configuration to disable TypeScript project references to prevent build errors
  • Modernizing React components by replacing defaultProps with default parameter values

Reviewed Changes

Copilot reviewed 57 out of 61 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
webpack.config.js Disables TypeScript project references in webpack to prevent TS6307 errors
tsconfig.json Adds project references configuration for shared and public directories
shared/searchPageCtrlUtils.ts New file containing TypeScript implementation of course search logic
shared/periodSearchUtils.ts Refactored period configuration logic with new convertSummerToPeriods function
shared/periods.ts Removes unused getSummerPeriodsList function
shared/languageUtil.ts New shared language utility functions and types
shared/SearchTypes.ts New shared TypeScript types for search responses
server/controllers/searchPageCtrl.js Delegates to TypeScript implementation in shared directory
public/js/app/util/searchHelper.ts Updates period display logic to use new KTH period data structures
public/js/app/pages/types/searchPageTypes.ts Replaces semesters with period parameter and converts SEARCH_MODES to enum
domain/searchParams.js Removes period transformation logic, delegates to shared TypeScript implementation
Various test files Updates tests to use new period format (2024:P1 instead of HT2024)
Various component files Replaces defaultProps with default parameter values per React best practices
Comments suppressed due to low confidence (3)

shared/periodSearchUtils.ts:1

  • Corrected spelling of 'periodSearchutils' to 'periodSearchUtils' to match the file name.
    domain/searchParams.js:136
  • Superfluous argument passed to function _periodConfigByYearType.
      return _periodConfigByYearType('currentYear', langIndex, true)

domain/searchParams.js:138

      return _periodConfigByYearType('nextYear', langIndex, true)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI commented Nov 4, 2025

@belanglos I've opened a new pull request, #372, to work on those changes. Once the pull request is ready, I'll request review from you.

@belanglos belanglos force-pushed the issues/KP-433-implement-periods-without-shared branch 2 times, most recently from c7ccca1 to 51442a4 Compare November 4, 2025 09:42
@belanglos belanglos requested a review from Copilot November 4, 2025 09:43
@belanglos belanglos changed the title test(KP-430): fix third cycle TableView test KP-433: add KTHPeriods to course search filter Nov 4, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 57 out of 61 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (3)

public/js/app/pages/types/searchPageTypes.ts:1

  • The Period type definition is incorrect. It only allows 'P' followed by '1' | '2' | '3' | '4' | 'summer', but the actual period values used throughout the code include 'P0' and 'P5' (e.g., in tests and convertSummerToPeriods function). The type should be ${number}:P${'0' | '1' | '2' | '3' | '4' | '5'} or ${number}:${'summer' | \P${0 | 1 | 2 | 3 | 4 | 5}`}`.
    domain/searchParams.js:136
  • Superfluous argument passed to function _periodConfigByYearType.
      return _periodConfigByYearType('currentYear', langIndex, true)

domain/searchParams.js:138

      return _periodConfigByYearType('nextYear', langIndex, true)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@belanglos belanglos force-pushed the issues/KP-433-implement-periods-without-shared branch from 5a6e2b2 to 322e94d Compare November 4, 2025 10:47
@belanglos belanglos requested a review from Copilot November 4, 2025 10:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 57 out of 61 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (2)

domain/searchParams.js:136

      return _periodConfigByYearType('currentYear', langIndex, true)

domain/searchParams.js:138

      return _periodConfigByYearType('nextYear', langIndex, true)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@belanglos belanglos force-pushed the issues/KP-433-implement-periods-without-shared branch from efab51b to 6e9f229 Compare November 4, 2025 10:59
@belanglos belanglos requested a review from Copilot November 4, 2025 10:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 57 out of 61 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (3)

public/js/app/components-shared/Alert.jsx:1

  • The type prop is marked as isRequired in PropTypes but has a default value of 'info' in the function signature. Remove .isRequired to align with the default parameter behavior.
// https://intra.kth.se/style/en/components/alert

domain/searchParams.js:136

      return _periodConfigByYearType('currentYear', langIndex, true)

domain/searchParams.js:138

      return _periodConfigByYearType('nextYear', langIndex, true)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@belanglos belanglos force-pushed the issues/KP-433-implement-periods-without-shared branch from 6e9f229 to 2e5762a Compare November 4, 2025 11:10
@belanglos belanglos marked this pull request as ready for review November 4, 2025 11:14
Copy link
Contributor

@axelbjo axelbjo left a comment

Choose a reason for hiding this comment

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

So much work done here, really nice job! I like the refactoring and general restructuring of things throughout the repo. Nice to see more TS introduced too.

Tested the application locally and ran the tests as well, no problems there. Great job Benni!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants