From a33c782c1085f3f4dcb94ab2425dd4bf9521ee59 Mon Sep 17 00:00:00 2001 From: "Lyu, Wei Da" Date: Mon, 23 Dec 2024 12:41:38 +0800 Subject: [PATCH] two more cases tracked it in git so we can reenable it later --- .../test/plugins/typescript/service.test.ts | 103 +++++++++++++----- 1 file changed, 77 insertions(+), 26 deletions(-) diff --git a/packages/language-server/test/plugins/typescript/service.test.ts b/packages/language-server/test/plugins/typescript/service.test.ts index 18d2b15c0..656de8b5d 100644 --- a/packages/language-server/test/plugins/typescript/service.test.ts +++ b/packages/language-server/test/plugins/typescript/service.test.ts @@ -332,57 +332,108 @@ describe('service', () => { ls.getService(); }); - it.only('do not throw when lang="ts" is nuke while a new files is added', async () => { + it.skip('do not throw when ScriptKind changes before new service is created', async () => { // testing this because the patch rely on ts implementation details // and we want to be aware of the changes const dirPath = getRandomVirtualDirPath(testDir); const { virtualSystem, lsDocumentContext, rootUris } = setup(); + const package1Path = path.join(dirPath, 'package1'); + const package2Path = path.join(dirPath, 'package2'); virtualSystem.writeFile( - path.join(dirPath, 'tsconfig.json'), + path.join(package1Path, 'tsconfig.json'), JSON.stringify({ compilerOptions: { - module: 'NodeNext', - moduleResolution: 'NodeNext' + allowJs: true } }) ); virtualSystem.writeFile( - path.join(dirPath, 'random.svelte'), - '' + path.join(package2Path, 'tsconfig.json'), + JSON.stringify({ + compilerOptions: { + allowJs: true + } + }) ); + + const usagePath = path.join(package1Path, 'usage.svelte'); virtualSystem.writeFile( - path.join(dirPath, 'random2.svelte'), - '' + usagePath, + '' ); - const ls = await getService( - path.join(dirPath, 'random.svelte'), - rootUris, - lsDocumentContext + const libraryPath = path.join(package2Path, 'Library.svelte'); + virtualSystem.writeFile(libraryPath, ''); + + const lsLibrary = await getService(libraryPath, rootUris, lsDocumentContext); + lsLibrary.getService(); + + const documentLibrary = new Document( + pathToUrl(libraryPath), + virtualSystem.readFile(libraryPath)! ); + documentLibrary.openedByClient = true; + documentLibrary.update(' ', 0, documentLibrary.getTextLength()); + lsLibrary.updateSnapshot(documentLibrary); + - const document = new Document(pathToUrl(path.join(dirPath, 'random.svelte')), ''); - document.openedByClient = true; - ls.updateSnapshot(document); + const lsUsage = await getService(usagePath, rootUris, lsDocumentContext); + lsUsage.getService(); + }); - const document2 = new Document( - pathToUrl(path.join(dirPath, 'random2.svelte')), - virtualSystem.readFile(path.join(dirPath, 'random2.svelte'))! + it.skip('do not throw when ScriptKind changes referenced service is updated', async () => { + // testing this because the patch rely on ts implementation details + // and we want to be aware of the changes + + const dirPath = getRandomVirtualDirPath(testDir); + const { virtualSystem, lsDocumentContext, rootUris } = setup(); + const package1Path = path.join(dirPath, 'package1'); + const package2Path = path.join(dirPath, 'package2'); + + virtualSystem.writeFile( + path.join(package1Path, 'tsconfig.json'), + JSON.stringify({ + compilerOptions: { + allowJs: true + } + }) ); - document.openedByClient = true; - ls.updateSnapshot(document2); - const lang = ls.getService(); - lang.getProgram(); + virtualSystem.writeFile( + path.join(package2Path, 'tsconfig.json'), + JSON.stringify({ + compilerOptions: { + allowJs: true + } + }) + ); - document2.update(' ', 0, document2.getTextLength()); - ls.updateSnapshot(document2); - ls.openVirtualDocument(new Document(pathToUrl(path.join(dirPath, 'random3.svelte')), '')); + const usagePath = path.join(package1Path, 'usage.svelte'); + virtualSystem.writeFile( + usagePath, + '' + ); - lang.getProgram(); + const libraryPath = path.join(package2Path, 'Library.svelte'); + virtualSystem.writeFile(libraryPath, ''); + + const lsLibrary = await getService(libraryPath, rootUris, lsDocumentContext); + lsLibrary.getService().getProgram(); + const lsUsage = await getService(usagePath, rootUris, lsDocumentContext); + lsUsage.getService(); + + const documentLibrary = new Document( + pathToUrl(libraryPath), + virtualSystem.readFile(libraryPath)! + ); + documentLibrary.openedByClient = true; + documentLibrary.update(' ', 0, documentLibrary.getTextLength()); + lsLibrary.updateSnapshot(documentLibrary); + + lsLibrary.getService(); }); function createReloadTester(