|
19 | 19 | * |
20 | 20 | */ |
21 | 21 |
|
22 | | -/*global describe, it, beforeAll, afterAll*/ |
| 22 | +/*global describe, it, beforeAll, afterAll, beforeEach*/ |
23 | 23 |
|
24 | 24 | define(function (require, exports, module) { |
25 | 25 |
|
26 | 26 |
|
27 | 27 | var SpecRunnerUtils = require("spec/SpecRunnerUtils"); |
28 | 28 |
|
29 | | - describe("integration:ColorPreview in gutter", function () { |
| 29 | + describe("integration:ColorPreview in gutter - needs focus", function () { |
30 | 30 | const testRootSpec = "/spec/CSSColorPreview-test-files/"; |
31 | 31 | const GUTTER_NAME = "CodeMirror-colorGutter", |
32 | 32 | SINGLE_COLOR_PREVIEW_CLASS = "ico-cssColorPreview", |
@@ -55,6 +55,10 @@ define(function (require, exports, module) { |
55 | 55 | await SpecRunnerUtils.closeTestWindow(); |
56 | 56 | }, 30000); |
57 | 57 |
|
| 58 | + beforeEach(async function () { |
| 59 | + await __PR.closeAll(); |
| 60 | + }); |
| 61 | + |
58 | 62 | it("should color gutter not appear in cpp files", async function () { |
59 | 63 | const fileName = "a.cpp"; |
60 | 64 | await __PR.writeTextFile(fileName, "#include <iostream>", true); |
@@ -204,16 +208,24 @@ define(function (require, exports, module) { |
204 | 208 | const editor = await init(); |
205 | 209 | await __PR.execCommand(__PR.Commands.EDIT_BEAUTIFY_CODE); |
206 | 210 | if(baseFileName === "base.css"){ |
207 | | - await __PR.awaitsFor(()=>{ |
208 | | - return editor.getLine(0) === ".class-one {"; |
209 | | - }, "for beautify complete"); |
| 211 | + await __PR.awaitsFor(async ()=>{ |
| 212 | + if(editor.getLine(0) !== ".class-one {"){ |
| 213 | + await __PR.execCommand(__PR.Commands.EDIT_BEAUTIFY_CODE); |
| 214 | + return false; |
| 215 | + } |
| 216 | + return true; |
| 217 | + }, "for beautify complete", 2000, 50); |
210 | 218 | _verifyExpectedColors(editor, [8, 12, 15, 18, 21, 24]); |
211 | 219 | await __PR.closeFile(); |
212 | 220 | return; |
213 | 221 | } |
214 | | - await __PR.awaitsFor(()=>{ |
215 | | - return editor.getLine(2) === " <head>"; |
216 | | - }, "for beautify complete"); |
| 222 | + await __PR.awaitsFor(async ()=>{ |
| 223 | + if(editor.getLine(2) !== " <head>"){ |
| 224 | + await __PR.execCommand(__PR.Commands.EDIT_BEAUTIFY_CODE); |
| 225 | + return false; |
| 226 | + } |
| 227 | + return true; |
| 228 | + }, "for beautify complete", 2000, 50); |
217 | 229 | _verifyExpectedColors(editor, [8, 12, 13, 14, 15, 16]); |
218 | 230 | await __PR.closeFile(); |
219 | 231 | }); |
@@ -250,6 +262,29 @@ define(function (require, exports, module) { |
250 | 262 | await __PR.closeFile(); |
251 | 263 | }); |
252 | 264 |
|
| 265 | + it(`should color gutter track correct line numbers after deleting lines in ${fileName}`, async function () { |
| 266 | + const editor = await init(); |
| 267 | + validateMultipleColors(editor, 12, ["#00ff8c", "red"]); |
| 268 | + |
| 269 | + __PR.setCursors(["6:1-10:2"]); |
| 270 | + __PR.keydown(["BACK_SPACE"]); // this will delete the selected lines |
| 271 | + |
| 272 | + // now the color gutter should account for the missing lines |
| 273 | + let gutterMarker = editor.getGutterMarker(11, GUTTER_NAME); |
| 274 | + const individualColors = $(gutterMarker).find(".color-box"); |
| 275 | + individualColors[0].click(); |
| 276 | + await __PR.awaitsFor(()=>{ |
| 277 | + return __PR.$(".CodeMirror-linewidget").length === 1 && |
| 278 | + areColorsEqual(__PR.$(".CodeMirror-linewidget").find(".original-color")[0], "#ff0090"); |
| 279 | + }, "quick edit to color #ff0090 appear"); |
| 280 | + individualColors[2].click(); |
| 281 | + await __PR.awaitsFor(()=>{ |
| 282 | + return __PR.$(".CodeMirror-linewidget").length === 1 && |
| 283 | + areColorsEqual(__PR.$(".CodeMirror-linewidget").find(".original-color")[0], "#954e3e"); |
| 284 | + }, "quick edit to color #954e3e appear"); |
| 285 | + await __PR.closeFile(); |
| 286 | + }); |
| 287 | + |
253 | 288 | it(`should update colors on typing ${fileName}`, async function () { |
254 | 289 | const editor = await init(); |
255 | 290 | validateSingleColor(editor, 8, "blue"); |
|
0 commit comments