forked from onivim/oni2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegression3323DiagnosticsTest.re
89 lines (78 loc) · 2.42 KB
/
Regression3323DiagnosticsTest.re
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
open Oni_Core;
open Oni_Model;
open Oni_IntegrationTestLib;
module TS = TextSynchronization;
// Validate that deleting lines with diagnostics does not crash
// Regression test for: https://github.com/onivim/oni2/issues/3323
runTest(
~name=
"Regression3323 - Deleting diagnostics at top of file should not crash",
({input, dispatch, wait, staysTrue, _}) => {
wait(~timeout=30.0, ~name="Exthost is initialized", (state: State.t) =>
Feature_Exthost.isInitialized(state.exthost)
);
// Wait until the extension is activated
// Give some time for the exthost to start
wait(
~timeout=30.0,
~name="Validate the 'oni-dev' extension gets activated",
(state: State.t) =>
List.exists(
id => id == "oni-dev-extension",
state.extensions |> Feature_Extensions.activatedIds,
)
);
let testFilePath = getAssetPath("some-test-file.txt");
// Create a buffer
dispatch(
Actions.OpenFileByPath(testFilePath, SplitDirection.Current, None),
);
wait(~timeout=30.0, ~name="Validate buffer is loaded", (state: State.t) => {
Selectors.getActiveBuffer(state)
|> Utility.OptionEx.flatMap(buffer => {
buffer
|> Buffer.rawLine(EditorCoreTypes.LineNumber.zero)
|> Option.map(String.equal("abc"))
})
|> Option.value(~default=false)
});
// Set diagnostics from extension host
dispatch(
Actions.Extensions(
Feature_Extensions.Msg.command(
~command="developer.oni.diagnostics-add",
~arguments=[],
),
),
);
wait(
~timeout=30.0,
~name="Diagnostics get set",
(state: State.t) => {
let count =
state
|> Selectors.getActiveBuffer
|> Option.map(
Feature_Diagnostics.getDiagnostics(state.diagnostics),
)
|> Option.map(List.length)
|> Option.value(~default=0);
count > 0;
},
);
// Delete all lines
input("ggdG");
staysTrue(~name="Validate survives multiple renders", ~timeout=5., _state =>
true
);
// With #3323 - the rendering will crash before making it here...
// Once formatting fix is in - update this:
// Validate buffer gets updated everywhere
// TS.validateTextIsSynchronized(
// ~expectedText=Some(""),
// ~description="after formatting",
// dispatch,
// wait,
// );
},
);