mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Attempt to fix flaky test re: blinking cursor
As shown in #15122, this test sometimes fails in CI with the following error: TextEditorComponent rendering it blinks cursors when the editor is focused and the cursors are not moving Expected '0' to be '1'. at it (C:\projects\atom\spec\text-editor-component-spec.js:414:49) Expected '0' to be '1'. at it (C:\projects\atom\spec\text-editor-component-spec.js:415:49) I *think* this might be a case of overspecification in the test's assertions. Prior to this commit, the test expected the blinking cursor to *start* in the visible state, and then transition to the invisible state. When we see the failure above, I suspect that the cursor has already transitioned from the visible state to the invisible state by the time the assertion runs. Since the test aims to verify that the cursor blinks, it seems like we should focus on the blinking, and not worry about the *initial* state of the cursor. This commit removes the assertions that verify the initial state of the cursor, and instead asserts that the cursor toggles between the visible and the invisible state.
This commit is contained in:
@@ -411,26 +411,28 @@ describe('TextEditorComponent', () => {
|
|||||||
await component.getNextUpdatePromise()
|
await component.getNextUpdatePromise()
|
||||||
const [cursor1, cursor2] = element.querySelectorAll('.cursor')
|
const [cursor1, cursor2] = element.querySelectorAll('.cursor')
|
||||||
|
|
||||||
expect(getComputedStyle(cursor1).opacity).toBe('1')
|
|
||||||
expect(getComputedStyle(cursor2).opacity).toBe('1')
|
|
||||||
|
|
||||||
await conditionPromise(() =>
|
|
||||||
getComputedStyle(cursor1).opacity === '0' && getComputedStyle(cursor2).opacity === '0'
|
|
||||||
)
|
|
||||||
|
|
||||||
await conditionPromise(() =>
|
await conditionPromise(() =>
|
||||||
getComputedStyle(cursor1).opacity === '1' && getComputedStyle(cursor2).opacity === '1'
|
getComputedStyle(cursor1).opacity === '1' && getComputedStyle(cursor2).opacity === '1'
|
||||||
)
|
)
|
||||||
|
|
||||||
await conditionPromise(() =>
|
await conditionPromise(() =>
|
||||||
getComputedStyle(cursor1).opacity === '0' && getComputedStyle(cursor2).opacity === '0'
|
getComputedStyle(cursor1).opacity === '0' && getComputedStyle(cursor2).opacity === '0'
|
||||||
)
|
)
|
||||||
|
await conditionPromise(() =>
|
||||||
|
getComputedStyle(cursor1).opacity === '1' && getComputedStyle(cursor2).opacity === '1'
|
||||||
|
)
|
||||||
|
|
||||||
editor.moveRight()
|
editor.moveRight()
|
||||||
await component.getNextUpdatePromise()
|
await component.getNextUpdatePromise()
|
||||||
|
|
||||||
expect(getComputedStyle(cursor1).opacity).toBe('1')
|
await conditionPromise(() =>
|
||||||
expect(getComputedStyle(cursor2).opacity).toBe('1')
|
getComputedStyle(cursor1).opacity === '0' && getComputedStyle(cursor2).opacity === '0'
|
||||||
|
)
|
||||||
|
await conditionPromise(() =>
|
||||||
|
getComputedStyle(cursor1).opacity === '1' && getComputedStyle(cursor2).opacity === '1'
|
||||||
|
)
|
||||||
|
await conditionPromise(() =>
|
||||||
|
getComputedStyle(cursor1).opacity === '0' && getComputedStyle(cursor2).opacity === '0'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('gives cursors at the end of lines the width of an "x" character', async () => {
|
it('gives cursors at the end of lines the width of an "x" character', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user