Skip to content

fix(web): fake folder access checks in the add-folder-videos test - #3108

Merged
richiemcilroy merged 1 commit into
CapSoftware:mainfrom
patrickballard:fix/add-folder-videos-access-test
Oct 24, 2026
Merged

richiemcilroy merged 1 commit into
CapSoftware:mainfrom
patrickballard:fix/add-folder-videos-access-test

Conversation

@patrickballard

@patrickballard patrickballard commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

apps/web/__tests__/unit/add-folder-videos.test.ts fails 8 of its 10 tests on main, each with Error: Folder not found.

The test arrived in bd7648a, written against addVideosToFolder before the ownership checks from d2348b1 were merged. That commit made the action select organizationId alongside id and spaceId, and call getOrganizationAccess / getSpaceAccess before writing. Each change is fine on its own; together:

  • the test's fake database still returns two-column folder rows, so organizationId reads the space id and spaceId is undefined
  • the access helpers aren't faked, so their queries fall through to the catch-all branch that returns shared-video rows. Access is granted only when a test happens to return shared rows, which is why exactly the 8 tests with none fail

Fix

  • Fake getOrganizationAccess and getSpaceAccess with hoisted vi.fn()s, the way move-owned-videos.test.ts does, defaulting to an authorised owner of the folder's organization.
  • Return the folder's organizationId in its row.

New coverage

addVideosToFolder is only tested here, and d2348b1 added no tests, so its ownership checks had no coverage at all. Two new tests, run for both the space and organization variants, check that these are rejected before anything is written:

  • a caller with no access to the collection
  • a folder that belongs to another organization

They are not tautological. Mutating add-videos.ts:

mutation result
delete the whole access check exactly the 4 new tests fail; the original 10 still pass
drop folder.organizationId !== user.activeOrganizationId only the organization-folder cross-org test fails
drop access.organizationId !== folder.organizationId only the space-folder cross-org test fails

Verification

  • bun run test in apps/web: 8 failed → 0 failed; total up by exactly the 4 new tests, nothing else affected
  • 14/14 across 5 runs in shuffled order
  • bun run typecheck exit 0, biome ci clean
  • based on the latest main

Test-only change; add-videos.ts is untouched. The web unit suite isn't part of CI, which is how this went unnoticed.

RetriggerView in GreptileConfidence Score: 5/5

This test-only change appears safe to merge.

Summary

Repairs the database fixtures and access mocks in add-folder-videos.test.ts.

  • Folder-video tests now cover access checks for both folder types.

Reviews (1) · Last reviewed commit: "fix(web): fake folder access checks in t..." · Reviewed by Greptile

add-folder-videos.test.ts fails 8 of its 10 tests on main. It was
written against addVideosToFolder before the ownership checks from
d2348b1 landed: its fake database still returns two-column folder
rows, and the new getOrganizationAccess / getSpaceAccess lookups fall
through to the catch-all branch, so access is only granted when a test
happens to return shared rows.

Fake both access helpers the way move-owned-videos.test.ts does and
return the folder's organizationId. Add tests that a caller without
access, and a folder from another organization, are rejected before
anything is written; nothing covered those checks until now.
@vercel
vercel Bot temporarily deployed to Preview – cap-status October 24, 2026 14:43 Inactive
@vercel

vercel Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Oct 24, 2026 2:43pm UTC

@richiemcilroy
richiemcilroy merged commit 24d7984 into CapSoftware:main Oct 24, 2026
31 of 32 checks passed

This branch was previously deployed

1 inactive deployment
Preview – cap-status — a2f79cc2 Deployed Oct 24, 2026 by vercel[bot]
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.

2 participants