executionRailHidden.test.ts2.8 KBView on GitHub
import {
  TASK_EXECUTION_RAIL_ENABLED,
  shouldForceRailExpandedForTask,
  shouldShowTaskExecutionRail,
} from '@/modules/userTasks/utils/execution-rail';

/**
 * The task-execution rail is OFF: opening a task must never turn the left rail into the
 * task list.
 *
 * Why this is pinned rather than left to the constant. Opening a task still writes `?group=`
 * and `?task=` — those params drive the pinned task card in the centre column, which stays.
 * So every input the rail used to switch on is still present on every task open, and the
 * ONLY thing keeping the rail as navigation is these two predicates. A well-meaning
 * "the param is set, so show the list" change reads as a bug fix and silently brings back
 * the exact surface the customer called the most confusing thing in the product.
 *
 * The inputs below are the real execution-mode state, not edge cases: a task open in an
 * expanded rail with its lane selected is precisely what a click on a task produces.
 */
describe('task execution rail is hidden', () => {
  it('is disabled', () => {
    expect(TASK_EXECUTION_RAIL_ENABLED).toBe(false);
  });

  describe('shouldShowTaskExecutionRail', () => {
    it('stays hidden for an open lane in an expanded rail — the execution-mode state', () => {
      expect(shouldShowTaskExecutionRail({ expanded: true, groupParam: 'group-1' })).toBe(false);
    });

    it('stays hidden for the Misc lane, whose key is a real group value', () => {
      // `?group=misc` is written for a task with no group (taskGroupId === null), so it is
      // not a "no lane" sentinel the gate could fall through on.
      expect(shouldShowTaskExecutionRail({ expanded: true, groupParam: 'misc' })).toBe(false);
    });

    it('stays hidden with no lane open', () => {
      expect(shouldShowTaskExecutionRail({ expanded: true, groupParam: null })).toBe(false);
    });

    it('stays hidden while the rail is collapsed', () => {
      expect(shouldShowTaskExecutionRail({ expanded: false, groupParam: 'group-1' })).toBe(false);
    });
  });

  describe('shouldForceRailExpandedForTask', () => {
    it('does not override a collapsed rail when a task opens', () => {
      // The user's own collapse preference wins now: there is no task list to keep visible,
      // so forcing the rail open would just widen plain navigation for no reason.
      expect(shouldForceRailExpandedForTask({ taskParam: 'task-1', onAgentScreen: false })).toBe(
        false,
      );
    });

    it('does not force expansion on /agent either', () => {
      expect(shouldForceRailExpandedForTask({ taskParam: 'task-1', onAgentScreen: true })).toBe(
        false,
      );
    });

    it('does not force expansion with no task open', () => {
      expect(shouldForceRailExpandedForTask({ taskParam: null, onAgentScreen: false })).toBe(false);
    });
  });
});