#752-implement-automatically-cards-update #827

Merged
a22erigr merged 28 commits from #752-implement-automatically-cards-update into team_2_week_5 2026-05-12 10:55:11 +00:00
Collaborator

Implementing automatically update functionality for some views and adding associated tests

Environment

This was developed on an Arch-based Linux distribution and tested using Jest.

What has been done?

Config

Created the file frontend/src/configs/pollFrequencyConfig.js as the configuration file for each view's "refresh" interval.
The "refresh" time is the interval between API calls a component makes to self-update its content.

Views

In the following views:

  • TemperatureGraphView
  • TemperatureAllView
  • TemperatureWeekView
  • SMHIForecastView
  • SMHIForecastView
  • SMHITemperatureView
  • ParkingView
  • BookingView
  • ScheduleView

The following features were added:

  • Using useEffect, setInterval, and useState, each of the described views now self-updates based on the configured time interval by using the use* hooks
  • Basic tests have been added to each view

Tests

This section represents the bulk of the work done. The test structure is the same in all implemented tests.
Each test file contains two groups of tests. The first group covers general state testing, serving as a simple foundation for future developers to modify, expand, or remove as needed.
The second group consists of basic tests for the polling (refresh) functionality.

Because the test files follow a standardized pattern, they are practically identical in both structure and content.

General state tests

This group follows the same pattern across all test files:

  1. shows a loading state while data is loading: Ensures that the loading indicator is displayed when triggered by the API.
  2. shows an error state when the request fails: Ensures that errors are properly displayed when they occur.
  3. renders the data when the request succeeds: Verifies that the data is correctly rendered when provided.

Polling tests

Similarly, this group follows a standardized pattern:

  1. re-fetches at the configured interval: Tests that the component doesn't crash or throw when polling multiple times at the configured intervals. Note: These tests utilize Jest's fake timers, so they execute instantly rather than waiting in real-time.
  2. reflects updated data after a poll: Verifies that the UI visually updates after a poll. This is achieved by setting an initial mock value, simulating a time skip, providing a new mock value, and inspecting the DOM for changes.
  3. cleans up the interval on unmount: Ensures the component clears its timer upon unmounting, preventing memory leaks or background errors.

Currently, all tests would be considered the "happy path," meaning they only verify the best-case scenario and do not test for bad inputs/outputs. Adding "bad path" (edge case) tests would be highly advisable, but since it falls outside the scope of this PR and issue, it is left for future development.

Issue:

General: #752
The times each should refresh: #742
Inspiration from #702

# Implementing automatically update functionality for some views and adding associated tests ## Environment This was developed on an Arch-based Linux distribution and tested using Jest. ## What has been done? ### Config Created the file **frontend/src/configs/pollFrequencyConfig.js** as the configuration file for each view's "refresh" interval. The "refresh" time is the interval between API calls a component makes to self-update its content. ### Views In the following views: * TemperatureGraphView * TemperatureAllView * TemperatureWeekView * SMHIForecastView * SMHIForecastView * SMHITemperatureView * ParkingView * BookingView * ScheduleView The following features were added: * Using _useEffect_, _setInterval_, and _useState_, each of the described views now self-updates based on the configured time interval by using the use* hooks * Basic tests have been added to each view ### Tests This section represents the bulk of the work done. The test structure is the same in all implemented tests. Each test file contains two groups of tests. The first group covers general state testing, serving as a simple foundation for future developers to modify, expand, or remove as needed. The second group consists of basic tests for the polling (refresh) functionality. Because the test files follow a standardized pattern, they are practically identical in both structure and content. #### General state tests This group follows the same pattern across all test files: 1. **shows a loading state while data is loading**: Ensures that the loading indicator is displayed when triggered by the API. 2. **shows an error state when the request fails**: Ensures that errors are properly displayed when they occur. 3. **renders the data when the request succeeds**: Verifies that the data is correctly rendered when provided. #### Polling tests Similarly, this group follows a standardized pattern: 1. **re-fetches at the configured interval**: Tests that the component doesn't crash or throw when polling multiple times at the configured intervals. **Note**: These tests utilize Jest's fake timers, so they execute instantly rather than waiting in real-time. 2. **reflects updated data after a poll**: Verifies that the UI visually updates after a poll. This is achieved by setting an initial mock value, simulating a time skip, providing a new mock value, and inspecting the DOM for changes. 3. **cleans up the interval on unmount**: Ensures the component clears its timer upon unmounting, preventing memory leaks or background errors. Currently, **all** tests would be considered the "happy path," meaning they only verify the best-case scenario and do not test for bad inputs/outputs. Adding "bad path" (edge case) tests would be highly advisable, but since it falls outside the scope of this PR and issue, it is left for future development. ## Issue: General: #752 The times each should refresh: #742 Inspiration from #702
a22erigr 2026-05-08 07:12:13 +00:00
Collaborator

Review on #752

Whats done

Tested on Windows using Firefox

  • App starts
    • All views load without errors
    • pollFrequencyConfig.js centralizes refresh intervals which is clean
    • Tests included for all modified views

Inspected following files

  • configs/pollFrequencyConfig.js
    • Indentation/code styling
      • Follows prettier
    • Naming convention
      • Follows wiki standards
    • Comments
      • Follows wiki standards
    • General code quality
      • Clean and easy to read
  • features/parking/ParkingView.js
    • General code quality
      • console.log statements left in on lines 20 and 43
      • useParking() does not accept refreshCount so passing it does nothing
  • features/smhi/SMHIForecastView.js, SMHITemperatureView.js, booking/BookingView.js, schedule/ScheduleView.js
    • General code quality
      • Same problem
  • features/utility/sharedFeatures.js
    • General code quality
      • Added options to useEffect dependency array this causes infinite re-renders because hooks like useSMHIForecast pass a new object every render.

What needs to be done

  • Remove console.log debug statements in ParkingView.js
  • The hooks (useParking, useSMHIForecast, useSMHIObservations, useBooking, useTimeedit) need to accept refreshCount and pass it to useApi, otherwise auto-refresh does not work.
  • Remove options from the useEffect dependency array in sharedFeatures.js

Conclusion

  • Config file and tests are well done. The main issues is that auto-refresh does not actually work for most views because the hooks ignore refreshCount and the sharedFeatures.js change causes infinite API calls. Needs fixes before merge.

Screenshot 2026-05-08 195450

# Review on #752 ## Whats done ### Tested on Windows using Firefox + App starts + All views load without errors + pollFrequencyConfig.js centralizes refresh intervals which is clean + Tests included for all modified views ### Inspected following files + configs/pollFrequencyConfig.js + Indentation/code styling + Follows prettier + Naming convention + Follows wiki standards + Comments + Follows wiki standards + General code quality + Clean and easy to read + features/parking/ParkingView.js + General code quality + console.log statements left in on lines 20 and 43 + useParking() does not accept refreshCount so passing it does nothing + features/smhi/SMHIForecastView.js, SMHITemperatureView.js, booking/BookingView.js, schedule/ScheduleView.js + General code quality + Same problem + features/utility/sharedFeatures.js + General code quality + Added options to useEffect dependency array this causes infinite re-renders because hooks like useSMHIForecast pass a new object every render. ## What needs to be done + Remove console.log debug statements in ParkingView.js + The hooks (useParking, useSMHIForecast, useSMHIObservations, useBooking, useTimeedit) need to accept refreshCount and pass it to useApi, otherwise auto-refresh does not work. + Remove options from the useEffect dependency array in sharedFeatures.js ## Conclusion + Config file and tests are well done. The main issues is that auto-refresh does not actually work for most views because the hooks ignore refreshCount and the sharedFeatures.js change causes infinite API calls. Needs fixes before merge. ![Screenshot 2026-05-08 195450](/attachments/3b496cbb-3134-439d-aad2-fff0d4c7bcbc)
Collaborator

Can you fix the problems c24elipe

Can you fix the problems c24elipe
Author
Collaborator

I think it is fixed after the review requirements now

I think it is fixed after the review requirements now
Collaborator

Re-review on #752

Previous issues checked

  • console.log statements removed
  • Hooks now accept and pass refreshCount
  • sharedFeatures.js infinite re-render fixed

Conclusion

  • Main issues from previous review are fixed. Ready for merge.
# Re-review on #752 ## Previous issues checked + console.log statements removed + Hooks now accept and pass refreshCount + sharedFeatures.js infinite re-render fixed ## Conclusion + Main issues from previous review are fixed. Ready for merge.
a22erigr merged commit 278c9f148e into team_2_week_5 2026-05-12 10:55:11 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Andras/BoundlessFlowCampus2K!827
No description provided.