1
1
import { fileExists } from "@s3-smart-sync/shared/fileExists.js" ;
2
- import { mkdir , readFile , rm , stat } from "node:fs/promises" ;
2
+ import { readFile , rm , stat } from "node:fs/promises" ;
3
3
import { join } from "node:path" ;
4
4
import {
5
5
UNIGNORE_DURATION ,
@@ -10,6 +10,7 @@ import {
10
10
cleanupS3 ,
11
11
clientLogs ,
12
12
createClientDirectories ,
13
+ createDirectory ,
13
14
createFile ,
14
15
list ,
15
16
pause ,
@@ -32,14 +33,27 @@ globalThis.it = (name: string, fn: () => Promise<void>, timeout?: number) => {
32
33
originalIt (
33
34
name ,
34
35
async function ( ) {
35
- process . stdout . write ( `===========================================\n` ) ;
36
- process . stdout . write ( `${ name } \n` ) ;
37
- process . stdout . write ( `===========================================\n` ) ;
36
+ process . stdout . write (
37
+ `===============================================================================\n` ,
38
+ ) ;
39
+ process . stdout . write ( ` 🧪 ${ name } \n` ) ;
40
+ process . stdout . write (
41
+ `===============================================================================\n` ,
42
+ ) ;
38
43
return await fn ( ) ;
39
44
} ,
40
45
timeout ,
41
46
) ;
42
47
} ;
48
+ // @ts -expect-error
49
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
50
+ globalThis . it . only = (
51
+ name : string ,
52
+ fn : ( ) => Promise < void > ,
53
+ timeout ?: number ,
54
+ ) => {
55
+ originalIt . only ( name , fn , timeout ) ;
56
+ } ;
43
57
44
58
describe ( "E2E Tests" , ( ) => {
45
59
beforeAll ( async ( ) => {
@@ -118,7 +132,9 @@ describe("E2E Tests", () => {
118
132
await stopClients ( [ 1 ] ) ;
119
133
await Promise . all (
120
134
Object . entries ( TEST_FILES ) . map ( ( [ key , content ] ) =>
121
- createFile ( 0 , key , content ) ,
135
+ key . endsWith ( "/" )
136
+ ? createDirectory ( 0 , key as `${string } /`)
137
+ : createFile ( 0 , key , content ) ,
122
138
) ,
123
139
) ;
124
140
await startClients ( [ 1 ] ) ;
@@ -177,11 +193,7 @@ describe("E2E Tests", () => {
177
193
await pause ( WATCHER_DEBOUNCE_DURATION + 300 ) ;
178
194
await sendSnsMessage ( "file-then-directory" , "delete" ) ;
179
195
180
- await mkdir ( join ( clientDirectories [ 0 ] ! , "file-then-directory" ) ) ;
181
- // First, the debounced upload. Then we have to wait for the upload to actually have finished
182
- await pause ( WATCHER_DEBOUNCE_DURATION + 300 ) ;
183
- await sendSnsMessage ( "file-then-directory/" , "put" ) ;
184
-
196
+ await createDirectory ( 0 , "file-then-directory/" ) ;
185
197
await waitUntil ( async ( ) =>
186
198
(
187
199
await stat ( join ( clientDirectories [ 1 ] ! , "file-then-directory" ) )
@@ -190,10 +202,7 @@ describe("E2E Tests", () => {
190
202
} ) ;
191
203
192
204
it ( "should handle replacing an empty directory with a file" , async ( ) => {
193
- await mkdir ( join ( clientDirectories [ 0 ] ! , "directory-then-file" ) ) ;
194
- // First, the debounced upload. Then we have to wait for the upload to actually have finished
195
- await pause ( WATCHER_DEBOUNCE_DURATION + 300 ) ;
196
- await sendSnsMessage ( "directory-then-file/" , "put" ) ;
205
+ await createDirectory ( 0 , "directory-then-file/" ) ;
197
206
await waitUntil ( async ( ) =>
198
207
(
199
208
await stat ( join ( clientDirectories [ 1 ] ! , "directory-then-file" ) )
@@ -203,7 +212,7 @@ describe("E2E Tests", () => {
203
212
await rm ( join ( clientDirectories [ 0 ] ! , "directory-then-file" ) , {
204
213
recursive : true ,
205
214
} ) ;
206
- await pause ( WATCHER_DEBOUNCE_DURATION + 300 ) ;
215
+ await pause ( WATCHER_DEBOUNCE_DURATION + 1000 ) ;
207
216
await waitUntil ( async ( ) => {
208
217
const { Contents } = await list ( "directory-then-file/" ) ;
209
218
return Contents === undefined ;
0 commit comments