@@ -2,6 +2,7 @@ import { describe, it, expect } from 'vitest';
2
2
import gql from 'graphql-tag' ;
3
3
import { ADMIN_USER , queryAsAdmin } from '../../utils/testQuery' ;
4
4
import type { CaseIncident } from '../../../src/generated/graphql' ;
5
+ import { ENTITY_TYPE_CONTAINER_CASE_INCIDENT } from '../../../src/modules/case/case-incident/case-incident-types' ;
5
6
6
7
const CREATE_QUERY = gql `
7
8
mutation CaseIncidentAdd($input: CaseIncidentAddInput!) {
@@ -12,6 +13,7 @@ const CREATE_QUERY = gql`
12
13
description
13
14
authorized_members {
14
15
id
16
+ access_right
15
17
}
16
18
}
17
19
}
@@ -134,9 +136,21 @@ describe('Case Incident Response resolver standard behavior', () => {
134
136
135
137
describe ( 'Case Incident Response authorized_members standard behavior' , ( ) => {
136
138
let caseIncidentResponseAuthorizedMembers : CaseIncident ;
137
- it ( 'should Case Incident Response created with authorized_members activated' , async ( ) => {
139
+ it ( 'should Case Incident Response created with authorized_members activated via settings ' , async ( ) => {
138
140
// Activate authorized members for IR
139
- const UPDATE_SETTINGS_QUERY = gql `
141
+ const ENTITY_SETTINGS_READ_QUERY_BY_TARGET_TYPE = gql `
142
+ query entitySettingsByTargetType($targetType: String!) {
143
+ entitySettingByType(targetType: $targetType) {
144
+ id
145
+ target_type
146
+ platform_entity_files_ref
147
+ platform_hidden_type
148
+ enforce_reference
149
+ }
150
+ }
151
+ ` ;
152
+
153
+ const ENTITY_SETTINGS_UPDATE_QUERY = gql `
140
154
mutation entitySettingsEdit($ids: [ID!]!, $input: [EditInput!]!) {
141
155
entitySettingsFieldPatch(ids: $ids, input: $input) {
142
156
id
@@ -148,21 +162,21 @@ describe('Case Incident Response authorized_members standard behavior', () => {
148
162
}
149
163
}
150
164
` ;
151
- const variables = {
152
- ids : [
153
- '5a18d85f-6e4b-4191-9e23-eeeedd6ca41a'
154
- ] ,
155
- input : {
156
- key : 'attributes_configuration' ,
157
- value : '[{"name":"authorized_members","default_values":["{\\"id\\":\\"CREATOR\\",\\"access_right\\":\\"admin\\"}"]}]'
158
- }
159
- } ;
160
- // TODO use JSON.stringify(
161
- await queryAsAdmin ( {
162
- query : UPDATE_SETTINGS_QUERY ,
163
- variables,
165
+
166
+ const caseIncidentResponseSettingsQueryResult = await queryAsAdmin ( {
167
+ query : ENTITY_SETTINGS_READ_QUERY_BY_TARGET_TYPE ,
168
+ variables : { targetType : ENTITY_TYPE_CONTAINER_CASE_INCIDENT }
169
+ } ) ;
170
+ expect ( caseIncidentResponseSettingsQueryResult . data ?. entitySettingByType . target_type ) . toEqual ( ENTITY_TYPE_CONTAINER_CASE_INCIDENT ) ;
171
+ const caseIncidentEntitySetting = caseIncidentResponseSettingsQueryResult . data ?. entitySettingByType ;
172
+
173
+ const authorizedMembersConfiguration = JSON . stringify ( [ { name : 'authorized_members' , default_values : [ { id : ADMIN_USER . id , access_right : 'admin' } ] } ] ) ;
174
+
175
+ const updateEntitySettingsResult = await queryAsAdmin ( {
176
+ query : ENTITY_SETTINGS_UPDATE_QUERY ,
177
+ variables : { ids : [ caseIncidentEntitySetting . id ] , input : { key : 'attributes_configuration' , value : [ authorizedMembersConfiguration ] } } ,
164
178
} ) ;
165
- // TODO ADD assertion to check that entitysettings have been modify?
179
+ expect ( updateEntitySettingsResult . data ?. entitySettingsFieldPatch [ 0 ] . attribute_configuration ) . toEqual ( [ authorizedMembersConfiguration ] ) ;
166
180
167
181
const caseIncidentResponseAuthorizedMembersData = await queryAsAdmin ( {
168
182
query : CREATE_QUERY ,
@@ -182,6 +196,11 @@ describe('Case Incident Response authorized_members standard behavior', () => {
182
196
}
183
197
] ) ;
184
198
caseIncidentResponseAuthorizedMembers = caseIncidentResponseAuthorizedMembersData ?. data ?. caseIncidentAdd ;
199
+ // Clean
200
+ await queryAsAdmin ( {
201
+ query : ENTITY_SETTINGS_UPDATE_QUERY ,
202
+ variables : { ids : [ caseIncidentEntitySetting . id ] , input : { key : 'attributes_configuration' , value : [ ] } } ,
203
+ } ) ;
185
204
} ) ;
186
205
it ( 'should Case Incident Response deleted' , async ( ) => {
187
206
// Delete the case
0 commit comments