@@ -66,6 +66,14 @@ test.beforeEach(async ({ request, tmpPath }) => {
6666
6767 await contents . createDirectory ( tmpPath ) ;
6868
69+ if ( await contents . fileExists ( "nbgrader_config.py" ) ) {
70+ await contents . deleteFile ( "nbgrader_config.py" ) ;
71+ }
72+ await contents . uploadFile (
73+ path . resolve ( __dirname , "./files/nbgrader_config.py" ) ,
74+ "nbgrader_config.py"
75+ ) ;
76+
6977 if ( ! isWindows ) {
7078 exchange_dir = fs . mkdtempSync (
7179 path . join ( os . tmpdir ( ) , "nbgrader_exchange_test_" )
@@ -77,29 +85,26 @@ test.beforeEach(async ({ request, tmpPath }) => {
7785/*
7886 * delete temp directories at the end of test
7987 */
80- test . afterEach ( async ( { request, tmpPath } ) => {
88+ test . afterEach ( async ( { request, page , tmpPath } ) => {
8189 if ( ! isWindows ) {
8290 fs . rmSync ( exchange_dir , { recursive : true , force : true } ) ;
8391 fs . rmSync ( cache_dir , { recursive : true , force : true } ) ;
8492 }
8593
8694 if ( request === undefined ) throw new Error ( "Request is undefined." ) ;
87- const contents = galata . newContentsHelper ( request ) ;
95+ const contents = galata . newContentsHelper ( request , page ) ;
8896 await contents . deleteDirectory ( tmpPath ) ;
89-
90- if ( await contents . fileExists ( "nbgrader_config.py" ) )
91- contents . deleteFile ( "nbgrader_config.py" ) ;
92- contents . uploadFile (
93- path . resolve ( __dirname , "./files/nbgrader_config.py" ) ,
94- "nbgrader_config.py"
95- ) ;
9697} ) ;
9798
9899/*
99100 * Create a nbgrader file system and modify config
100101 */
101- const addCourses = async ( request : APIRequestContext , tmpPath : string ) => {
102- const contents = galata . newContentsHelper ( request ) ;
102+ const addCourses = async (
103+ request : APIRequestContext ,
104+ page : IJupyterLabPageFixture ,
105+ tmpPath : string
106+ ) => {
107+ const contents = galata . newContentsHelper ( request , page ) ;
103108
104109 // copy files from the user guide
105110 const source = path . resolve (
@@ -235,6 +240,15 @@ test("Open assignment list tab from menu", async ({ page, tmpPath }) => {
235240
236241 if ( isNotebook ) await page . goto ( `tree/${ tmpPath } ` ) ;
237242
243+ // Creating the config file is useful to avoid server error about the exchange
244+ // directory not writable.
245+ // This is not required for the test, only to have cleaner logs.
246+ await createEnv ( testDir , tmpPath , exchange_dir , cache_dir , isWindows ) ;
247+ fs . copyFileSync (
248+ path . resolve ( testDir , "nbgrader_config.py" ) ,
249+ path . resolve ( testDir , tmpPath , "nbgrader_config.py" )
250+ ) ;
251+
238252 const nbgrader_menu = page . locator ( `${ menuPanelId } div.lm-MenuBar-itemLabel:text("Nbgrader")` ) ;
239253 const assignmentList_menu = page . locator (
240254 '#jp-mainmenu-nbgrader li[data-command="nbgrader:open-assignment-list"]'
@@ -277,7 +291,7 @@ test("Show assignment list", async ({ page, request, tmpPath }) => {
277291 if ( isNotebook ) await page . goto ( `tree/${ tmpPath } ` ) ;
278292
279293 await createEnv ( testDir , tmpPath , exchange_dir , cache_dir , isWindows ) ;
280- await addCourses ( request , tmpPath ) ;
294+ await addCourses ( request , page , tmpPath ) ;
281295 await openAssignmentList ( page ) ;
282296
283297 // Wait for DOM of each status
@@ -311,7 +325,7 @@ test("Multiple released assignments", async ({ page, request, tmpPath }) => {
311325 if ( isNotebook ) await page . goto ( `tree/${ tmpPath } ` ) ;
312326
313327 await createEnv ( testDir , tmpPath , exchange_dir , cache_dir , isWindows ) ;
314- await addCourses ( request , tmpPath ) ;
328+ await addCourses ( request , page , tmpPath ) ;
315329 await openAssignmentList ( page ) ;
316330
317331 // release two assignments
@@ -347,7 +361,7 @@ test("Fetch assignments", async ({ page, request, tmpPath }) => {
347361 if ( isNotebook ) await page . goto ( `tree/${ tmpPath } ` ) ;
348362
349363 await createEnv ( testDir , tmpPath , exchange_dir , cache_dir , isWindows ) ;
350- await addCourses ( request , tmpPath ) ;
364+ await addCourses ( request , page , tmpPath ) ;
351365 await openAssignmentList ( page ) ;
352366
353367 // release some assignments
@@ -400,7 +414,7 @@ test("Submit assignments", async ({ page, request, tmpPath }) => {
400414
401415 // create directories and config files, and open assignment_list tab
402416 await createEnv ( testDir , tmpPath , exchange_dir , cache_dir , isWindows ) ;
403- await addCourses ( request , tmpPath ) ;
417+ await addCourses ( request , page , tmpPath ) ;
404418 await openAssignmentList ( page ) ;
405419
406420 // release some assignments
@@ -468,7 +482,7 @@ test("submit assignment missing notebook", async ({
468482
469483 // create directories and config files, and open assignment_list tab
470484 await createEnv ( testDir , tmpPath , exchange_dir , cache_dir , isWindows ) ;
471- await addCourses ( request , tmpPath ) ;
485+ await addCourses ( request , page , tmpPath ) ;
472486 await openAssignmentList ( page ) ;
473487
474488 // release some assignments
@@ -556,7 +570,7 @@ test("Fetch a second assignment", async ({ page, request, tmpPath }) => {
556570 if ( isNotebook ) await page . goto ( `tree/${ tmpPath } ` ) ;
557571
558572 await createEnv ( testDir , tmpPath , exchange_dir , cache_dir , isWindows ) ;
559- await addCourses ( request , tmpPath ) ;
573+ await addCourses ( request , page , tmpPath ) ;
560574 await openAssignmentList ( page ) ;
561575
562576 // release some assignments
@@ -627,7 +641,7 @@ test("Submit another assignments", async ({ page, request, tmpPath }) => {
627641
628642 // create directories and config files, and open assignment_list tab
629643 await createEnv ( testDir , tmpPath , exchange_dir , cache_dir , isWindows ) ;
630- await addCourses ( request , tmpPath ) ;
644+ await addCourses ( request , page , tmpPath ) ;
631645 await openAssignmentList ( page ) ;
632646
633647 // release some assignments
@@ -681,7 +695,7 @@ test("Validate OK", async ({ page, request, tmpPath }) => {
681695
682696 // create directories and config files, and open assignment_list tab
683697 await createEnv ( testDir , tmpPath , exchange_dir , cache_dir , isWindows ) ;
684- await addCourses ( request , tmpPath ) ;
698+ await addCourses ( request , page , tmpPath ) ;
685699 await openAssignmentList ( page ) ;
686700
687701 // release some assignments
@@ -731,7 +745,7 @@ test("Validate failure", async ({ page, request, tmpPath }) => {
731745
732746 // create directories and config files, and open assignment_list tab
733747 await createEnv ( testDir , tmpPath , exchange_dir , cache_dir , isWindows ) ;
734- await addCourses ( request , tmpPath ) ;
748+ await addCourses ( request , page , tmpPath ) ;
735749 await openAssignmentList ( page ) ;
736750
737751 // release some assignments
@@ -785,7 +799,7 @@ test("Missing exchange directory", async ({ page, request, tmpPath }) => {
785799
786800 // create directories and config files
787801 await createEnv ( testDir , tmpPath , exchange_dir , cache_dir , isWindows ) ;
788- await addCourses ( request , tmpPath ) ;
802+ await addCourses ( request , page , tmpPath ) ;
789803
790804 // delete exchange directory
791805 fs . rmSync ( exchange_dir , { recursive : true , force : true } ) ;
0 commit comments