summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2024-10-16 22:43:26 +0100
committerGitHub <noreply@github.com>2024-10-16 22:43:26 +0100
commit72dd74d83a89d3db17e6ed5d0b8c7f4ba3f3d233 (patch)
treec2344262cbfdb824eacd712744cc805c6e96321c /tests/integration
parentf8417224eb9cbc2e4ae134ae197670a0bc53df2e (diff)
Reland feat(lsp): deno/didRefreshDenoConfigurationTree notifications (#26325)
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/lsp_tests.rs195
1 files changed, 190 insertions, 5 deletions
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs
index 0f2d43755..85e02041e 100644
--- a/tests/integration/lsp_tests.rs
+++ b/tests/integration/lsp_tests.rs
@@ -1050,6 +1050,191 @@ fn lsp_workspace_enable_paths_no_workspace_configuration() {
}
#[test]
+fn lsp_did_refresh_deno_configuration_tree_notification() {
+ let context = TestContextBuilder::new().use_temp_cwd().build();
+ let temp_dir = context.temp_dir();
+ temp_dir.create_dir_all("workspace/member1");
+ temp_dir.create_dir_all("workspace/member2");
+ temp_dir.create_dir_all("non_workspace1");
+ temp_dir.create_dir_all("non_workspace2");
+ temp_dir.write(
+ "workspace/deno.json",
+ json!({
+ "workspace": [
+ "member1",
+ "member2",
+ ],
+ })
+ .to_string(),
+ );
+ temp_dir.write("workspace/member1/deno.json", json!({}).to_string());
+ temp_dir.write("workspace/member1/package.json", json!({}).to_string());
+ temp_dir.write("workspace/member2/package.json", json!({}).to_string());
+ temp_dir.write("non_workspace1/deno.json", json!({}).to_string());
+ let mut client = context.new_lsp_command().build();
+ client.initialize_default();
+ let res = client
+ .read_notification_with_method::<Value>(
+ "deno/didRefreshDenoConfigurationTree",
+ )
+ .unwrap();
+ assert_eq!(
+ res,
+ json!({
+ "data": [
+ {
+ "scopeUri": temp_dir.url().join("non_workspace1/").unwrap(),
+ "workspaceRootScopeUri": null,
+ "denoJson": {
+ "uri": temp_dir.url().join("non_workspace1/deno.json").unwrap(),
+ },
+ "packageJson": null,
+ },
+ {
+ "scopeUri": temp_dir.url().join("workspace/").unwrap(),
+ "workspaceRootScopeUri": null,
+ "denoJson": {
+ "uri": temp_dir.url().join("workspace/deno.json").unwrap(),
+ },
+ "packageJson": null,
+ },
+ {
+ "scopeUri": temp_dir.url().join("workspace/member1/").unwrap(),
+ "workspaceRootScopeUri": temp_dir.url().join("workspace/").unwrap(),
+ "denoJson": {
+ "uri": temp_dir.url().join("workspace/member1/deno.json").unwrap(),
+ },
+ "packageJson": {
+ "uri": temp_dir.url().join("workspace/member1/package.json").unwrap(),
+ },
+ },
+ {
+ "scopeUri": temp_dir.url().join("workspace/member2/").unwrap(),
+ "workspaceRootScopeUri": temp_dir.url().join("workspace/").unwrap(),
+ "denoJson": null,
+ "packageJson": {
+ "uri": temp_dir.url().join("workspace/member2/package.json").unwrap(),
+ },
+ },
+ ],
+ }),
+ );
+ temp_dir.write("non_workspace2/deno.json", json!({}).to_string());
+ client.did_change_watched_files(json!({
+ "changes": [{
+ "uri": temp_dir.url().join("non_workspace2/deno.json").unwrap(),
+ "type": 1,
+ }],
+ }));
+ let res = client
+ .read_notification_with_method::<Value>(
+ "deno/didRefreshDenoConfigurationTree",
+ )
+ .unwrap();
+ assert_eq!(
+ res,
+ json!({
+ "data": [
+ {
+ "scopeUri": temp_dir.url().join("non_workspace1/").unwrap(),
+ "workspaceRootScopeUri": null,
+ "denoJson": {
+ "uri": temp_dir.url().join("non_workspace1/deno.json").unwrap(),
+ },
+ "packageJson": null,
+ },
+ {
+ "scopeUri": temp_dir.url().join("non_workspace2/").unwrap(),
+ "workspaceRootScopeUri": null,
+ "denoJson": {
+ "uri": temp_dir.url().join("non_workspace2/deno.json").unwrap(),
+ },
+ "packageJson": null,
+ },
+ {
+ "scopeUri": temp_dir.url().join("workspace/").unwrap(),
+ "workspaceRootScopeUri": null,
+ "denoJson": {
+ "uri": temp_dir.url().join("workspace/deno.json").unwrap(),
+ },
+ "packageJson": null,
+ },
+ {
+ "scopeUri": temp_dir.url().join("workspace/member1/").unwrap(),
+ "workspaceRootScopeUri": temp_dir.url().join("workspace/").unwrap(),
+ "denoJson": {
+ "uri": temp_dir.url().join("workspace/member1/deno.json").unwrap(),
+ },
+ "packageJson": {
+ "uri": temp_dir.url().join("workspace/member1/package.json").unwrap(),
+ },
+ },
+ {
+ "scopeUri": temp_dir.url().join("workspace/member2/").unwrap(),
+ "workspaceRootScopeUri": temp_dir.url().join("workspace/").unwrap(),
+ "denoJson": null,
+ "packageJson": {
+ "uri": temp_dir.url().join("workspace/member2/package.json").unwrap(),
+ },
+ },
+ ],
+ }),
+ );
+ client.change_configuration(json!({
+ "deno": {
+ "disablePaths": ["non_workspace1"],
+ },
+ }));
+ let res = client
+ .read_notification_with_method::<Value>(
+ "deno/didRefreshDenoConfigurationTree",
+ )
+ .unwrap();
+ assert_eq!(
+ res,
+ json!({
+ "data": [
+ {
+ "scopeUri": temp_dir.url().join("non_workspace2/").unwrap(),
+ "workspaceRootScopeUri": null,
+ "denoJson": {
+ "uri": temp_dir.url().join("non_workspace2/deno.json").unwrap(),
+ },
+ "packageJson": null,
+ },
+ {
+ "scopeUri": temp_dir.url().join("workspace/").unwrap(),
+ "workspaceRootScopeUri": null,
+ "denoJson": {
+ "uri": temp_dir.url().join("workspace/deno.json").unwrap(),
+ },
+ "packageJson": null,
+ },
+ {
+ "scopeUri": temp_dir.url().join("workspace/member1/").unwrap(),
+ "workspaceRootScopeUri": temp_dir.url().join("workspace/").unwrap(),
+ "denoJson": {
+ "uri": temp_dir.url().join("workspace/member1/deno.json").unwrap(),
+ },
+ "packageJson": {
+ "uri": temp_dir.url().join("workspace/member1/package.json").unwrap(),
+ },
+ },
+ {
+ "scopeUri": temp_dir.url().join("workspace/member2/").unwrap(),
+ "workspaceRootScopeUri": temp_dir.url().join("workspace/").unwrap(),
+ "denoJson": null,
+ "packageJson": {
+ "uri": temp_dir.url().join("workspace/member2/package.json").unwrap(),
+ },
+ },
+ ],
+ }),
+ );
+ client.shutdown();
+}
+
+#[test]
fn lsp_did_change_deno_configuration_notification() {
let context = TestContextBuilder::new().use_temp_cwd().build();
let temp_dir = context.temp_dir();
@@ -9403,14 +9588,15 @@ fn lsp_auto_discover_registry() {
"triggerCharacter": "@"
}),
);
- let (method, res) = client.read_notification();
- assert_eq!(method, "deno/registryState");
+ let res = client
+ .read_notification_with_method::<Value>("deno/registryState")
+ .unwrap();
assert_eq!(
res,
- Some(json!({
+ json!({
"origin": "http://localhost:4545",
"suggestions": true,
- }))
+ }),
);
client.shutdown();
}
@@ -10117,7 +10303,6 @@ fn lsp_diagnostics_refresh_dependents() {
assert_eq!(json!(diagnostics.all()), json!([])); // no diagnostics now
client.shutdown();
- assert_eq!(client.queue_len(), 0);
}
// Regression test for https://github.com/denoland/deno/issues/10897.