@@ -29,7 +29,7 @@ vi.mock("../../../src/app/lib/url", () => ({
2929// ── Imports ───────────────────────────────────────────────────────────────────
3030
3131import PullRequestsTab from "../../../src/app/components/dashboard/PullRequestsTab" ;
32- import { setTabFilter , setAllExpanded , resetViewState } from "../../../src/app/stores/view" ;
32+ import { viewState , setTabFilter , setAllExpanded , resetViewState } from "../../../src/app/stores/view" ;
3333import type { TrackedUser } from "../../../src/app/stores/config" ;
3434
3535// ── Setup ─────────────────────────────────────────────────────────────────────
@@ -473,3 +473,62 @@ describe("PullRequestsTab — star count in repo headers", () => {
473473 expect ( container . textContent ) . not . toContain ( "★" ) ;
474474 } ) ;
475475} ) ;
476+
477+ // ── PullRequestsTab — scope chip visibility ────────────────────────────────
478+
479+ describe ( "PullRequestsTab — scope chip visibility" , ( ) => {
480+ it ( "does not show Scope chip when no monitored repos and no tracked users" , ( ) => {
481+ const prs = [ makePullRequest ( { id : 1 , title : "PR" , repoFullName : "org/repo" , surfacedBy : [ "me" ] } ) ] ;
482+
483+ const { container } = render ( ( ) => (
484+ < PullRequestsTab pullRequests = { prs } userLogin = "me" monitoredRepos = { [ ] } />
485+ ) ) ;
486+
487+ expect ( container . textContent ) . not . toContain ( "Scope:" ) ;
488+ } ) ;
489+
490+ it ( "shows Scope chip when monitored repos exist" , ( ) => {
491+ const prs = [ makePullRequest ( { id : 1 , title : "PR" , repoFullName : "org/repo" , surfacedBy : [ "me" ] } ) ] ;
492+
493+ const { container } = render ( ( ) => (
494+ < PullRequestsTab pullRequests = { prs } userLogin = "me"
495+ monitoredRepos = { [ { owner : "org" , name : "mon" , fullName : "org/mon" } ] }
496+ />
497+ ) ) ;
498+
499+ expect ( container . textContent ) . toContain ( "Scope:" ) ;
500+ } ) ;
501+
502+ it ( "auto-resets scope to involves_me when scope chip becomes hidden" , ( ) => {
503+ setTabFilter ( "pullRequests" , "scope" , "all" ) ;
504+ expect ( viewState . tabFilters . pullRequests . scope ) . toBe ( "all" ) ;
505+
506+ render ( ( ) => (
507+ < PullRequestsTab pullRequests = { [ ] } userLogin = "me" monitoredRepos = { [ ] } />
508+ ) ) ;
509+
510+ expect ( viewState . tabFilters . pullRequests . scope ) . toBe ( "involves_me" ) ;
511+ } ) ;
512+ } ) ;
513+
514+ // ── PullRequestsTab — blocked composite filter ────────────────────────────
515+
516+ describe ( "PullRequestsTab — checkStatus=blocked filter" , ( ) => {
517+ it ( "shows both failure and conflict PRs when checkStatus=blocked" , ( ) => {
518+ const prs = [
519+ makePullRequest ( { id : 1 , title : "Failing PR" , repoFullName : "org/repo" , checkStatus : "failure" , surfacedBy : [ "me" ] , enriched : true } ) ,
520+ makePullRequest ( { id : 2 , title : "Conflict PR" , repoFullName : "org/repo" , checkStatus : "conflict" , surfacedBy : [ "me" ] , enriched : true } ) ,
521+ makePullRequest ( { id : 3 , title : "Passing PR" , repoFullName : "org/repo" , checkStatus : "success" , surfacedBy : [ "me" ] , enriched : true } ) ,
522+ ] ;
523+ setTabFilter ( "pullRequests" , "checkStatus" , "blocked" ) ;
524+ setAllExpanded ( "pullRequests" , [ "org/repo" ] , true ) ;
525+
526+ render ( ( ) => (
527+ < PullRequestsTab pullRequests = { prs } userLogin = "me" monitoredRepos = { [ ] } />
528+ ) ) ;
529+
530+ screen . getByText ( "Failing PR" ) ;
531+ screen . getByText ( "Conflict PR" ) ;
532+ expect ( screen . queryByText ( "Passing PR" ) ) . toBeNull ( ) ;
533+ } ) ;
534+ } ) ;
0 commit comments