@@ -3,49 +3,56 @@ import { test as setup } from "@e2e/utils/test-with-auth"
3
3
import fs from "fs"
4
4
import path from "node:path"
5
5
6
- setup ( "login" , async ( { page } ) => {
7
- await page . goto ( "/" )
8
- await page . waitForURL ( / l o c a l h o s t : 8 4 4 3 / )
9
-
10
- await page
11
- . getByRole ( "textbox" , { name : "Username or email" } )
12
- . fill ( "jane.doe" )
13
-
14
- await page . getByRole ( "textbox" , { name : "Password" } ) . fill ( "test" )
15
-
16
- await page . getByRole ( "button" , { name : "Sign In" } ) . click ( )
17
-
18
- await page . context ( ) . storageState ( { path : `e2e/storage/state.json` } )
19
-
20
- await page . waitForURL ( "/" )
21
- await page . unrouteAll ( { behavior : "wait" } )
22
- } )
23
-
24
- setup ( "create sample data" , async ( { authenticatedRequest : request } ) => {
25
- const files = [
26
- "bgbl-1_1001_2_mods_01/aenderungsgesetz.xml" ,
27
- "bgbl-1_1002_2_mods-subsitution_01/aenderungsgesetz.xml" ,
28
- "bgbl-1_2017_s419/aenderungsgesetz.xml" ,
29
- "bgbl-1_2023_413/aenderungsgesetz.xml" ,
30
- ]
31
-
32
- for ( const file of files ) {
33
- const filePath = path . join ( samplesDirectory , file )
34
- const fileContent = fs . readFileSync ( filePath ) // Read the file content
35
-
36
- const formData = new FormData ( )
37
- formData . append ( "file" , new Blob ( [ fileContent ] , { type : "text/xml" } ) , file )
38
- formData . append ( "force" , String ( true ) )
39
-
40
- const response = await request . post (
41
- `${ process . env . E2E_BASE_URL } /api/v1/announcements` ,
42
- { multipart : formData } ,
43
- )
44
-
45
- if ( ! response . ok ( ) ) {
46
- throw new Error ( `Failed to set up test data: ${ response . statusText ( ) } ` )
6
+ setup (
7
+ "login and create sample data" ,
8
+ async ( { page, authenticatedRequest : request } ) => {
9
+ // Login
10
+ await page . goto ( "/" )
11
+ await page . waitForURL ( / l o c a l h o s t : 8 4 4 3 / )
12
+
13
+ await page
14
+ . getByRole ( "textbox" , { name : "Username or email" } )
15
+ . fill ( "jane.doe" )
16
+
17
+ await page . getByRole ( "textbox" , { name : "Password" } ) . fill ( "test" )
18
+
19
+ await page . getByRole ( "button" , { name : "Sign In" } ) . click ( )
20
+
21
+ await page . context ( ) . storageState ( { path : `e2e/storage/state.json` } )
22
+
23
+ await page . waitForURL ( "/" )
24
+ await page . unrouteAll ( { behavior : "wait" } )
25
+
26
+ // Create sample data
27
+ const files = [
28
+ "bgbl-1_1001_2_mods_01/aenderungsgesetz.xml" ,
29
+ "bgbl-1_1002_2_mods-subsitution_01/aenderungsgesetz.xml" ,
30
+ "bgbl-1_2017_s419/aenderungsgesetz.xml" ,
31
+ "bgbl-1_2023_413/aenderungsgesetz.xml" ,
32
+ ]
33
+
34
+ for ( const file of files ) {
35
+ const filePath = path . join ( samplesDirectory , file )
36
+ const fileContent = fs . readFileSync ( filePath ) // Read the file content
37
+
38
+ const formData = new FormData ( )
39
+ formData . append (
40
+ "file" ,
41
+ new Blob ( [ fileContent ] , { type : "text/xml" } ) ,
42
+ file ,
43
+ )
44
+ formData . append ( "force" , String ( true ) )
45
+
46
+ const response = await request . post (
47
+ `${ process . env . E2E_BASE_URL } /api/v1/announcements` ,
48
+ { multipart : formData } ,
49
+ )
50
+
51
+ if ( ! response . ok ( ) ) {
52
+ throw new Error ( `Failed to set up test data: ${ response . statusText ( ) } ` )
53
+ }
54
+
55
+ console . log ( `Imported ${ file } successfully.` )
47
56
}
48
-
49
- console . log ( `Imported ${ file } successfully.` )
50
- }
51
- } )
57
+ } ,
58
+ )
0 commit comments