Skip to content

Commit 3e2558c

Browse files
committed
fix: integ test failures
1 parent 1b330a3 commit 3e2558c

File tree

4 files changed

+49
-42
lines changed

4 files changed

+49
-42
lines changed

src/extensions/default/QuickView/unittests.js

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,15 @@ define(function (require, exports, module) {
8686
return QuickView._queryPreviewProviders(editor, pos, token);
8787
}
8888

89-
async function expectNoPreviewAtPos(line, ch) {
89+
async function expectNoColorOrImagePreviewAtPos(line, ch) {
9090
var popoverInfo = await getPopoverAtPos(line, ch);
91-
expect(popoverInfo).toBeFalsy();
91+
if(popoverInfo){
92+
let quickViews = popoverInfo.content.find(".quick-view-item").length;
93+
if(popoverInfo.content.find(".code-inspection-item").length){
94+
quickViews -= popoverInfo.content.find(".code-inspection-item").length;
95+
}
96+
expect(quickViews).toBe(0);
97+
}
9298
}
9399

94100
async function checkColorAtPos(expectedColor, line, ch) {
@@ -128,8 +134,8 @@ define(function (require, exports, module) {
128134
});
129135

130136
it("should NOT show preview of color on words start with #",async function () {
131-
await expectNoPreviewAtPos(7, 7); // cursor on #invalid_hex
132-
await expectNoPreviewAtPos(8, 15); // cursor on #web
137+
await expectNoColorOrImagePreviewAtPos(7, 7); // cursor on #invalid_hex
138+
await expectNoColorOrImagePreviewAtPos(8, 15); // cursor on #web
133139
});
134140

135141
it("should show preview of valid rgb/rgba colors",async function () {
@@ -149,9 +155,9 @@ define(function (require, exports, module) {
149155
});
150156

151157
it("should NOT show preview of unsupported rgb/rgba colors",async function () {
152-
await expectNoPreviewAtPos(25, 14); // cursor on rgb(300, 0, 0)
153-
await expectNoPreviewAtPos(26, 15); // cursor on rgb(0, 95.5, 0)
154-
await expectNoPreviewAtPos(27, 15); // cursor on rgba(-0, 0, 0, 0.5)
158+
await expectNoColorOrImagePreviewAtPos(25, 14); // cursor on rgb(300, 0, 0)
159+
await expectNoColorOrImagePreviewAtPos(26, 15); // cursor on rgb(0, 95.5, 0)
160+
await expectNoColorOrImagePreviewAtPos(27, 15); // cursor on rgba(-0, 0, 0, 0.5)
155161
});
156162

157163
it("should show preview of valid hsl/hsla colors",async function () {
@@ -162,9 +168,9 @@ define(function (require, exports, module) {
162168
});
163169

164170
it("should NOT show preview of unsupported hsl/hsla colors",async function () {
165-
await expectNoPreviewAtPos(38, 14); // cursor on hsla(90, 100%, 50%, 2)
166-
await expectNoPreviewAtPos(39, 14); // cursor on hsla(0, 200%, 50%, 0.5)
167-
await expectNoPreviewAtPos(40, 14); // cursor on hsla(0.0, 100%, 50%, .5)
171+
await expectNoColorOrImagePreviewAtPos(38, 14); // cursor on hsla(90, 100%, 50%, 2)
172+
await expectNoColorOrImagePreviewAtPos(39, 14); // cursor on hsla(0, 200%, 50%, 0.5)
173+
await expectNoColorOrImagePreviewAtPos(40, 14); // cursor on hsla(0.0, 100%, 50%, .5)
168174
});
169175

170176
it("should show preview of colors with valid names", async function () {
@@ -179,10 +185,10 @@ define(function (require, exports, module) {
179185
});
180186

181187
it("should NOT show preview of colors with invalid names", async function () {
182-
await expectNoPreviewAtPos(72, 15); // cursor on redsox
183-
await expectNoPreviewAtPos(73, 16); // cursor on pinky
184-
await expectNoPreviewAtPos(74, 16); // cursor on blue in hyphenated word blue-cheese
185-
await expectNoPreviewAtPos(75, 18); // cursor on white in hyphenated word @bc-bg-highlight
188+
await expectNoColorOrImagePreviewAtPos(72, 15); // cursor on redsox
189+
await expectNoColorOrImagePreviewAtPos(73, 16); // cursor on pinky
190+
await expectNoColorOrImagePreviewAtPos(74, 16); // cursor on blue in hyphenated word blue-cheese
191+
await expectNoColorOrImagePreviewAtPos(75, 18); // cursor on white in hyphenated word @bc-bg-highlight
186192
});
187193

188194
it("should open quick edit if clicked on colorview",async function () {
@@ -198,16 +204,16 @@ define(function (require, exports, module) {
198204
testFile = "test.js";
199205

200206
it("should NOT show preview of color-named functions and object/array keys", async function () {
201-
await expectNoPreviewAtPos(2, 12); // cursor on green()
202-
await expectNoPreviewAtPos(4, 22); // cursor on Math.tan
203-
await expectNoPreviewAtPos(5, 14); // cursor on tan()
204-
await expectNoPreviewAtPos(5, 38); // cursor on array[red]
207+
await expectNoColorOrImagePreviewAtPos(2, 12); // cursor on green()
208+
await expectNoColorOrImagePreviewAtPos(4, 22); // cursor on Math.tan
209+
await expectNoColorOrImagePreviewAtPos(5, 14); // cursor on tan()
210+
await expectNoColorOrImagePreviewAtPos(5, 38); // cursor on array[red]
205211
});
206212
it("should not show preview of literal color names", async function () {
207-
await expectNoPreviewAtPos(2, 36); // green
208-
await expectNoPreviewAtPos(3, 21); // green
209-
await expectNoPreviewAtPos(5, 25); // red
210-
await expectNoPreviewAtPos(7, 1); // darkgray
213+
await expectNoColorOrImagePreviewAtPos(2, 36); // green
214+
await expectNoColorOrImagePreviewAtPos(3, 21); // green
215+
await expectNoColorOrImagePreviewAtPos(5, 25); // red
216+
await expectNoColorOrImagePreviewAtPos(7, 1); // darkgray
211217
});
212218
});
213219
});
@@ -313,8 +319,8 @@ define(function (require, exports, module) {
313319

314320
it("Should not go into infinite loop on unbalanced parens", async function () {
315321
// no preview, and no infinite loop
316-
await expectNoPreviewAtPos(189, 30);
317-
await expectNoPreviewAtPos(190, 40);
322+
await expectNoColorOrImagePreviewAtPos(189, 30);
323+
await expectNoColorOrImagePreviewAtPos(190, 40);
318324
});
319325
});
320326

@@ -417,19 +423,19 @@ define(function (require, exports, module) {
417423
});
418424

419425
it("Should ignore URLs for common non-image extensions", async function () {
420-
await expectNoPreviewAtPos(209, 20); // .html
421-
await expectNoPreviewAtPos(210, 20); // .css
422-
await expectNoPreviewAtPos(211, 20); // .js
423-
await expectNoPreviewAtPos(212, 20); // .json
424-
await expectNoPreviewAtPos(213, 20); // .md
425-
await expectNoPreviewAtPos(214, 20); // .xml
426-
await expectNoPreviewAtPos(215, 20); // .mp3
427-
await expectNoPreviewAtPos(216, 20); // .ogv
428-
await expectNoPreviewAtPos(217, 20); // .mp4
429-
await expectNoPreviewAtPos(218, 20); // .mpeg
430-
await expectNoPreviewAtPos(219, 20); // .webm
431-
await expectNoPreviewAtPos(220, 20); // .zip
432-
await expectNoPreviewAtPos(221, 20); // .tgz
426+
await expectNoColorOrImagePreviewAtPos(209, 20); // .html
427+
await expectNoColorOrImagePreviewAtPos(210, 20); // .css
428+
await expectNoColorOrImagePreviewAtPos(211, 20); // .js
429+
await expectNoColorOrImagePreviewAtPos(212, 20); // .json
430+
await expectNoColorOrImagePreviewAtPos(213, 20); // .md
431+
await expectNoColorOrImagePreviewAtPos(214, 20); // .xml
432+
await expectNoColorOrImagePreviewAtPos(215, 20); // .mp3
433+
await expectNoColorOrImagePreviewAtPos(216, 20); // .ogv
434+
await expectNoColorOrImagePreviewAtPos(217, 20); // .mp4
435+
await expectNoColorOrImagePreviewAtPos(218, 20); // .mpeg
436+
await expectNoColorOrImagePreviewAtPos(219, 20); // .webm
437+
await expectNoColorOrImagePreviewAtPos(220, 20); // .zip
438+
await expectNoColorOrImagePreviewAtPos(221, 20); // .tgz
433439
});
434440

435441
it("Should show image preview for a data URI inside url()", async function () {

src/features/QuickViewManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,9 @@ define(function (require, exports, module) {
374374
if(result.editsDoc){
375375
popover.editsDoc = true;
376376
}
377-
let cssClass = `class='quick-view-partition'`;
377+
let cssClass = `class='quick-view-partition quick-view-item'`;
378378
if(i === (popoverResults.length - 1)) {
379-
cssClass = "";
379+
cssClass = "class='quick-view-item'";
380380
}
381381
popover.content.append($(`<div ${cssClass} ></div>`).append(result.content));
382382
}

src/language/CodeInspection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ define(function (require, exports, module) {
504504
resolve({
505505
start: {line: pos.line, ch: token.start},
506506
end: {line: pos.line, ch: token.end},
507-
content: hoverMessage
507+
content: `<div class="code-inspection-item">${hoverMessage}</div>`
508508
});
509509
return;
510510
}

test/spec/Editor-test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,7 +2083,8 @@ define(function (require, exports, module) {
20832083
describe("Gutter APIs", function () {
20842084
var leftGutter = "left",
20852085
rightGutter = "right",
2086-
lineNumberGutter = "CodeMirror-linenumbers";
2086+
lineNumberGutter = "CodeMirror-linenumbers",
2087+
codeInspectionGutter = "code-inspection-gutter";
20872088

20882089
beforeEach(function () {
20892090
createTestEditor("hello\nworld\nyo", "javascript");
@@ -2109,7 +2110,7 @@ define(function (require, exports, module) {
21092110
return gutter.name;
21102111
});
21112112
expect(gutters).toEqual(expectedGutters);
2112-
expect(registeredGutters).toEqual(expectedGutters);
2113+
expect(registeredGutters).toEqual([...expectedGutters, codeInspectionGutter]);
21132114
});
21142115

21152116
it("should isGutterRegistered work on multiple gutters", function () {

0 commit comments

Comments
 (0)