From cce3985b4c1385e84a307cfcf788760d52454bd4 Mon Sep 17 00:00:00 2001 From: machty Date: Thu, 20 Jun 2024 13:09:13 -0400 Subject: [PATCH] fix a number of snapshots --- .../language-server/custom-extensions.test.ts | 2 +- .../diagnostic-augmentation.test.ts | 78 +++++----- .../language-server/diagnostics.test.ts | 135 +++++++++--------- test-packages/test-utils/src/project.ts | 1 - 4 files changed, 106 insertions(+), 110 deletions(-) diff --git a/packages/core/__tests__/language-server/custom-extensions.test.ts b/packages/core/__tests__/language-server/custom-extensions.test.ts index 73fded291..e73dd6eaa 100644 --- a/packages/core/__tests__/language-server/custom-extensions.test.ts +++ b/packages/core/__tests__/language-server/custom-extensions.test.ts @@ -36,7 +36,7 @@ describe('Language Server: custom file extensions', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Type 'number' is not assignable to type 'string'.", diff --git a/packages/core/__tests__/language-server/diagnostic-augmentation.test.ts b/packages/core/__tests__/language-server/diagnostic-augmentation.test.ts index 9c47e662b..8ae1cb791 100644 --- a/packages/core/__tests__/language-server/diagnostic-augmentation.test.ts +++ b/packages/core/__tests__/language-server/diagnostic-augmentation.test.ts @@ -87,7 +87,7 @@ describe('Language Server: Diagnostic Augmentation', () => { const { uri } = await server.openTextDocument(gtsUri, 'gts'); const diagnostics = await server.sendDocumentDiagnosticRequest(uri); - expect(diagnostics.reverse()).toMatchInlineSnapshot(` + expect(diagnostics.items.reverse()).toMatchInlineSnapshot(` [ { "code": 0, @@ -154,7 +154,7 @@ describe('Language Server: Diagnostic Augmentation', () => { const { uri } = await server.openTextDocument(project.filePath('index.gts'), 'glimmer-ts'); let diagnostics = await server.sendDocumentDiagnosticRequest(uri); - expect(diagnostics.reverse()).toMatchInlineSnapshot(` + expect(diagnostics.items.reverse()).toMatchInlineSnapshot(` [ { "code": 2554, @@ -163,7 +163,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Expected 2 arguments, but got 1.", @@ -190,7 +190,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "line": 9, }, }, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", }, "message": "An argument for 'b' was not provided.", }, @@ -205,7 +205,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Expected 2 arguments, but got 3.", @@ -229,7 +229,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Expected 2 arguments, but got 3. Note that named args are passed together as a final argument, so they collectively increase the given arg count by 1.", @@ -253,7 +253,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Expected at least 1 arguments, but got 0.", @@ -280,7 +280,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "line": 13, }, }, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", }, "message": "An argument for 'a' was not provided.", }, @@ -295,7 +295,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Expected 2 arguments, but got 1.", @@ -319,7 +319,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Expected 2 arguments, but got 3.", @@ -343,7 +343,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Expected at least 1 arguments, but got 0.", @@ -413,7 +413,7 @@ describe('Language Server: Diagnostic Augmentation', () => { const { uri } = await server.openTextDocument(project.filePath('index.gts'), 'glimmer-ts'); let diagnostics = await server.sendDocumentDiagnosticRequest(uri); - expect(diagnostics.reverse()).toMatchInlineSnapshot(` + expect(diagnostics.items.reverse()).toMatchInlineSnapshot(` [ { "code": 2322, @@ -422,7 +422,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Only primitive values (see \`AttrValue\` in \`@glint/template\`) are assignable as HTML attributes. If you want to set an event listener, consider using the \`{{on}}\` modifier instead. @@ -447,7 +447,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Only primitive values and certain DOM objects (see \`ContentValue\` in \`@glint/template\`) are usable as top-level template content. @@ -472,7 +472,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Only primitive values and certain DOM objects (see \`ContentValue\` in \`@glint/template\`) are usable as top-level template content. @@ -497,7 +497,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Only primitive values and certain DOM objects (see \`ContentValue\` in \`@glint/template\`) are usable as top-level template content. @@ -522,7 +522,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Only primitive values (see \`AttrValue\` in \`@glint/template\`) are assignable as HTML attributes. If you want to set an event listener, consider using the \`{{on}}\` modifier instead. @@ -547,7 +547,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Only primitive values and certain DOM objects (see \`ContentValue\` in \`@glint/template\`) are usable as top-level template content. @@ -572,7 +572,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Only primitive values and certain DOM objects (see \`ContentValue\` in \`@glint/template\`) are usable as top-level template content. @@ -597,7 +597,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Only primitive values and certain DOM objects (see \`ContentValue\` in \`@glint/template\`) are usable as top-level template content. @@ -660,7 +660,7 @@ describe('Language Server: Diagnostic Augmentation', () => { // message: diagnostic.message.slice(0, diagnostic.message.indexOf('\n')), // })); - expect(diagnostics.reverse()).toMatchInlineSnapshot(` + expect(diagnostics.items.reverse()).toMatchInlineSnapshot(` [ { "code": 2769, @@ -669,7 +669,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "The given value does not appear to be usable as a component, modifier or helper. @@ -715,7 +715,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "The given value does not appear to be usable as a component, modifier or helper. @@ -744,7 +744,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "The given value does not appear to be usable as a component, modifier or helper. @@ -773,7 +773,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "The given value does not appear to be usable as a component, modifier or helper. @@ -802,7 +802,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "The given value does not appear to be usable as a component, modifier or helper. @@ -831,7 +831,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "The given value does not appear to be usable as a component, modifier or helper. @@ -860,7 +860,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "The given value does not appear to be usable as a component, modifier or helper. @@ -889,7 +889,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "The given value does not appear to be usable as a component, modifier or helper. @@ -942,7 +942,7 @@ describe('Language Server: Diagnostic Augmentation', () => { let server = await project.startLanguageServer(); let diagnostics = server.getDiagnostics(project.fileURI('index.hbs')); - expect(diagnostics.reverse()).toMatchInlineSnapshot(` + expect(diagnostics.items.reverse()).toMatchInlineSnapshot(` [ { "code": 7053, @@ -1070,7 +1070,7 @@ describe('Language Server: Diagnostic Augmentation', () => { let server = await project.startLanguageServer(); let diagnostics = server.getDiagnostics(project.fileURI('index.hbs')); - expect(diagnostics.reverse()).toMatchInlineSnapshot(` + expect(diagnostics.items.reverse()).toMatchInlineSnapshot(` [ { "code": 2769, @@ -1173,7 +1173,7 @@ describe('Language Server: Diagnostic Augmentation', () => { let server = await project.startLanguageServer(); let diagnostics = server.getDiagnostics(project.fileURI('index.hbs')); - expect(diagnostics.reverse()).toMatchInlineSnapshot(` + expect(diagnostics.items.reverse()).toMatchInlineSnapshot(` [ { "code": 2345, @@ -1275,7 +1275,7 @@ describe('Language Server: Diagnostic Augmentation', () => { const { uri } = await server.openTextDocument(project.filePath('index.gts'), 'glimmer-ts'); let diagnostics = await server.sendDocumentDiagnosticRequest(uri); - expect(diagnostics.reverse()).toMatchInlineSnapshot(` + expect(diagnostics.items.reverse()).toMatchInlineSnapshot(` [ { "code": 2345, @@ -1284,7 +1284,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Argument of type '[{ [NamedArgs]: true; foo: number; }]' is not assignable to parameter of type '[] | [NamedArgs<{ foo: string; }>]'. @@ -1327,7 +1327,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Argument of type '[{ [NamedArgs]: true; foo: number; }]' is not assignable to parameter of type '[] | [NamedArgs<{ foo: string; }>]'. @@ -1370,7 +1370,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Argument of type '[{ [NamedArgs]: true; foo: number; }]' is not assignable to parameter of type '[] | [NamedArgs<{ foo: string; }>]'. @@ -1434,7 +1434,7 @@ describe('Language Server: Diagnostic Augmentation', () => { const { uri } = await server.openTextDocument(project.filePath('index.gts'), 'glimmer-ts'); let diagnostics = await server.sendDocumentDiagnosticRequest(uri); - expect(diagnostics.reverse()).toMatchInlineSnapshot(` + expect(diagnostics.items.reverse()).toMatchInlineSnapshot(` [ { "code": 4111, @@ -1443,7 +1443,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Property 'fooBar' comes from an index signature, so it must be accessed with ['fooBar'].", @@ -1467,7 +1467,7 @@ describe('Language Server: Diagnostic Augmentation', () => { "isFormat": false, "original": {}, "pluginIndex": 0, - "uri": "file:///PATH_TO_EPHEMERAL_TEST_PROJECT/index.gts", + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", "version": 0, }, "message": "Property 'fooBar' comes from an index signature, so it must be accessed with {{get ... 'fooBar'}}.", diff --git a/packages/core/__tests__/language-server/diagnostics.test.ts b/packages/core/__tests__/language-server/diagnostics.test.ts index 250c08881..867315d72 100644 --- a/packages/core/__tests__/language-server/diagnostics.test.ts +++ b/packages/core/__tests__/language-server/diagnostics.test.ts @@ -198,81 +198,78 @@ describe('Language Server: Diagnostics', () => { const { uri } = await server.openTextDocument(gtsUri, 'glimmer-ts'); const diagnostics = await server.sendDocumentDiagnosticRequest(uri); - expect(diagnostics).toMatchInlineSnapshot(` - { - "items": [ - { - "code": 2551, - "data": { - "documentUri": "volar-embedded-content://URI_ENCODED_PATH_TO/FILE", - "isFormat": false, - "original": {}, - "pluginIndex": 0, - "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", - "version": 0, + expect(diagnostics.items.reverse()).toMatchInlineSnapshot(` + [ + { + "code": 6133, + "data": { + "documentUri": "volar-embedded-content://URI_ENCODED_PATH_TO/FILE", + "isFormat": false, + "original": {}, + "pluginIndex": 0, + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", + "version": 0, + }, + "message": "'startupTime' is declared but its value is never read.", + "range": { + "end": { + "character": 21, + "line": 8, }, - "message": "Property 'startupTimee' does not exist on type 'Application'. Did you mean 'startupTime'?", - "range": { - "end": { - "character": 43, - "line": 12, - }, - "start": { - "character": 31, - "line": 12, - }, + "start": { + "character": 10, + "line": 8, }, - "relatedInformation": [ - { - "location": { - "range": { - "end": { - "character": 21, - "line": 8, - }, - "start": { - "character": 10, - "line": 8, - }, - }, - "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", - }, - "message": "'startupTime' is declared here.", - }, - ], - "severity": 1, - "source": "glint", }, - { - "code": 6133, - "data": { - "documentUri": "volar-embedded-content://URI_ENCODED_PATH_TO/FILE", - "isFormat": false, - "original": {}, - "pluginIndex": 0, - "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", - "version": 0, + "severity": 4, + "source": "glint", + "tags": [ + 1, + ], + }, + { + "code": 2551, + "data": { + "documentUri": "volar-embedded-content://URI_ENCODED_PATH_TO/FILE", + "isFormat": false, + "original": {}, + "pluginIndex": 0, + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", + "version": 0, + }, + "message": "Property 'startupTimee' does not exist on type 'Application'. Did you mean 'startupTime'?", + "range": { + "end": { + "character": 43, + "line": 12, }, - "message": "'startupTime' is declared but its value is never read.", - "range": { - "end": { - "character": 21, - "line": 8, - }, - "start": { - "character": 10, - "line": 8, - }, + "start": { + "character": 31, + "line": 12, }, - "severity": 4, - "source": "glint", - "tags": [ - 1, - ], }, - ], - "kind": "full", - } + "relatedInformation": [ + { + "location": { + "range": { + "end": { + "character": 21, + "line": 8, + }, + "start": { + "character": 10, + "line": 8, + }, + }, + "uri": "file:///path/to/EPHEMERAL_TEST_PROJECT/index.gts", + }, + "message": "'startupTime' is declared here.", + }, + ], + "severity": 1, + "source": "glint", + }, + ] `); }); diff --git a/test-packages/test-utils/src/project.ts b/test-packages/test-utils/src/project.ts index 58d412802..b6ab3a529 100644 --- a/test-packages/test-utils/src/project.ts +++ b/test-packages/test-utils/src/project.ts @@ -161,7 +161,6 @@ export class Project { `volar-embedded-content://URI_ENCODED_PATH_TO/FILE` ) .replaceAll(this.filePath('.'), '/path/to/EPHEMERAL_TEST_PROJECT') - .replaceAll(this.fileURI('.'), 'file:///PATH_TO_EPHEMERAL_TEST_PROJECT') .replaceAll(fileUriToTemplatePackage, 'file:///PATH_TO_MODULE/@glint/template'); return JSON.parse(normalized);