1- import * as cp from "child_process"
21import { promises as fs } from "fs"
3- import * as os from "os"
42import * as path from "path"
5- import * as util from "util"
63import { getMaybeProxiedCodeServer } from "../utils/helpers"
74import { describe , test , expect } from "./baseFixture"
85import { CodeServer } from "./models/CodeServer"
@@ -17,30 +14,6 @@ describe("code-server", [], {}, () => {
1714 await Promise . all ( procs . map ( ( cs ) => cs . close ( ) ) )
1815 } )
1916
20- /**
21- * Spawn a specific version of code-server using the install script.
22- */
23- const spawn = async ( version : string , dir ?: string ) : Promise < CodeServer > => {
24- let instance = instances . get ( version )
25- if ( ! instance ) {
26- await util . promisify ( cp . exec ) ( `./install.sh --method standalone --version ${ version } ` , {
27- cwd : path . join ( __dirname , "../.." ) ,
28- } )
29-
30- instance = new CodeServer (
31- "code-server@" + version ,
32- [ "--auth=none" ] ,
33- { VSCODE_DEV : "" } ,
34- dir ,
35- `${ os . homedir ( ) } /.local/lib/code-server-${ version } ` ,
36- )
37-
38- instances . set ( version , instance )
39- }
40-
41- return instance
42- }
43-
4417 test ( "should navigate to home page" , async ( { codeServerPage } ) => {
4518 // We navigate codeServer before each test
4619 // and we start the test with a storage state
@@ -68,54 +41,4 @@ describe("code-server", [], {}, () => {
6841 await fs . writeFile ( file , "bar" )
6942 await codeServerPage . openFile ( file )
7043 } )
71-
72- test ( "should migrate state to avoid collisions" , async ( { codeServerPage } ) => {
73- // This can take a very long time in development because of how long pages
74- // take to load and we are doing a lot of that here.
75- if ( process . env . VSCODE_DEV === "1" ) {
76- test . slow ( )
77- }
78-
79- const dir = await codeServerPage . workspaceDir
80- const files = [ path . join ( dir , "foo" ) , path . join ( dir , "bar" ) ]
81- await Promise . all (
82- files . map ( ( file ) => {
83- return fs . writeFile ( file , path . basename ( file ) )
84- } ) ,
85- )
86-
87- // Open a file in the latest instance.
88- await codeServerPage . openFile ( files [ 0 ] )
89- await codeServerPage . stateFlush ( )
90-
91- // Open a file in an older version of code-server. It should not see the
92- // file opened in the new instance since the database has a different
93- // name. This must be accessed through the proxy so it shares the same
94- // domain and can write to the same database.
95- const cs = await spawn ( "4.0.2" , dir )
96- const address = new URL ( await cs . address ( ) )
97-
98- await codeServerPage . navigate ( "/proxy/" + address . port + "/" )
99- await codeServerPage . openFile ( files [ 1 ] )
100- expect ( await codeServerPage . tabIsVisible ( files [ 0 ] ) ) . toBe ( false )
101- await codeServerPage . stateFlush ( )
102-
103- // Move back to latest code-server. We should see the file we previously
104- // opened with it but not the old code-server file because the new instance
105- // already created its own database on this path and will avoid migrating.
106- await codeServerPage . navigate ( )
107- await codeServerPage . waitForTab ( files [ 0 ] )
108- expect ( await codeServerPage . tabIsVisible ( files [ 1 ] ) ) . toBe ( false )
109-
110- // Open a new path in latest code-server. This one should migrate the
111- // database from old code-server but see nothing from the new database
112- // created on the root.
113- await codeServerPage . navigate ( "/vscode" )
114- await codeServerPage . waitForTab ( files [ 1 ] )
115- expect ( await codeServerPage . tabIsVisible ( files [ 0 ] ) ) . toBe ( false )
116- // Should still be open after a reload.
117- await codeServerPage . navigate ( "/vscode" )
118- await codeServerPage . waitForTab ( files [ 1 ] )
119- expect ( await codeServerPage . tabIsVisible ( files [ 0 ] ) ) . toBe ( false )
120- } )
12144} )
0 commit comments