stable

Clone or download

Read-only

refactor: Migrate the file lines state + placeholders builders to TypeScript

part of request #29602 Migrate pullrequest file-diffs to TypeScript This one was hard to migrate, because the state was composed of a multitude of exported function looking for stuff in some maps that was initialized at some point. The placeholders builders had to be migrated in the same patch, since the state is now an object providing those functions they need to work. Moreover, the way the state was mocked in the unit tests was not good. Indeed, I have found a test that is influencing artificially its result to make it pass. I don't have a solution yet to fix it. I've spent 3 hours trying to debug it, but given I had no clue of what's the actual expected behavior, I couldn't get any further. The unit tests can now use a FileLinesStateStub to test their code if they need. This stub has been designed to work with the real state object, but while providing stubbed lines/handles/groups of lines. This stub is able to prepend missing lines to the collection of file lines, in order to be able to test a case where a group of lines is in the middle of the file. Firsts and last lines of diffs being subject to bugs, It allows us to replicate a given file-diff state with enough fidelity. -- No functional change expected Change-Id: Ieb67e7b75b3b28630e0c600f57deb40213b2586e

Modified Files

Name
M plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-code-mirrors-content-manager.ts +1 −1 Go to diff View file
D plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-code-placeholder-builder.js +0 −80 Go to diff View file
D plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-code-placeholder-builder.test.js +0 −233 Go to diff View file
A plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-code-placeholder-builder.test.ts +244 −0 Go to diff View file
A plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-code-placeholder-builder.ts +95 −0 Go to diff View file
D plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-comment-placeholder-builder.js +0 −247 Go to diff View file
D plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-comment-placeholder-builder.test.js +0 −481 Go to diff View file
A plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-comment-placeholder-builder.test.ts +347 −0 Go to diff View file
A plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-comment-placeholder-builder.ts +249 −0 Go to diff View file
M plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-diff-component.js +37 −28 Go to diff View file
M plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-line-grouper.ts +2 −2 Go to diff View file
M plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-line-height-equalizer.js +8 −6 Go to diff View file
M plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-line-height-equalizer.test.js +43 −7 Go to diff View file
M plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-line-mapper.ts +1 −1 Go to diff View file
D plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-lines-state.js +0 −84 Go to diff View file
R plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-lines-state.test.js Go to diff View file
A plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-lines-state.ts +135 −0 Go to diff View file
D plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-placeholder-positioner.js +0 −36 Go to diff View file
R plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-placeholder-positioner.test.js Go to diff View file
A plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-placeholder-positioner.ts +40 −0 Go to diff View file
M plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/types-codemirror-overriden.ts +9 −1 Go to diff View file
A plugins/pullrequest/scripts/pullrequests-app/tests/stubs/FileLinesStateStub.ts +71 −0 Go to diff View file
M plugins/pullrequest/scripts/pullrequests-app/tests/stubs/GroupSideBySideLinesStub.ts +1 −1 Go to diff View file
M plugins/pullrequest/scripts/pullrequests-app/tests/stubs/MapSideBySideLinesStub.ts +1 −1 Go to diff View file
M plugins/pullrequest/scripts/pullrequests-app/tests/stubs/PullRequestCommentPresenterStub.ts +4 −1 Go to diff View file