This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 407
Correct remaining flapping test coverage #1903
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -610,9 +610,6 @@ export default class Present extends State { | |
| const bundle = await this.git().getStatusBundle(); | ||
| const results = await this.formatChangedFiles(bundle); | ||
| results.branch = bundle.branch; | ||
| if (!results.branch.aheadBehind) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is unused, I take it? good catch.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup! |
||
| results.branch.aheadBehind = {ahead: null, behind: null}; | ||
| } | ||
| return results; | ||
| } catch (err) { | ||
| if (err instanceof LargeRepoError) { | ||
|
|
@@ -855,7 +852,7 @@ export default class Present extends State { | |
| // Direct blob access | ||
|
|
||
| getBlobContents(sha) { | ||
| return this.cache.getOrSet(Keys.blob(sha), () => { | ||
| return this.cache.getOrSet(Keys.blob.oneWith(sha), () => { | ||
| return this.git().getBlobContents(sha); | ||
| }); | ||
| } | ||
|
|
@@ -876,6 +873,7 @@ export default class Present extends State { | |
|
|
||
| // Cache | ||
|
|
||
| /* istanbul ignore next */ | ||
| getCache() { | ||
| return this.cache; | ||
| } | ||
|
|
@@ -974,6 +972,7 @@ class Cache { | |
| this.didUpdate(); | ||
| } | ||
|
|
||
| /* istanbul ignore next */ | ||
| [Symbol.iterator]() { | ||
| return this.storage[Symbol.iterator](); | ||
| } | ||
|
|
@@ -988,6 +987,7 @@ class Cache { | |
| this.emitter.emit('did-update'); | ||
| } | ||
|
|
||
| /* istanbul ignore next */ | ||
| onDidUpdate(callback) { | ||
| return this.emitter.on('did-update', callback); | ||
| } | ||
|
|
@@ -1025,6 +1025,7 @@ class CacheKey { | |
| } | ||
| } | ||
|
|
||
| /* istanbul ignore next */ | ||
| toString() { | ||
| return `CacheKey(${this.primary})`; | ||
| } | ||
|
|
@@ -1041,6 +1042,7 @@ class GroupKey { | |
| } | ||
| } | ||
|
|
||
| /* istanbul ignore next */ | ||
| toString() { | ||
| return `GroupKey(${this.group})`; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -166,6 +166,49 @@ describe('EditorConflictController', function() { | |
| assert.strictEqual(conflicts[2].getChosenSide(), conflicts[2].getSide(THEIRS)); | ||
| }); | ||
|
|
||
| it('resolves multiple conflicts as "ours"', function() { | ||
| assert.isFalse(conflicts[0].isResolved()); | ||
| assert.isFalse(conflicts[1].isResolved()); | ||
| assert.isFalse(conflicts[2].isResolved()); | ||
|
|
||
| editor.setCursorBufferPosition([8, 3]); // On "Your changes" | ||
| editor.addCursorAtBufferPosition([11, 2]); // On "Text in between 0 and 1." | ||
| editor.addCursorAtBufferPosition([14, 5]); // On "My middle changes" | ||
| editor.addCursorAtBufferPosition([15, 0]); // On "=======" | ||
| commandRegistry.dispatch(editorView, 'github:resolve-as-ours'); | ||
|
|
||
| assert.isTrue(conflicts[0].isResolved()); | ||
| assert.strictEqual(conflicts[0].getChosenSide(), conflicts[0].getSide(OURS)); | ||
| assert.deepEqual(conflicts[0].getUnchosenSides(), [conflicts[0].getSide(THEIRS)]); | ||
|
|
||
| assert.isTrue(conflicts[1].isResolved()); | ||
| assert.strictEqual(conflicts[1].getChosenSide(), conflicts[1].getSide(OURS)); | ||
| assert.deepEqual(conflicts[1].getUnchosenSides(), [conflicts[1].getSide(THEIRS)]); | ||
|
|
||
| assert.isFalse(conflicts[2].isResolved()); | ||
| }); | ||
|
|
||
| it('resolves multiple conflicts as "theirs"', function() { | ||
| assert.isFalse(conflicts[0].isResolved()); | ||
| assert.isFalse(conflicts[1].isResolved()); | ||
| assert.isFalse(conflicts[2].isResolved()); | ||
|
|
||
| editor.setCursorBufferPosition([8, 3]); // On "Your changes" | ||
| editor.addCursorAtBufferPosition([11, 2]); // On "Text in between 0 and 1." | ||
| editor.addCursorAtBufferPosition([22, 5]); // On "More of my changes" | ||
| commandRegistry.dispatch(editorView, 'github:resolve-as-theirs'); | ||
|
|
||
| assert.isTrue(conflicts[0].isResolved()); | ||
| assert.strictEqual(conflicts[0].getChosenSide(), conflicts[0].getSide(THEIRS)); | ||
| assert.deepEqual(conflicts[0].getUnchosenSides(), [conflicts[0].getSide(OURS)]); | ||
|
|
||
| assert.isFalse(conflicts[1].isResolved()); | ||
|
|
||
| assert.isTrue(conflicts[2].isResolved()); | ||
| assert.strictEqual(conflicts[2].getChosenSide(), conflicts[2].getSide(THEIRS)); | ||
| assert.deepEqual(conflicts[2].getUnchosenSides(), [conflicts[2].getSide(OURS)]); | ||
| }); | ||
|
|
||
| it('disregards conflicts with cursors on both sides', function() { | ||
| editor.setCursorBufferPosition([6, 3]); // On "Multi-line even" | ||
| editor.addCursorAtBufferPosition([14, 1]); // On "My middle changes" | ||
|
|
@@ -316,6 +359,26 @@ describe('EditorConflictController', function() { | |
|
|
||
| await assert.async.isTrue(refreshResolutionProgress.calledWith(fixtureFile)); | ||
| }); | ||
|
|
||
| it('performs a resolution from the context menu', function() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh cool - I did not know resolving from the context menu was a thing. |
||
| const conflict = conflicts[1]; | ||
| assert.isFalse(conflict.isResolved()); | ||
|
|
||
| wrapper.find('ConflictController').at(1).prop('resolveAsSequence')([OURS]); | ||
|
|
||
| assert.isTrue(conflict.isResolved()); | ||
| assert.strictEqual(conflict.getChosenSide(), conflict.getSide(OURS)); | ||
| }); | ||
|
|
||
| it('dismisses a conflict from the context menu', function() { | ||
| const conflict = conflicts[2]; | ||
|
|
||
| wrapper.find('ConflictController').at(2).prop('dismiss')(); | ||
| wrapper.update(); | ||
|
|
||
| assert.lengthOf(wrapper.find(ConflictController), 2); | ||
| assert.isFalse(wrapper.find(ConflictController).someWhere(cc => cc.prop('conflict') === conflict)); | ||
| }); | ||
| }); | ||
|
|
||
| describe('on a file with 3-way diff markers', function() { | ||
|
|
@@ -442,4 +505,12 @@ describe('EditorConflictController', function() { | |
| assert.equal(editor.getText(), 'These are my changes\nThese are your changes\n\nPast the end\n'); | ||
| }); | ||
| }); | ||
|
|
||
| it('cleans up its subscriptions when unmounting', async function() { | ||
| await useFixture('triple-2way-diff.txt'); | ||
| wrapper.unmount(); | ||
|
|
||
| editor.destroy(); | ||
| assert.isFalse(refreshResolutionProgress.called); | ||
| }); | ||
| }); | ||
8 changes: 8 additions & 0 deletions
8
test/fixtures/conflict-marker-examples/single-2way-diff-empty.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| Before the start | ||
|
|
||
| <<<<<<< HEAD | ||
| These are my changes | ||
| ======= | ||
| >>>>>>> master | ||
|
|
||
| Past the end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you change from
statetopropsbecause that's easier to test?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it was actually just broken before 😅 We hadn't had any tests that covered an update of an existing component, and apparently it doesn't come up in our package yet. But
editorHolderis a member of the state in the wrapper class that reads Context, not in theBareDecoration!