Skip to main content

ProjectGuard

Overview

This document outlines the test cases for the ProjectGuard component. The ProjectGuard component is responsible for ensuring that the project session is properly managed, displaying a loading spinner while the project is being fetched from a remote source. These test cases ensure that the component behaves correctly during the loading and loaded states.

Test Case 1: Loading Project from Remote

  • Description: Tests the behavior of the ProjectGuard component when the project data is being loaded from a remote source.
  • Expected Outcome: A spinner container should be displayed while the project data is being fetched. The component should render an element with the test ID spinner-container.

Test Case 2: Finished Loading Project from Remote

  • Description: Tests the behavior of the ProjectGuard component once the project data has finished loading from a remote source.
  • Expected Outcome: The spinner container should no longer be displayed once the project data has finished loading. The element with the test ID spinner-container should not be present in the DOM.

Steps:

  1. Mock Hook Return Value:
    • For the loading state, mock useProjectSession to return { isPending: true }.
    • For the loaded state, mock useProjectSession to return { isPending: false }.
  2. Render Component:
    • Render the ProjectGuard component in both loading and loaded states.
  3. Verify Rendered Elements:
    • In the loading state, verify that an element with the test ID spinner-container is present.
    • In the loaded state, verify that the element with the test ID spinner-container is not present.