Skip to content

Sidebar.spec: 'should require login before opening following for anonymous users' is red on main #5910

@tsahimatsliah

Description

@tsahimatsliah

Summary

packages/shared/src/components/sidebar/Sidebar.spec.tsxshould require login before opening following for anonymous users has been failing on main since the sidebar rework landed.

Failing test

it('should require login before opening following for anonymous users', async () => {
  renderComponent(defaultAlerts, [createMockFeedSettings()], undefined);
  const item = await screen.findByText('Following');

  fireEvent.click(item);

  expect(showLogin).toHaveBeenCalledWith({
    trigger: 'Following',
  });
});

Observed error

expect(jest.fn()).toHaveBeenCalledWith(...expected)

Expected: {"trigger": "Following"}
Number of calls: 0

showLogin is never invoked when an anonymous user clicks the Following sidebar item. The Following entry in sidebar/sections/MainSection.tsx is set to requiresLogin: true, and SidebarItem / ClickableNavItem look correct on a static read, so the regression is subtle.

Where it originated

Introduced as part of ee36f20e7 feat: add happening now to sidebar — the commit switched renderComponent(..., null) to renderComponent(..., undefined) and moved the settings context over to createTestSettings(...). I suspect the regression is in how the new createTestSettings fixture or the undefined user path flows through AuthContext, rather than a product bug.

Impact

Reproduction

git checkout main
pnpm --filter @dailydotdev/shared test -- --testPathPattern='sidebar/Sidebar.spec'

Tests: 1 failed, 10 passed, 11 total.

Suggested fix

Either restore the old SettingsContextData fixture in the test (to rule out the fixture change) or add a console/print inside ClickableNavItem.onClick to confirm whether showLogin is being invoked with an unexpected argument, or the click target is not the anchor with the handler.

cc @idoshamun — this was from the "happening now" sidebar rework; happy to pair on a fix if helpful, but flagging here so it can be picked up on main.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions