1
- import { expect } from "vitest" ;
2
- import { bulkActionHandlers } from "../../src/handlers/bulk-action-handlers.js" ;
3
- import { server } from "../msw-setup.js" ;
1
+ import { expect , vi } from "vitest"
2
+ import { bulkActionHandlers } from "../../src/handlers/bulk-action-handlers.js"
3
+ import { server } from "../msw-setup.js"
4
4
5
5
describe ( "Bulk Action Handlers Integration Tests" , ( ) => {
6
6
// Start MSW Server before tests
7
- beforeAll ( ( ) => server . listen ( ) ) ;
8
- afterEach ( ( ) => server . resetHandlers ( ) ) ;
9
- afterAll ( ( ) => server . close ( ) ) ;
7
+ beforeAll ( ( ) => server . listen ( ) )
8
+ afterEach ( ( ) => server . resetHandlers ( ) )
9
+ afterAll ( ( ) => server . close ( ) )
10
10
11
- const testSpaceId = "test-space-id" ;
12
- const testEnvironmentId = "master" ;
13
- const testEntryId = "test-entry-id" ;
14
- const testAssetId = "test-asset-id" ;
11
+ const testSpaceId = "test-space-id"
12
+ const testEnvironmentId = "master"
13
+ const testEntryId = "test-entry-id"
14
+ const testAssetId = "test-asset-id"
15
15
16
16
// Mock the getContentfulClient function to avoid actual API calls
17
17
vi . mock ( "../../src/config/client.js" , ( ) => ( {
18
18
getContentfulClient : vi . fn ( ) . mockResolvedValue ( {
19
19
entry : {
20
20
get : vi . fn ( ) . mockResolvedValue ( {
21
- sys : { id : testEntryId , version : 1 }
22
- } )
21
+ sys : { id : testEntryId , version : 1 } ,
22
+ } ) ,
23
23
} ,
24
24
asset : {
25
25
get : vi . fn ( ) . mockResolvedValue ( {
26
- sys : { id : testAssetId , version : 1 }
27
- } )
26
+ sys : { id : testAssetId , version : 1 } ,
27
+ } ) ,
28
28
} ,
29
29
bulkAction : {
30
30
publish : vi . fn ( ) . mockResolvedValue ( {
31
- sys : { id : "test-bulk-action-id" , status : "created" }
31
+ sys : { id : "test-bulk-action-id" , status : "created" } ,
32
32
} ) ,
33
33
unpublish : vi . fn ( ) . mockResolvedValue ( {
34
- sys : { id : "test-bulk-action-id" , status : "created" }
34
+ sys : { id : "test-bulk-action-id" , status : "created" } ,
35
35
} ) ,
36
36
validate : vi . fn ( ) . mockResolvedValue ( {
37
- sys : { id : "test-bulk-action-id" , status : "created" }
37
+ sys : { id : "test-bulk-action-id" , status : "created" } ,
38
38
} ) ,
39
39
get : vi . fn ( ) . mockResolvedValue ( {
40
40
sys : { id : "test-bulk-action-id" , status : "succeeded" } ,
41
41
succeeded : [
42
42
{ sys : { id : testEntryId , type : "Entry" } } ,
43
- { sys : { id : testAssetId , type : "Asset" } }
44
- ]
45
- } )
46
- }
47
- } )
48
- } ) ) ;
43
+ { sys : { id : testAssetId , type : "Asset" } } ,
44
+ ] ,
45
+ } ) ,
46
+ } ,
47
+ } ) ,
48
+ } ) )
49
49
50
50
describe ( "bulkPublish" , ( ) => {
51
51
it ( "should publish multiple entries and assets" , async ( ) => {
@@ -54,15 +54,15 @@ describe("Bulk Action Handlers Integration Tests", () => {
54
54
environmentId : testEnvironmentId ,
55
55
entities : [
56
56
{ sys : { id : testEntryId , type : "Entry" } } ,
57
- { sys : { id : testAssetId , type : "Asset" } }
58
- ]
59
- } ) ;
57
+ { sys : { id : testAssetId , type : "Asset" } } ,
58
+ ] ,
59
+ } )
60
60
61
- expect ( result ) . to . have . property ( "content" ) . that . is . an ( "array" ) ;
62
- expect ( result . content [ 0 ] . text ) . to . include ( "Bulk publish completed" ) ;
63
- expect ( result . content [ 0 ] . text ) . to . include ( "Successfully processed" ) ;
64
- } ) ;
65
- } ) ;
61
+ expect ( result ) . to . have . property ( "content" ) . that . is . an ( "array" )
62
+ expect ( result . content [ 0 ] . text ) . to . include ( "Bulk publish completed" )
63
+ expect ( result . content [ 0 ] . text ) . to . include ( "Successfully processed" )
64
+ } )
65
+ } )
66
66
67
67
describe ( "bulkUnpublish" , ( ) => {
68
68
it ( "should unpublish multiple entries and assets" , async ( ) => {
@@ -71,27 +71,27 @@ describe("Bulk Action Handlers Integration Tests", () => {
71
71
environmentId : testEnvironmentId ,
72
72
entities : [
73
73
{ sys : { id : testEntryId , type : "Entry" } } ,
74
- { sys : { id : testAssetId , type : "Asset" } }
75
- ]
76
- } ) ;
74
+ { sys : { id : testAssetId , type : "Asset" } } ,
75
+ ] ,
76
+ } )
77
77
78
- expect ( result ) . to . have . property ( "content" ) . that . is . an ( "array" ) ;
79
- expect ( result . content [ 0 ] . text ) . to . include ( "Bulk unpublish completed" ) ;
80
- expect ( result . content [ 0 ] . text ) . to . include ( "Successfully processed" ) ;
81
- } ) ;
82
- } ) ;
78
+ expect ( result ) . to . have . property ( "content" ) . that . is . an ( "array" )
79
+ expect ( result . content [ 0 ] . text ) . to . include ( "Bulk unpublish completed" )
80
+ expect ( result . content [ 0 ] . text ) . to . include ( "Successfully processed" )
81
+ } )
82
+ } )
83
83
84
84
describe ( "bulkValidate" , ( ) => {
85
85
it ( "should validate multiple entries" , async ( ) => {
86
86
const result = await bulkActionHandlers . bulkValidate ( {
87
87
spaceId : testSpaceId ,
88
88
environmentId : testEnvironmentId ,
89
- entryIds : [ testEntryId ]
90
- } ) ;
89
+ entryIds : [ testEntryId ] ,
90
+ } )
91
91
92
- expect ( result ) . to . have . property ( "content" ) . that . is . an ( "array" ) ;
93
- expect ( result . content [ 0 ] . text ) . to . include ( "Bulk validation completed" ) ;
94
- expect ( result . content [ 0 ] . text ) . to . include ( "Successfully validated" ) ;
95
- } ) ;
96
- } ) ;
97
- } ) ;
92
+ expect ( result ) . to . have . property ( "content" ) . that . is . an ( "array" )
93
+ expect ( result . content [ 0 ] . text ) . to . include ( "Bulk validation completed" )
94
+ expect ( result . content [ 0 ] . text ) . to . include ( "Successfully validated" )
95
+ } )
96
+ } )
97
+ } )
0 commit comments