@@ -216,6 +216,74 @@ defmodule LinearCli.CLI.ProfileDefaultsTest do
216216 assert filter [ "project" ] == % { "id" => % { "eq" => "p2" } }
217217 end
218218
219+ test "--no-profile bypasses the active profile's team/project defaults" do
220+ { :ok , _ } = Profiles . create ( "manhattan" , team: "CRY" , project: "Manhattan Rollout" )
221+ :ok = Profiles . activate ( "manhattan" )
222+
223+ test_pid = self ( )
224+
225+ Req.Test . stub ( LinearCli.Api , fn conn ->
226+ { :ok , body , conn } = Plug.Conn . read_body ( conn )
227+ decoded = Jason . decode! ( body )
228+ query = decoded [ "query" ]
229+
230+ cond do
231+ String . contains? ( query , "issues(filter" ) ->
232+ send ( test_pid , { :filter , decoded [ "variables" ] [ "filter" ] } )
233+ Req.Test . json ( conn , issues_response ( [ issue_map ( ) ] ) )
234+
235+ true ->
236+ raise "no stub matched query: #{ query } "
237+ end
238+ end )
239+
240+ result = % {
241+ flags: % { no_mine: false , unassigned: false , full: false , no_profile: true } ,
242+ options: % { team: nil , project: nil , output: "text" } ,
243+ unknown: [ ]
244+ }
245+
246+ capture_io ( fn -> assert :ok = Commands . issue_list ( result ) end )
247+
248+ assert_received { :filter , filter }
249+ refute Map . has_key? ( filter , "team" )
250+ refute Map . has_key? ( filter , "project" )
251+ end
252+
253+ test "--no-profile with an explicit --team still applies the explicit team" do
254+ { :ok , _ } = Profiles . create ( "manhattan" , team: "CRY" , project: "Manhattan Rollout" )
255+ :ok = Profiles . activate ( "manhattan" )
256+
257+ test_pid = self ( )
258+
259+ Req.Test . stub ( LinearCli.Api , fn conn ->
260+ { :ok , body , conn } = Plug.Conn . read_body ( conn )
261+ decoded = Jason . decode! ( body )
262+ query = decoded [ "query" ]
263+
264+ cond do
265+ String . contains? ( query , "issues(filter" ) ->
266+ send ( test_pid , { :filter , decoded [ "variables" ] [ "filter" ] } )
267+ Req.Test . json ( conn , issues_response ( [ issue_map ( ) ] ) )
268+
269+ true ->
270+ raise "no stub matched query: #{ query } "
271+ end
272+ end )
273+
274+ result = % {
275+ flags: % { no_mine: false , unassigned: false , full: false , no_profile: true } ,
276+ options: % { team: "ENG" , project: nil , output: "text" } ,
277+ unknown: [ ]
278+ }
279+
280+ capture_io ( fn -> assert :ok = Commands . issue_list ( result ) end )
281+
282+ assert_received { :filter , filter }
283+ assert filter [ "team" ] == % { "key" => % { "eq" => "ENG" } }
284+ refute Map . has_key? ( filter , "project" )
285+ end
286+
219287 test "resolves bare issue numbers (positional ids) via the active profile's team" do
220288 { :ok , _ } = Profiles . create ( "manhattan" , team: "CRY" )
221289 :ok = Profiles . activate ( "manhattan" )
@@ -250,6 +318,77 @@ defmodule LinearCli.CLI.ProfileDefaultsTest do
250318 end
251319 end
252320
321+ describe "Commands.issue_list/1 with --no-profile bypasses active profile defaults" do
322+ test "ignores both team and project defaults when --no-profile is set" do
323+ { :ok , _ } = Profiles . create ( "manhattan" , team: "CRY" , project: "Manhattan Rollout" )
324+ :ok = Profiles . activate ( "manhattan" )
325+
326+ test_pid = self ( )
327+
328+ Req.Test . stub ( LinearCli.Api , fn conn ->
329+ { :ok , body , conn } = Plug.Conn . read_body ( conn )
330+ decoded = Jason . decode! ( body )
331+ query = decoded [ "query" ]
332+
333+ if String . contains? ( query , "projects(first: $first" ) do
334+ raise "--no-profile must not query projects when --project wasn't given"
335+ end
336+
337+ if String . contains? ( query , "issues(filter" ) do
338+ send ( test_pid , { :filter , decoded [ "variables" ] [ "filter" ] } )
339+ Req.Test . json ( conn , issues_response ( [ issue_map ( ) ] ) )
340+ else
341+ raise "no stub matched query: #{ query } "
342+ end
343+ end )
344+
345+ result = % {
346+ flags: % { no_mine: false , unassigned: false , full: false , no_profile: true } ,
347+ options: % { team: nil , project: nil , output: "text" } ,
348+ unknown: [ ]
349+ }
350+
351+ output = capture_io ( fn -> assert :ok = Commands . issue_list ( result ) end )
352+
353+ assert output =~ "CRY-1"
354+ assert_received { :filter , filter }
355+ refute Map . has_key? ( filter , "team" )
356+ refute Map . has_key? ( filter , "project" )
357+ end
358+
359+ test "--no-profile with explicit --team still applies the explicit team" do
360+ { :ok , _ } = Profiles . create ( "manhattan" , team: "CRY" , project: "Manhattan Rollout" )
361+ :ok = Profiles . activate ( "manhattan" )
362+
363+ test_pid = self ( )
364+
365+ Req.Test . stub ( LinearCli.Api , fn conn ->
366+ { :ok , body , conn } = Plug.Conn . read_body ( conn )
367+ decoded = Jason . decode! ( body )
368+ query = decoded [ "query" ]
369+
370+ if String . contains? ( query , "issues(filter" ) do
371+ send ( test_pid , { :filter , decoded [ "variables" ] [ "filter" ] } )
372+ Req.Test . json ( conn , issues_response ( [ issue_map ( ) ] ) )
373+ else
374+ raise "no stub matched query: #{ query } "
375+ end
376+ end )
377+
378+ result = % {
379+ flags: % { no_mine: false , unassigned: false , full: false , no_profile: true } ,
380+ options: % { team: "ENG" , project: nil , output: "text" } ,
381+ unknown: [ ]
382+ }
383+
384+ capture_io ( fn -> assert :ok = Commands . issue_list ( result ) end )
385+
386+ assert_received { :filter , filter }
387+ assert filter [ "team" ] == % { "key" => % { "eq" => "ENG" } }
388+ refute Map . has_key? ( filter , "project" )
389+ end
390+ end
391+
253392 describe "Commands.issue_update/1 resolves bare issue numbers via the active profile" do
254393 test "expands a bare positional id before looking it up" do
255394 { :ok , _ } = Profiles . create ( "manhattan" , team: "CRY" )
0 commit comments