@@ -210,10 +210,15 @@ func TestFindStarredByWorkspace(t *testing.T) {
210
210
project2ID := createProject (e , "Project 2" )
211
211
project3ID := createProject (e , "Project 3" )
212
212
project4ID := createProject (e , "Project 4" )
213
+ project5ID := createProject (e , "Project 5" )
213
214
214
215
starProject (e , project1ID )
215
216
starProject (e , project3ID )
216
217
218
+ // star and deleted 'Project 5'
219
+ starProject (e , project5ID )
220
+ deleteProject (e , project5ID )
221
+
217
222
requestBody := GraphQLRequest {
218
223
OperationName : "GetStarredProjects" ,
219
224
Query : `
@@ -251,6 +256,8 @@ func TestFindStarredByWorkspace(t *testing.T) {
251
256
nodeCount := int (nodes .Length ().Raw ())
252
257
assert .Equal (t , 2 , nodeCount , "Expected 2 nodes in the response" )
253
258
259
+ nodes .Length ().Equal (2 ) // 'Project 1' and 'Project 3'
260
+
254
261
starredProjectsMap := make (map [string ]bool )
255
262
for _ , node := range nodes .Iter () {
256
263
obj := node .Object ()
@@ -275,7 +282,6 @@ func TestFindStarredByWorkspace(t *testing.T) {
275
282
assert .True (t , starredProjectsMap [project3ID ], "Project 3 should be starred" )
276
283
assert .False (t , starredProjectsMap [project2ID ], "Project 2 should not be starred" )
277
284
assert .False (t , starredProjectsMap [project4ID ], "Project 4 should not be starred" )
278
-
279
285
}
280
286
281
287
func starProject (e * httpexpect.Expect , projectID string ) {
@@ -449,6 +455,96 @@ func TestSortByUpdatedAt(t *testing.T) {
449
455
450
456
edges .Length ().Equal (3 )
451
457
edges .Element (0 ).Object ().Value ("node" ).Object ().Value ("name" ).Equal ("project2-test" ) // 'project2' is first
452
- edges .Element (1 ).Object ().Value ("node" ).Object ().Value ("name" ).Equal ("project3-test" )
453
- edges .Element (2 ).Object ().Value ("node" ).Object ().Value ("name" ).Equal ("project1-test" )
458
+ }
459
+
460
+ // go test -v -run TestDeleteProjects ./e2e/...
461
+
462
+ func TestDeleteProjects (t * testing.T ) {
463
+
464
+ e := StartServer (t , & config.Config {
465
+ Origins : []string {"https://example.com" },
466
+ AuthSrv : config.AuthSrvConfig {
467
+ Disabled : true ,
468
+ },
469
+ }, true , baseSeeder )
470
+
471
+ createProject (e , "project1-test" )
472
+ project2ID := createProject (e , "project2-test" )
473
+ createProject (e , "project3-test" )
474
+
475
+ // Deleted 'project2'
476
+ deleteProject (e , project2ID )
477
+
478
+ // check
479
+ requestBody := GraphQLRequest {
480
+ OperationName : "GetDeletedProjects" ,
481
+ Query : `
482
+ query GetDeletedProjects($teamId: ID!) {
483
+ deletedProjects(teamId: $teamId) {
484
+ nodes {
485
+ id
486
+ name
487
+ isDeleted
488
+ }
489
+ totalCount
490
+ }
491
+ }` ,
492
+ Variables : map [string ]any {
493
+ "teamId" : wID ,
494
+ },
495
+ }
496
+ deletedProjects := e .POST ("/api/graphql" ).
497
+ WithHeader ("Origin" , "https://example.com" ).
498
+ WithHeader ("X-Reearth-Debug-User" , uID .String ()).
499
+ WithHeader ("Content-Type" , "application/json" ).
500
+ WithJSON (requestBody ).
501
+ Expect ().
502
+ Status (http .StatusOK ).
503
+ JSON ().
504
+ Object ().Value ("data" ).Object ().Value ("deletedProjects" ).Object ()
505
+
506
+ deletedProjects .Value ("totalCount" ).Equal (1 )
507
+ deletedProjects .Value ("nodes" ).Array ().Length ().Equal (1 )
508
+ deletedProjects .Value ("nodes" ).Array ().First ().Object ().Value ("name" ).Equal ("project2-test" )
509
+ }
510
+
511
+ func deleteProject (e * httpexpect.Expect , projectID string ) {
512
+
513
+ updateProjectMutation := GraphQLRequest {
514
+ OperationName : "UpdateProject" ,
515
+ Query : `mutation UpdateProject($input: UpdateProjectInput!) {
516
+ updateProject(input: $input) {
517
+ project {
518
+ id
519
+ name
520
+ isDeleted
521
+ updatedAt
522
+ __typename
523
+ }
524
+ __typename
525
+ }
526
+ }` ,
527
+ Variables : map [string ]any {
528
+ "input" : map [string ]any {
529
+ "projectId" : projectID ,
530
+ "deleted" : true ,
531
+ },
532
+ },
533
+ }
534
+
535
+ response := e .POST ("/api/graphql" ).
536
+ WithHeader ("Origin" , "https://example.com" ).
537
+ WithHeader ("X-Reearth-Debug-User" , uID .String ()).
538
+ WithHeader ("Content-Type" , "application/json" ).
539
+ WithJSON (updateProjectMutation ).
540
+ Expect ().
541
+ Status (http .StatusOK ).
542
+ JSON ().
543
+ Object ().
544
+ Value ("data" ).Object ().
545
+ Value ("updateProject" ).Object ().
546
+ Value ("project" ).Object ()
547
+
548
+ response .ValueEqual ("id" , projectID ).
549
+ ValueEqual ("isDeleted" , true )
454
550
}
0 commit comments