From 4236be77c49e9f22d6d0bb6762e7174ab52a8485 Mon Sep 17 00:00:00 2001 From: Sawy Date: Tue, 30 Jan 2024 18:29:01 +0200 Subject: [PATCH] CV2-4072: test coverage --- app/graph/types/bot_user_type.rb | 2 +- app/lib/check_graphql.rb | 2 ++ lib/relay.idl | 2 +- public/relay.json | 2 +- test/controllers/graphql_controller_2_test.rb | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/graph/types/bot_user_type.rb b/app/graph/types/bot_user_type.rb index af26bc92b0..179abed85b 100644 --- a/app/graph/types/bot_user_type.rb +++ b/app/graph/types/bot_user_type.rb @@ -46,7 +46,7 @@ def settings_as_json_schema(team_slug: nil) object.settings_as_json_schema(false, team_slug) end - field :team_author, TeamType, null: true + field :team_author, PublicTeamType, null: true def team_author RecordLoader.for(Team).load(object.team_author_id.to_i) diff --git a/app/lib/check_graphql.rb b/app/lib/check_graphql.rb index 136fe18fa8..66bcf34271 100644 --- a/app/lib/check_graphql.rb +++ b/app/lib/check_graphql.rb @@ -23,6 +23,8 @@ def object_from_id(id, ctx) if type_name == 'About' name = Rails.application.class.module_parent_name obj = OpenStruct.new({ name: name, version: VERSION, id: 1, type: 'About' }) + elsif type_name == 'Me' + obj = User.find_if_can(id) elsif ['Relationships', 'RelationshipsSource', 'RelationshipsTarget'].include?(type_name) obj = ProjectMedia.find_if_can(id) elsif type_name == 'CheckSearch' diff --git a/lib/relay.idl b/lib/relay.idl index cda6635e8c..22ac832d7a 100644 --- a/lib/relay.idl +++ b/lib/relay.idl @@ -479,7 +479,7 @@ type BotUser implements Node { permissions: String settings_as_json_schema(team_slug: String): String settings_ui_schema: String - team_author: Team + team_author: PublicTeam updated_at: String } diff --git a/public/relay.json b/public/relay.json index 85bb36e641..f035b73e3f 100644 --- a/public/relay.json +++ b/public/relay.json @@ -2328,7 +2328,7 @@ ], "type": { "kind": "OBJECT", - "name": "Team", + "name": "PublicTeam", "ofType": null }, "isDeprecated": false, diff --git a/test/controllers/graphql_controller_2_test.rb b/test/controllers/graphql_controller_2_test.rb index 929898e4fc..294139c421 100644 --- a/test/controllers/graphql_controller_2_test.rb +++ b/test/controllers/graphql_controller_2_test.rb @@ -53,7 +53,7 @@ def setup authenticate_with_user tb1 = create_team_bot set_listed: true tb2 = create_team_bot set_listed: false - query = "query read { root { current_user { id }, current_team { id }, team_bots_listed { edges { node { dbid } } } } }" + query = "query read { root { current_user { id }, current_team { id }, team_bots_listed { edges { node { dbid, get_description, get_version, get_source_code_url, get_role } } } } }" post :create, params: { query: query } edges = JSON.parse(@response.body)['data']['root']['team_bots_listed']['edges'] assert_equal [tb1.id], edges.collect{ |e| e['node']['dbid'] }