| b69ab31 | | | 1 | /** |
| b69ab31 | | | 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| b69ab31 | | | 3 | * |
| b69ab31 | | | 4 | * This source code is licensed under the MIT license found in the |
| b69ab31 | | | 5 | * LICENSE file in the root directory of this source tree. |
| b69ab31 | | | 6 | */ |
| b69ab31 | | | 7 | |
| b69ab31 | | | 8 | import {act, fireEvent, render, screen, waitFor, within} from '@testing-library/react'; |
| b69ab31 | | | 9 | import userEvent from '@testing-library/user-event'; |
| b69ab31 | | | 10 | import App from '../App'; |
| b69ab31 | | | 11 | import {tracker} from '../analytics'; |
| b69ab31 | | | 12 | import platform from '../platform'; |
| b69ab31 | | | 13 | import {CommitInfoTestUtils, CommitTreeListTestUtils, ignoreRTL} from '../testQueries'; |
| b69ab31 | | | 14 | import { |
| b69ab31 | | | 15 | COMMIT, |
| b69ab31 | | | 16 | closeCommitInfoSidebar, |
| b69ab31 | | | 17 | expectMessageSentToServer, |
| b69ab31 | | | 18 | openCommitInfoSidebar, |
| b69ab31 | | | 19 | resetTestMessages, |
| b69ab31 | | | 20 | simulateCommits, |
| b69ab31 | | | 21 | simulateMessageFromServer, |
| b69ab31 | | | 22 | simulateUncommittedChangedFiles, |
| b69ab31 | | | 23 | waitForWithTick, |
| b69ab31 | | | 24 | } from '../testUtils'; |
| b69ab31 | | | 25 | import {CommandRunner, succeedableRevset} from '../types'; |
| b69ab31 | | | 26 | |
| b69ab31 | | | 27 | /* eslint-disable @typescript-eslint/no-non-null-assertion */ |
| b69ab31 | | | 28 | |
| b69ab31 | | | 29 | const { |
| b69ab31 | | | 30 | withinCommitInfo, |
| b69ab31 | | | 31 | clickAmendButton, |
| b69ab31 | | | 32 | clickCancel, |
| b69ab31 | | | 33 | clickCommitButton, |
| b69ab31 | | | 34 | clickCommitMode, |
| b69ab31 | | | 35 | clickToSelectCommit, |
| b69ab31 | | | 36 | getTitleEditor, |
| b69ab31 | | | 37 | getDescriptionEditor, |
| b69ab31 | | | 38 | clickToEditTitle, |
| b69ab31 | | | 39 | clickToEditDescription, |
| b69ab31 | | | 40 | expectIsEditingTitle, |
| b69ab31 | | | 41 | expectIsNOTEditingTitle, |
| b69ab31 | | | 42 | expectIsEditingDescription, |
| b69ab31 | | | 43 | expectIsNOTEditingDescription, |
| b69ab31 | | | 44 | } = CommitInfoTestUtils; |
| b69ab31 | | | 45 | |
| b69ab31 | | | 46 | describe('CommitInfoView', () => { |
| b69ab31 | | | 47 | beforeEach(() => { |
| b69ab31 | | | 48 | resetTestMessages(); |
| b69ab31 | | | 49 | jest.spyOn(tracker, 'track').mockImplementation(() => undefined); |
| b69ab31 | | | 50 | }); |
| b69ab31 | | | 51 | |
| b69ab31 | | | 52 | it('shows loading spinner on mount', () => { |
| b69ab31 | | | 53 | render(<App />); |
| b69ab31 | | | 54 | |
| b69ab31 | | | 55 | expect(screen.getByTestId('commit-info-view-loading')).toBeInTheDocument(); |
| b69ab31 | | | 56 | }); |
| b69ab31 | | | 57 | |
| b69ab31 | | | 58 | describe('after commits loaded', () => { |
| b69ab31 | | | 59 | beforeEach(() => { |
| b69ab31 | | | 60 | render(<App />); |
| b69ab31 | | | 61 | act(() => { |
| b69ab31 | | | 62 | openCommitInfoSidebar(); |
| b69ab31 | | | 63 | expectMessageSentToServer({ |
| b69ab31 | | | 64 | type: 'subscribe', |
| b69ab31 | | | 65 | kind: 'smartlogCommits', |
| b69ab31 | | | 66 | subscriptionID: expect.anything(), |
| b69ab31 | | | 67 | }); |
| b69ab31 | | | 68 | simulateCommits({ |
| b69ab31 | | | 69 | value: [ |
| b69ab31 | | | 70 | COMMIT('1', 'some public base', '0', {phase: 'public'}), |
| b69ab31 | | | 71 | COMMIT('a', 'My Commit', '1'), |
| b69ab31 | | | 72 | COMMIT('b', 'Head Commit', 'a', {isDot: true}), |
| b69ab31 | | | 73 | ], |
| b69ab31 | | | 74 | }); |
| b69ab31 | | | 75 | }); |
| b69ab31 | | | 76 | }); |
| b69ab31 | | | 77 | |
| b69ab31 | | | 78 | describe('drawer', () => { |
| b69ab31 | | | 79 | it('can close commit info sidebar by clicking label', () => { |
| b69ab31 | | | 80 | expect(screen.getByTestId('commit-info-view')).toBeInTheDocument(); |
| b69ab31 | | | 81 | expect(screen.getByText('Commit Info')).toBeInTheDocument(); |
| b69ab31 | | | 82 | act(() => { |
| b69ab31 | | | 83 | closeCommitInfoSidebar(); |
| b69ab31 | | | 84 | }); |
| b69ab31 | | | 85 | expect(screen.queryByTestId('commit-info-view')).not.toBeInTheDocument(); |
| b69ab31 | | | 86 | expect(screen.getByText('Commit Info')).toBeInTheDocument(); |
| b69ab31 | | | 87 | }); |
| b69ab31 | | | 88 | }); |
| b69ab31 | | | 89 | |
| b69ab31 | | | 90 | describe('commit selection', () => { |
| b69ab31 | | | 91 | it('shows head commit by default', () => { |
| b69ab31 | | | 92 | expect(withinCommitInfo().queryByText('Head Commit')).toBeInTheDocument(); |
| b69ab31 | | | 93 | }); |
| b69ab31 | | | 94 | |
| b69ab31 | | | 95 | it('can click to select commit', () => { |
| b69ab31 | | | 96 | clickToSelectCommit('a'); |
| b69ab31 | | | 97 | |
| b69ab31 | | | 98 | // now commit info view shows selected commit |
| b69ab31 | | | 99 | expect(withinCommitInfo().queryByText('My Commit')).toBeInTheDocument(); |
| b69ab31 | | | 100 | expect(withinCommitInfo().queryByText('Head Commit')).not.toBeInTheDocument(); |
| b69ab31 | | | 101 | }); |
| b69ab31 | | | 102 | |
| b69ab31 | | | 103 | it('cannot select public commits', () => { |
| b69ab31 | | | 104 | clickToSelectCommit('1'); |
| b69ab31 | | | 105 | |
| b69ab31 | | | 106 | expect(withinCommitInfo().queryByText('some public base')).not.toBeInTheDocument(); |
| b69ab31 | | | 107 | // stays on head commit |
| b69ab31 | | | 108 | expect(withinCommitInfo().queryByText('Head Commit')).toBeInTheDocument(); |
| b69ab31 | | | 109 | }); |
| b69ab31 | | | 110 | }); |
| b69ab31 | | | 111 | |
| b69ab31 | | | 112 | describe('changed files', () => { |
| b69ab31 | | | 113 | beforeEach(() => { |
| b69ab31 | | | 114 | act(() => { |
| b69ab31 | | | 115 | simulateCommits({ |
| b69ab31 | | | 116 | value: [ |
| b69ab31 | | | 117 | COMMIT('1', 'some public base', '0', {phase: 'public'}), |
| b69ab31 | | | 118 | COMMIT('a', 'My Commit', '1', {filePathsSample: ['src/ca.js'], totalFileCount: 1}), |
| b69ab31 | | | 119 | COMMIT('b', 'Head Commit', 'a', { |
| b69ab31 | | | 120 | isDot: true, |
| b69ab31 | | | 121 | filePathsSample: ['src/cb.js'], |
| b69ab31 | | | 122 | totalFileCount: 1, |
| b69ab31 | | | 123 | }), |
| b69ab31 | | | 124 | ], |
| b69ab31 | | | 125 | }); |
| b69ab31 | | | 126 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 127 | value: [ |
| b69ab31 | | | 128 | {path: 'src/file1.js', status: 'M'}, |
| b69ab31 | | | 129 | {path: 'src/file2.js', status: 'M'}, |
| b69ab31 | | | 130 | ], |
| b69ab31 | | | 131 | }); |
| b69ab31 | | | 132 | }); |
| b69ab31 | | | 133 | }); |
| b69ab31 | | | 134 | |
| b69ab31 | | | 135 | it('shows uncommitted changes for head commit', () => { |
| b69ab31 | | | 136 | expect(withinCommitInfo().queryByText(ignoreRTL('file1.js'))).toBeInTheDocument(); |
| b69ab31 | | | 137 | expect(withinCommitInfo().queryByText(ignoreRTL('file2.js'))).toBeInTheDocument(); |
| b69ab31 | | | 138 | }); |
| b69ab31 | | | 139 | |
| b69ab31 | | | 140 | it('shows file actions on uncommitted changes in commit info view', () => { |
| b69ab31 | | | 141 | // (1) uncommitted changes in commit list, (2) uncommitted changes in commit info, (3) committed changes in commit info |
| b69ab31 | | | 142 | expect(withinCommitInfo().queryAllByTestId('file-actions')).toHaveLength(3); |
| b69ab31 | | | 143 | }); |
| b69ab31 | | | 144 | |
| b69ab31 | | | 145 | it("doesn't show uncommitted changes on non-head commits ", () => { |
| b69ab31 | | | 146 | clickToSelectCommit('a'); |
| b69ab31 | | | 147 | expect(withinCommitInfo().queryByText(ignoreRTL('file1.js'))).not.toBeInTheDocument(); |
| b69ab31 | | | 148 | expect(withinCommitInfo().queryByText(ignoreRTL('file2.js'))).not.toBeInTheDocument(); |
| b69ab31 | | | 149 | }); |
| b69ab31 | | | 150 | |
| b69ab31 | | | 151 | it('shows files changed in the commit for head commit', () => { |
| b69ab31 | | | 152 | expect(withinCommitInfo().queryByText(ignoreRTL('ca.js'))).not.toBeInTheDocument(); |
| b69ab31 | | | 153 | expect(withinCommitInfo().queryByText(ignoreRTL('cb.js'))).toBeInTheDocument(); |
| b69ab31 | | | 154 | }); |
| b69ab31 | | | 155 | |
| b69ab31 | | | 156 | it('shows files changed in the commit for non-head commit', () => { |
| b69ab31 | | | 157 | clickToSelectCommit('a'); |
| b69ab31 | | | 158 | expect(withinCommitInfo().queryByText(ignoreRTL('ca.js'))).toBeInTheDocument(); |
| b69ab31 | | | 159 | expect(withinCommitInfo().queryByText(ignoreRTL('cb.js'))).not.toBeInTheDocument(); |
| b69ab31 | | | 160 | }); |
| b69ab31 | | | 161 | |
| b69ab31 | | | 162 | it('enables amend button with uncommitted changes', () => { |
| b69ab31 | | | 163 | expect(withinCommitInfo().queryByText(ignoreRTL('file1.js'))).toBeInTheDocument(); |
| b69ab31 | | | 164 | expect(withinCommitInfo().queryByText(ignoreRTL('file2.js'))).toBeInTheDocument(); |
| b69ab31 | | | 165 | |
| b69ab31 | | | 166 | const amendButton: HTMLButtonElement | null = within( |
| b69ab31 | | | 167 | screen.getByTestId('commit-info-actions-bar'), |
| b69ab31 | | | 168 | ).queryByText('Amend'); |
| b69ab31 | | | 169 | expect(amendButton).toBeInTheDocument(); |
| b69ab31 | | | 170 | expect(amendButton?.disabled).not.toBe(true); |
| b69ab31 | | | 171 | }); |
| b69ab31 | | | 172 | |
| b69ab31 | | | 173 | it('does not show banner if all files are shown', () => { |
| b69ab31 | | | 174 | expect( |
| b69ab31 | | | 175 | withinCommitInfo().queryByText(/Showing first .* files out of .* total/), |
| b69ab31 | | | 176 | ).not.toBeInTheDocument(); |
| b69ab31 | | | 177 | }); |
| b69ab31 | | | 178 | |
| b69ab31 | | | 179 | it('shows banner if not all files are shown', () => { |
| b69ab31 | | | 180 | act(() => { |
| b69ab31 | | | 181 | simulateCommits({ |
| b69ab31 | | | 182 | value: [ |
| b69ab31 | | | 183 | COMMIT('1', 'some public base', '0', {phase: 'public'}), |
| b69ab31 | | | 184 | COMMIT('a', 'Head Commit', '1', { |
| b69ab31 | | | 185 | isDot: true, |
| b69ab31 | | | 186 | filePathsSample: new Array(25).fill(null).map((_, i) => `src/file${i}.txt`), |
| b69ab31 | | | 187 | totalFileCount: 100, |
| b69ab31 | | | 188 | }), |
| b69ab31 | | | 189 | ], |
| b69ab31 | | | 190 | }); |
| b69ab31 | | | 191 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 192 | value: [], |
| b69ab31 | | | 193 | }); |
| b69ab31 | | | 194 | }); |
| b69ab31 | | | 195 | |
| b69ab31 | | | 196 | expect(withinCommitInfo().queryByText(ignoreRTL('file1.txt'))).toBeInTheDocument(); |
| b69ab31 | | | 197 | expect( |
| b69ab31 | | | 198 | withinCommitInfo().queryByText('Showing first 25 files out of 100 total'), |
| b69ab31 | | | 199 | ).toBeInTheDocument(); |
| b69ab31 | | | 200 | }); |
| b69ab31 | | | 201 | |
| b69ab31 | | | 202 | it('runs amend with selected files', async () => { |
| b69ab31 | | | 203 | expect(withinCommitInfo().queryByText(ignoreRTL('file1.js'))).toBeInTheDocument(); |
| b69ab31 | | | 204 | expect(withinCommitInfo().queryByText(ignoreRTL('file2.js'))).toBeInTheDocument(); |
| b69ab31 | | | 205 | |
| b69ab31 | | | 206 | act(() => { |
| b69ab31 | | | 207 | const checkboxes = withinCommitInfo() |
| b69ab31 | | | 208 | .queryByTestId('changes-to-amend')! |
| b69ab31 | | | 209 | .querySelectorAll('input[type="checkbox"]'); |
| b69ab31 | | | 210 | fireEvent.click(checkboxes[0]); |
| b69ab31 | | | 211 | }); |
| b69ab31 | | | 212 | |
| b69ab31 | | | 213 | const amendButton = within(screen.getByTestId('commit-info-actions-bar')).queryByText( |
| b69ab31 | | | 214 | 'Amend', |
| b69ab31 | | | 215 | ); |
| b69ab31 | | | 216 | expect(amendButton).toBeInTheDocument(); |
| b69ab31 | | | 217 | |
| b69ab31 | | | 218 | act(() => { |
| b69ab31 | | | 219 | fireEvent.click(amendButton!); |
| b69ab31 | | | 220 | }); |
| b69ab31 | | | 221 | |
| b69ab31 | | | 222 | await waitFor(() => |
| b69ab31 | | | 223 | expectMessageSentToServer({ |
| b69ab31 | | | 224 | type: 'runOperation', |
| b69ab31 | | | 225 | operation: { |
| b69ab31 | | | 226 | args: [ |
| b69ab31 | | | 227 | {type: 'config', key: 'amend.autorestack', value: 'always'}, |
| b69ab31 | | | 228 | 'amend', |
| b69ab31 | | | 229 | '--addremove', |
| b69ab31 | | | 230 | {type: 'repo-relative-file', path: 'src/file2.js'}, |
| b69ab31 | | | 231 | '--message', |
| b69ab31 | | | 232 | expect.stringMatching(/^Head Commit/), |
| b69ab31 | | | 233 | ], |
| b69ab31 | | | 234 | id: expect.anything(), |
| b69ab31 | | | 235 | runner: CommandRunner.Sapling, |
| b69ab31 | | | 236 | trackEventName: 'AmendFileSubsetOperation', |
| b69ab31 | | | 237 | }, |
| b69ab31 | | | 238 | }), |
| b69ab31 | | | 239 | ); |
| b69ab31 | | | 240 | }); |
| b69ab31 | | | 241 | |
| b69ab31 | | | 242 | it('disallows amending when all uncommitted changes deselected', () => { |
| b69ab31 | | | 243 | // click every checkbox in changes to amend |
| b69ab31 | | | 244 | act(() => { |
| b69ab31 | | | 245 | const checkboxes = withinCommitInfo() |
| b69ab31 | | | 246 | .queryByTestId('changes-to-amend') |
| b69ab31 | | | 247 | ?.querySelectorAll('input[type="checkbox"]'); |
| b69ab31 | | | 248 | checkboxes?.forEach(checkbox => { |
| b69ab31 | | | 249 | fireEvent.click(checkbox); |
| b69ab31 | | | 250 | }); |
| b69ab31 | | | 251 | }); |
| b69ab31 | | | 252 | |
| b69ab31 | | | 253 | const amendButton: HTMLButtonElement | null = within( |
| b69ab31 | | | 254 | screen.getByTestId('commit-info-actions-bar'), |
| b69ab31 | | | 255 | ).queryByText('Amend'); |
| b69ab31 | | | 256 | expect(amendButton).toBeInTheDocument(); |
| b69ab31 | | | 257 | expect(amendButton?.disabled).toBe(true); |
| b69ab31 | | | 258 | }); |
| b69ab31 | | | 259 | |
| b69ab31 | | | 260 | it('shows optimistic uncommitted changes', async () => { |
| b69ab31 | | | 261 | act(() => { |
| b69ab31 | | | 262 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 263 | value: [], |
| b69ab31 | | | 264 | }); |
| b69ab31 | | | 265 | }); |
| b69ab31 | | | 266 | |
| b69ab31 | | | 267 | expect(screen.queryByText('Amend and Submit')).not.toBeInTheDocument(); |
| b69ab31 | | | 268 | |
| b69ab31 | | | 269 | jest.spyOn(platform, 'confirm').mockImplementation(() => Promise.resolve(true)); |
| b69ab31 | | | 270 | act(() => { |
| b69ab31 | | | 271 | fireEvent.click(screen.getByText('Uncommit')); |
| b69ab31 | | | 272 | }); |
| b69ab31 | | | 273 | act(() => { |
| b69ab31 | | | 274 | simulateMessageFromServer({ |
| b69ab31 | | | 275 | type: 'fetchedCommitChangedFiles', |
| b69ab31 | | | 276 | hash: 'b', |
| b69ab31 | | | 277 | result: { |
| b69ab31 | | | 278 | value: { |
| b69ab31 | | | 279 | totalFileCount: 3, |
| b69ab31 | | | 280 | filesSample: [{path: 'src/cb.js', status: 'M'}], |
| b69ab31 | | | 281 | }, |
| b69ab31 | | | 282 | }, |
| b69ab31 | | | 283 | }); |
| b69ab31 | | | 284 | }); |
| b69ab31 | | | 285 | |
| b69ab31 | | | 286 | await waitFor(() => { |
| b69ab31 | | | 287 | expect(withinCommitInfo().queryByText(ignoreRTL('cb.js'))).toBeInTheDocument(); |
| b69ab31 | | | 288 | expect(screen.queryByText('Amend and Submit')).toBeInTheDocument(); |
| b69ab31 | | | 289 | }); |
| b69ab31 | | | 290 | }); |
| b69ab31 | | | 291 | }); |
| b69ab31 | | | 292 | |
| b69ab31 | | | 293 | describe('editing fields', () => { |
| b69ab31 | | | 294 | beforeEach(() => { |
| b69ab31 | | | 295 | act(() => { |
| b69ab31 | | | 296 | simulateCommits({ |
| b69ab31 | | | 297 | value: [ |
| b69ab31 | | | 298 | COMMIT('1', 'some public base', '0', {phase: 'public'}), |
| b69ab31 | | | 299 | COMMIT('a', 'My Commit', '1', {description: 'Summary: First commit in the stack'}), |
| b69ab31 | | | 300 | COMMIT('b', 'Head Commit', 'a', { |
| b69ab31 | | | 301 | description: 'Summary: stacked commit', |
| b69ab31 | | | 302 | isDot: true, |
| b69ab31 | | | 303 | }), |
| b69ab31 | | | 304 | ], |
| b69ab31 | | | 305 | }); |
| b69ab31 | | | 306 | }); |
| b69ab31 | | | 307 | }); |
| b69ab31 | | | 308 | |
| b69ab31 | | | 309 | it('starts editing title when clicked', () => { |
| b69ab31 | | | 310 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 311 | clickToEditTitle(); |
| b69ab31 | | | 312 | expectIsEditingTitle(); |
| b69ab31 | | | 313 | }); |
| b69ab31 | | | 314 | |
| b69ab31 | | | 315 | it('starts editing description when clicked', () => { |
| b69ab31 | | | 316 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 317 | clickToEditDescription(); |
| b69ab31 | | | 318 | expectIsEditingDescription(); |
| b69ab31 | | | 319 | }); |
| b69ab31 | | | 320 | |
| b69ab31 | | | 321 | it('cancel button stops editing', () => { |
| b69ab31 | | | 322 | clickToEditTitle(); |
| b69ab31 | | | 323 | clickToEditDescription(); |
| b69ab31 | | | 324 | expectIsEditingTitle(); |
| b69ab31 | | | 325 | expectIsEditingDescription(); |
| b69ab31 | | | 326 | |
| b69ab31 | | | 327 | const cancelButton: HTMLButtonElement | null = withinCommitInfo().queryByText('Cancel'); |
| b69ab31 | | | 328 | expect(cancelButton).toBeInTheDocument(); |
| b69ab31 | | | 329 | |
| b69ab31 | | | 330 | act(() => { |
| b69ab31 | | | 331 | fireEvent.click(cancelButton!); |
| b69ab31 | | | 332 | }); |
| b69ab31 | | | 333 | |
| b69ab31 | | | 334 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 335 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 336 | }); |
| b69ab31 | | | 337 | |
| b69ab31 | | | 338 | it('amend button stops editing', async () => { |
| b69ab31 | | | 339 | act(() => |
| b69ab31 | | | 340 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 341 | value: [{path: 'src/file1.js', status: 'M'}], |
| b69ab31 | | | 342 | }), |
| b69ab31 | | | 343 | ); |
| b69ab31 | | | 344 | |
| b69ab31 | | | 345 | clickToEditTitle(); |
| b69ab31 | | | 346 | clickToEditDescription(); |
| b69ab31 | | | 347 | expectIsEditingTitle(); |
| b69ab31 | | | 348 | expectIsEditingDescription(); |
| b69ab31 | | | 349 | |
| b69ab31 | | | 350 | const amendButton: HTMLButtonElement | null = within( |
| b69ab31 | | | 351 | screen.getByTestId('commit-info-actions-bar'), |
| b69ab31 | | | 352 | ).queryByText('Amend'); |
| b69ab31 | | | 353 | expect(amendButton).toBeInTheDocument(); |
| b69ab31 | | | 354 | expect(amendButton?.disabled).not.toEqual(true); |
| b69ab31 | | | 355 | |
| b69ab31 | | | 356 | act(() => { |
| b69ab31 | | | 357 | fireEvent.click(amendButton!); |
| b69ab31 | | | 358 | }); |
| b69ab31 | | | 359 | |
| b69ab31 | | | 360 | await waitFor(() => |
| b69ab31 | | | 361 | expectMessageSentToServer({ |
| b69ab31 | | | 362 | type: 'runOperation', |
| b69ab31 | | | 363 | operation: expect.objectContaining({ |
| b69ab31 | | | 364 | args: expect.arrayContaining(['amend']), |
| b69ab31 | | | 365 | }), |
| b69ab31 | | | 366 | }), |
| b69ab31 | | | 367 | ); |
| b69ab31 | | | 368 | |
| b69ab31 | | | 369 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 370 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 371 | }); |
| b69ab31 | | | 372 | |
| b69ab31 | | | 373 | it('resets edited fields when changing selected commit', () => { |
| b69ab31 | | | 374 | clickToEditTitle(); |
| b69ab31 | | | 375 | clickToEditDescription(); |
| b69ab31 | | | 376 | expectIsEditingTitle(); |
| b69ab31 | | | 377 | expectIsEditingDescription(); |
| b69ab31 | | | 378 | |
| b69ab31 | | | 379 | clickToSelectCommit('a'); |
| b69ab31 | | | 380 | |
| b69ab31 | | | 381 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 382 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 383 | }); |
| b69ab31 | | | 384 | |
| b69ab31 | | | 385 | it('fields stay reset after switching commit, if there were no real changes made', () => { |
| b69ab31 | | | 386 | clickToEditTitle(); |
| b69ab31 | | | 387 | clickToEditDescription(); |
| b69ab31 | | | 388 | expectIsEditingTitle(); |
| b69ab31 | | | 389 | expectIsEditingDescription(); |
| b69ab31 | | | 390 | |
| b69ab31 | | | 391 | clickToSelectCommit('a'); |
| b69ab31 | | | 392 | |
| b69ab31 | | | 393 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 394 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 395 | |
| b69ab31 | | | 396 | clickToSelectCommit('b'); |
| b69ab31 | | | 397 | |
| b69ab31 | | | 398 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 399 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 400 | }); |
| b69ab31 | | | 401 | |
| b69ab31 | | | 402 | it('edited fields go back into editing state when returning to selected commit', () => { |
| b69ab31 | | | 403 | clickToEditTitle(); |
| b69ab31 | | | 404 | clickToEditDescription(); |
| b69ab31 | | | 405 | expectIsEditingTitle(); |
| b69ab31 | | | 406 | expectIsEditingDescription(); |
| b69ab31 | | | 407 | |
| b69ab31 | | | 408 | { |
| b69ab31 | | | 409 | act(() => { |
| b69ab31 | | | 410 | userEvent.type(getTitleEditor(), ' hello new title'); |
| b69ab31 | | | 411 | userEvent.type(getDescriptionEditor(), '\nhello new text'); |
| b69ab31 | | | 412 | }); |
| b69ab31 | | | 413 | } |
| b69ab31 | | | 414 | |
| b69ab31 | | | 415 | clickToSelectCommit('a'); |
| b69ab31 | | | 416 | |
| b69ab31 | | | 417 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 418 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 419 | |
| b69ab31 | | | 420 | clickToSelectCommit('b'); |
| b69ab31 | | | 421 | |
| b69ab31 | | | 422 | expectIsEditingTitle(); |
| b69ab31 | | | 423 | expectIsEditingDescription(); |
| b69ab31 | | | 424 | |
| b69ab31 | | | 425 | { |
| b69ab31 | | | 426 | expect(getTitleEditor().value).toBe('Head Commit hello new title'); |
| b69ab31 | | | 427 | expect(getDescriptionEditor().value).toEqual( |
| b69ab31 | | | 428 | expect.stringContaining('stacked commit\nhello new text'), |
| b69ab31 | | | 429 | ); |
| b69ab31 | | | 430 | } |
| b69ab31 | | | 431 | }); |
| b69ab31 | | | 432 | |
| b69ab31 | | | 433 | it('cannot type newlines into title', () => { |
| b69ab31 | | | 434 | clickToEditTitle(); |
| b69ab31 | | | 435 | expectIsEditingTitle(); |
| b69ab31 | | | 436 | |
| b69ab31 | | | 437 | act(() => { |
| b69ab31 | | | 438 | userEvent.type(getTitleEditor(), ' hello\nsomething\r\nhi'); |
| b69ab31 | | | 439 | }); |
| b69ab31 | | | 440 | expect(getTitleEditor().value).toBe('Head Commit hellosomethinghi'); |
| b69ab31 | | | 441 | }); |
| b69ab31 | | | 442 | |
| b69ab31 | | | 443 | describe('focus', () => { |
| b69ab31 | | | 444 | it('focuses title when you start editing', async () => { |
| b69ab31 | | | 445 | clickToEditTitle(); |
| b69ab31 | | | 446 | |
| b69ab31 | | | 447 | await waitFor(() => { |
| b69ab31 | | | 448 | expect(getTitleEditor()).toHaveFocus(); |
| b69ab31 | | | 449 | }); |
| b69ab31 | | | 450 | }); |
| b69ab31 | | | 451 | |
| b69ab31 | | | 452 | it('focuses summary when you start editing', async () => { |
| b69ab31 | | | 453 | clickToEditDescription(); |
| b69ab31 | | | 454 | |
| b69ab31 | | | 455 | await waitFor(() => { |
| b69ab31 | | | 456 | expect(getDescriptionEditor()).toHaveFocus(); |
| b69ab31 | | | 457 | }); |
| b69ab31 | | | 458 | }); |
| b69ab31 | | | 459 | |
| b69ab31 | | | 460 | it('focuses topmost field when all fields start being edited', async () => { |
| b69ab31 | | | 461 | act(() => { |
| b69ab31 | | | 462 | simulateUncommittedChangedFiles({value: [{path: 'src/file1.js', status: 'M'}]}); |
| b69ab31 | | | 463 | }); |
| b69ab31 | | | 464 | // edit fields, then switch selected commit and switch back to edit both fields together |
| b69ab31 | | | 465 | fireEvent.click(screen.getByText('Amend as...', {exact: false})); |
| b69ab31 | | | 466 | |
| b69ab31 | | | 467 | await waitFor(() => { |
| b69ab31 | | | 468 | expect(getTitleEditor()).toHaveFocus(); |
| b69ab31 | | | 469 | expect(getDescriptionEditor()).not.toHaveFocus(); |
| b69ab31 | | | 470 | }); |
| b69ab31 | | | 471 | }); |
| b69ab31 | | | 472 | |
| b69ab31 | | | 473 | it('focuses topmost edited field when loading from saved state', async () => { |
| b69ab31 | | | 474 | act(() => { |
| b69ab31 | | | 475 | clickToEditTitle(); |
| b69ab31 | | | 476 | clickToEditDescription(); |
| b69ab31 | | | 477 | }); |
| b69ab31 | | | 478 | { |
| b69ab31 | | | 479 | act(() => { |
| b69ab31 | | | 480 | userEvent.type(getTitleEditor(), ' hello new title'); |
| b69ab31 | | | 481 | userEvent.type(getDescriptionEditor(), '\nhello new text'); |
| b69ab31 | | | 482 | }); |
| b69ab31 | | | 483 | } |
| b69ab31 | | | 484 | |
| b69ab31 | | | 485 | clickToSelectCommit('a'); |
| b69ab31 | | | 486 | clickToSelectCommit('b'); |
| b69ab31 | | | 487 | |
| b69ab31 | | | 488 | expectIsEditingTitle(); |
| b69ab31 | | | 489 | expectIsEditingDescription(); |
| b69ab31 | | | 490 | |
| b69ab31 | | | 491 | await waitFor(() => { |
| b69ab31 | | | 492 | expect(getTitleEditor()).toHaveFocus(); |
| b69ab31 | | | 493 | expect(getDescriptionEditor()).not.toHaveFocus(); |
| b69ab31 | | | 494 | }); |
| b69ab31 | | | 495 | }); |
| b69ab31 | | | 496 | }); |
| b69ab31 | | | 497 | |
| b69ab31 | | | 498 | describe('head commit', () => { |
| b69ab31 | | | 499 | it('only has metaedit button on non-head commits', () => { |
| b69ab31 | | | 500 | { |
| b69ab31 | | | 501 | const preChangeAmendMessageButton = within( |
| b69ab31 | | | 502 | screen.getByTestId('commit-info-actions-bar'), |
| b69ab31 | | | 503 | ).queryByText('Amend Message'); |
| b69ab31 | | | 504 | expect(preChangeAmendMessageButton).not.toBeInTheDocument(); |
| b69ab31 | | | 505 | } |
| b69ab31 | | | 506 | |
| b69ab31 | | | 507 | clickToSelectCommit('a'); |
| b69ab31 | | | 508 | |
| b69ab31 | | | 509 | const amendMessageButton = within( |
| b69ab31 | | | 510 | screen.getByTestId('commit-info-actions-bar'), |
| b69ab31 | | | 511 | ).queryByText('Amend Message'); |
| b69ab31 | | | 512 | expect(amendMessageButton).toBeInTheDocument(); |
| b69ab31 | | | 513 | }); |
| b69ab31 | | | 514 | |
| b69ab31 | | | 515 | it('has "You are here" on head commit', () => { |
| b69ab31 | | | 516 | expect(withinCommitInfo().queryByText('You are here')).toBeInTheDocument(); |
| b69ab31 | | | 517 | }); |
| b69ab31 | | | 518 | |
| b69ab31 | | | 519 | it('does not have "You are here" on non-head commit', () => { |
| b69ab31 | | | 520 | clickToSelectCommit('a'); |
| b69ab31 | | | 521 | expect(withinCommitInfo().queryByText('You are here')).not.toBeInTheDocument(); |
| b69ab31 | | | 522 | }); |
| b69ab31 | | | 523 | |
| b69ab31 | | | 524 | it('does not have "You are here" in commit mode', () => { |
| b69ab31 | | | 525 | clickCommitMode(); |
| b69ab31 | | | 526 | expect(withinCommitInfo().queryByText('You are here')).not.toBeInTheDocument(); |
| b69ab31 | | | 527 | }); |
| b69ab31 | | | 528 | }); |
| b69ab31 | | | 529 | |
| b69ab31 | | | 530 | describe('running commands', () => { |
| b69ab31 | | | 531 | describe('metaedit', () => { |
| b69ab31 | | | 532 | it('disables metaedit button if no fields edited', () => { |
| b69ab31 | | | 533 | clickToSelectCommit('a'); |
| b69ab31 | | | 534 | |
| b69ab31 | | | 535 | const amendMessageButton = within( |
| b69ab31 | | | 536 | screen.getByTestId('commit-info-actions-bar'), |
| b69ab31 | | | 537 | ).queryByText('Amend Message') as HTMLButtonElement; |
| b69ab31 | | | 538 | expect(amendMessageButton).toBeInTheDocument(); |
| b69ab31 | | | 539 | expect(amendMessageButton!.disabled).toBe(true); |
| b69ab31 | | | 540 | }); |
| b69ab31 | | | 541 | |
| b69ab31 | | | 542 | it('enables metaedit button if fields are edited', () => { |
| b69ab31 | | | 543 | clickToSelectCommit('a'); |
| b69ab31 | | | 544 | |
| b69ab31 | | | 545 | act(() => { |
| b69ab31 | | | 546 | clickToEditTitle(); |
| b69ab31 | | | 547 | clickToEditDescription(); |
| b69ab31 | | | 548 | }); |
| b69ab31 | | | 549 | }); |
| b69ab31 | | | 550 | |
| b69ab31 | | | 551 | it('runs metaedit', async () => { |
| b69ab31 | | | 552 | clickToSelectCommit('a'); |
| b69ab31 | | | 553 | |
| b69ab31 | | | 554 | act(() => { |
| b69ab31 | | | 555 | clickToEditTitle(); |
| b69ab31 | | | 556 | clickToEditDescription(); |
| b69ab31 | | | 557 | }); |
| b69ab31 | | | 558 | |
| b69ab31 | | | 559 | { |
| b69ab31 | | | 560 | act(() => { |
| b69ab31 | | | 561 | userEvent.type(getTitleEditor(), ' hello new title'); |
| b69ab31 | | | 562 | userEvent.type(getDescriptionEditor(), '\nhello new text'); |
| b69ab31 | | | 563 | }); |
| b69ab31 | | | 564 | } |
| b69ab31 | | | 565 | |
| b69ab31 | | | 566 | const amendMessageButton = within( |
| b69ab31 | | | 567 | screen.getByTestId('commit-info-actions-bar'), |
| b69ab31 | | | 568 | ).queryByText('Amend Message'); |
| b69ab31 | | | 569 | act(() => { |
| b69ab31 | | | 570 | fireEvent.click(amendMessageButton!); |
| b69ab31 | | | 571 | }); |
| b69ab31 | | | 572 | await waitFor(() => |
| b69ab31 | | | 573 | expectMessageSentToServer({ |
| b69ab31 | | | 574 | type: 'runOperation', |
| b69ab31 | | | 575 | operation: { |
| b69ab31 | | | 576 | args: [ |
| b69ab31 | | | 577 | 'metaedit', |
| b69ab31 | | | 578 | '--rev', |
| b69ab31 | | | 579 | succeedableRevset('a'), |
| b69ab31 | | | 580 | '--message', |
| b69ab31 | | | 581 | expect.stringMatching( |
| b69ab31 | | | 582 | /^My Commit hello new title\n+(Summary:\s+)?First commit in the stack\nhello new text/, |
| b69ab31 | | | 583 | ), |
| b69ab31 | | | 584 | ], |
| b69ab31 | | | 585 | id: expect.anything(), |
| b69ab31 | | | 586 | runner: CommandRunner.Sapling, |
| b69ab31 | | | 587 | trackEventName: 'AmendMessageOperation', |
| b69ab31 | | | 588 | }, |
| b69ab31 | | | 589 | }), |
| b69ab31 | | | 590 | ); |
| b69ab31 | | | 591 | }); |
| b69ab31 | | | 592 | |
| b69ab31 | | | 593 | it('disables metaedit button with spinner while running', async () => { |
| b69ab31 | | | 594 | clickToSelectCommit('a'); |
| b69ab31 | | | 595 | |
| b69ab31 | | | 596 | act(() => { |
| b69ab31 | | | 597 | clickToEditTitle(); |
| b69ab31 | | | 598 | clickToEditDescription(); |
| b69ab31 | | | 599 | }); |
| b69ab31 | | | 600 | { |
| b69ab31 | | | 601 | act(() => { |
| b69ab31 | | | 602 | userEvent.type(getTitleEditor(), ' hello new title'); |
| b69ab31 | | | 603 | userEvent.type(getDescriptionEditor(), '\nhello new text'); |
| b69ab31 | | | 604 | }); |
| b69ab31 | | | 605 | } |
| b69ab31 | | | 606 | |
| b69ab31 | | | 607 | const amendMessageButton = within( |
| b69ab31 | | | 608 | screen.getByTestId('commit-info-actions-bar'), |
| b69ab31 | | | 609 | ).queryByText('Amend Message'); |
| b69ab31 | | | 610 | act(() => { |
| b69ab31 | | | 611 | fireEvent.click(amendMessageButton!); |
| b69ab31 | | | 612 | }); |
| b69ab31 | | | 613 | |
| b69ab31 | | | 614 | await waitForWithTick(() => { |
| b69ab31 | | | 615 | expect(amendMessageButton).toBeDisabled(); |
| b69ab31 | | | 616 | }); |
| b69ab31 | | | 617 | }); |
| b69ab31 | | | 618 | }); |
| b69ab31 | | | 619 | |
| b69ab31 | | | 620 | describe('amend', () => { |
| b69ab31 | | | 621 | it('runs amend with changed message', async () => { |
| b69ab31 | | | 622 | act(() => |
| b69ab31 | | | 623 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 624 | value: [{path: 'src/file1.js', status: 'M'}], |
| b69ab31 | | | 625 | }), |
| b69ab31 | | | 626 | ); |
| b69ab31 | | | 627 | |
| b69ab31 | | | 628 | act(() => { |
| b69ab31 | | | 629 | clickToEditTitle(); |
| b69ab31 | | | 630 | clickToEditDescription(); |
| b69ab31 | | | 631 | }); |
| b69ab31 | | | 632 | |
| b69ab31 | | | 633 | { |
| b69ab31 | | | 634 | act(() => { |
| b69ab31 | | | 635 | userEvent.type(getTitleEditor(), ' hello new title'); |
| b69ab31 | | | 636 | userEvent.type(getDescriptionEditor(), '\nhello new text'); |
| b69ab31 | | | 637 | }); |
| b69ab31 | | | 638 | } |
| b69ab31 | | | 639 | |
| b69ab31 | | | 640 | clickAmendButton(); |
| b69ab31 | | | 641 | |
| b69ab31 | | | 642 | await waitFor(() => |
| b69ab31 | | | 643 | expectMessageSentToServer({ |
| b69ab31 | | | 644 | type: 'runOperation', |
| b69ab31 | | | 645 | operation: { |
| b69ab31 | | | 646 | args: [ |
| b69ab31 | | | 647 | {type: 'config', key: 'amend.autorestack', value: 'always'}, |
| b69ab31 | | | 648 | 'amend', |
| b69ab31 | | | 649 | '--addremove', |
| b69ab31 | | | 650 | '--message', |
| b69ab31 | | | 651 | expect.stringMatching( |
| b69ab31 | | | 652 | /^Head Commit hello new title\n+(Summary:\s+)?stacked commit\nhello new text/, |
| b69ab31 | | | 653 | ), |
| b69ab31 | | | 654 | ], |
| b69ab31 | | | 655 | id: expect.anything(), |
| b69ab31 | | | 656 | runner: CommandRunner.Sapling, |
| b69ab31 | | | 657 | trackEventName: 'AmendOperation', |
| b69ab31 | | | 658 | }, |
| b69ab31 | | | 659 | }), |
| b69ab31 | | | 660 | ); |
| b69ab31 | | | 661 | }); |
| b69ab31 | | | 662 | |
| b69ab31 | | | 663 | it('deselects head when running amend', async () => { |
| b69ab31 | | | 664 | act(() => |
| b69ab31 | | | 665 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 666 | value: [{path: 'src/file1.js', status: 'M'}], |
| b69ab31 | | | 667 | }), |
| b69ab31 | | | 668 | ); |
| b69ab31 | | | 669 | |
| b69ab31 | | | 670 | // even though 'b' is already shown when nothing is selected, |
| b69ab31 | | | 671 | // we want to use auto-selection after amending even if you previously selected something |
| b69ab31 | | | 672 | clickToSelectCommit('b'); |
| b69ab31 | | | 673 | |
| b69ab31 | | | 674 | clickToEditTitle(); |
| b69ab31 | | | 675 | |
| b69ab31 | | | 676 | { |
| b69ab31 | | | 677 | act(() => { |
| b69ab31 | | | 678 | userEvent.type(getTitleEditor(), ' hello'); |
| b69ab31 | | | 679 | }); |
| b69ab31 | | | 680 | } |
| b69ab31 | | | 681 | |
| b69ab31 | | | 682 | clickAmendButton(); |
| b69ab31 | | | 683 | |
| b69ab31 | | | 684 | // no commit is selected anymore |
| b69ab31 | | | 685 | await waitFor(() => |
| b69ab31 | | | 686 | expect(screen.queryByTestId('selected-commit')).not.toBeInTheDocument(), |
| b69ab31 | | | 687 | ); |
| b69ab31 | | | 688 | }); |
| b69ab31 | | | 689 | |
| b69ab31 | | | 690 | it('does not deselect non-head commits after running amend', () => { |
| b69ab31 | | | 691 | act(() => { |
| b69ab31 | | | 692 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 693 | value: [{path: 'src/file1.js', status: 'M'}], |
| b69ab31 | | | 694 | }); |
| b69ab31 | | | 695 | }); |
| b69ab31 | | | 696 | |
| b69ab31 | | | 697 | clickToSelectCommit('a'); |
| b69ab31 | | | 698 | |
| b69ab31 | | | 699 | // we can't use amend button in the commit info because we're on some other commit, so use quick amend |
| b69ab31 | | | 700 | const quickAmendButton = screen.getByTestId('uncommitted-changes-quick-amend-button'); |
| b69ab31 | | | 701 | act(() => { |
| b69ab31 | | | 702 | fireEvent.click(quickAmendButton); |
| b69ab31 | | | 703 | }); |
| b69ab31 | | | 704 | |
| b69ab31 | | | 705 | // commit remains selected |
| b69ab31 | | | 706 | expect( |
| b69ab31 | | | 707 | within(screen.getByTestId('commit-a')).queryByTestId('selected-commit'), |
| b69ab31 | | | 708 | ).toBeInTheDocument(); |
| b69ab31 | | | 709 | }); |
| b69ab31 | | | 710 | |
| b69ab31 | | | 711 | it('disables amend button with spinner while running', async () => { |
| b69ab31 | | | 712 | act(() => { |
| b69ab31 | | | 713 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 714 | value: [{path: 'src/file1.js', status: 'M'}], |
| b69ab31 | | | 715 | }); |
| b69ab31 | | | 716 | }); |
| b69ab31 | | | 717 | |
| b69ab31 | | | 718 | clickAmendButton(); |
| b69ab31 | | | 719 | await waitFor(() => |
| b69ab31 | | | 720 | expectMessageSentToServer({ |
| b69ab31 | | | 721 | type: 'runOperation', |
| b69ab31 | | | 722 | operation: expect.objectContaining({ |
| b69ab31 | | | 723 | args: expect.arrayContaining(['amend']), |
| b69ab31 | | | 724 | }), |
| b69ab31 | | | 725 | }), |
| b69ab31 | | | 726 | ); |
| b69ab31 | | | 727 | |
| b69ab31 | | | 728 | act(() => { |
| b69ab31 | | | 729 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 730 | value: [{path: 'src/file2.js', status: 'M'}], |
| b69ab31 | | | 731 | }); |
| b69ab31 | | | 732 | }); |
| b69ab31 | | | 733 | |
| b69ab31 | | | 734 | const amendMessageButton = within( |
| b69ab31 | | | 735 | screen.getByTestId('commit-info-actions-bar'), |
| b69ab31 | | | 736 | ).queryByText('Amend'); |
| b69ab31 | | | 737 | act(() => { |
| b69ab31 | | | 738 | fireEvent.click(amendMessageButton!); |
| b69ab31 | | | 739 | }); |
| b69ab31 | | | 740 | |
| b69ab31 | | | 741 | expect(amendMessageButton).toBeDisabled(); |
| b69ab31 | | | 742 | }); |
| b69ab31 | | | 743 | |
| b69ab31 | | | 744 | it('shows amend message instead of amend when there are only message changes', () => { |
| b69ab31 | | | 745 | act(() => { |
| b69ab31 | | | 746 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 747 | value: [{path: 'src/file1.js', status: 'M'}], |
| b69ab31 | | | 748 | }); |
| b69ab31 | | | 749 | }); |
| b69ab31 | | | 750 | |
| b69ab31 | | | 751 | expect( |
| b69ab31 | | | 752 | within(screen.getByTestId('commit-info-actions-bar')).queryByText('Amend'), |
| b69ab31 | | | 753 | ).toBeInTheDocument(); |
| b69ab31 | | | 754 | |
| b69ab31 | | | 755 | act(() => { |
| b69ab31 | | | 756 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 757 | value: [], |
| b69ab31 | | | 758 | }); |
| b69ab31 | | | 759 | }); |
| b69ab31 | | | 760 | |
| b69ab31 | | | 761 | expect( |
| b69ab31 | | | 762 | within(screen.getByTestId('commit-info-actions-bar')).queryByText('Amend'), |
| b69ab31 | | | 763 | ).toBeInTheDocument(); |
| b69ab31 | | | 764 | |
| b69ab31 | | | 765 | act(() => { |
| b69ab31 | | | 766 | clickToEditTitle(); |
| b69ab31 | | | 767 | clickToEditDescription(); |
| b69ab31 | | | 768 | }); |
| b69ab31 | | | 769 | |
| b69ab31 | | | 770 | // no uncommitted changes, and message is being changed |
| b69ab31 | | | 771 | expect( |
| b69ab31 | | | 772 | within(screen.getByTestId('commit-info-actions-bar')).queryByText('Amend Message'), |
| b69ab31 | | | 773 | ).toBeInTheDocument(); |
| b69ab31 | | | 774 | }); |
| b69ab31 | | | 775 | }); |
| b69ab31 | | | 776 | }); |
| b69ab31 | | | 777 | |
| b69ab31 | | | 778 | describe('commit mode', () => { |
| b69ab31 | | | 779 | it('has commit mode selector on head commit', () => { |
| b69ab31 | | | 780 | expect( |
| b69ab31 | | | 781 | within(screen.getByTestId('commit-info-toolbar-top')).getByText('Amend'), |
| b69ab31 | | | 782 | ).toBeInTheDocument(); |
| b69ab31 | | | 783 | expect( |
| b69ab31 | | | 784 | within(screen.getByTestId('commit-info-toolbar-top')).getByText('Commit'), |
| b69ab31 | | | 785 | ).toBeInTheDocument(); |
| b69ab31 | | | 786 | }); |
| b69ab31 | | | 787 | |
| b69ab31 | | | 788 | it('does not have commit mode selector on non-head commits', () => { |
| b69ab31 | | | 789 | clickToSelectCommit('a'); |
| b69ab31 | | | 790 | // toolbar won't appear at all on non-head commits right now |
| b69ab31 | | | 791 | expect(screen.queryByTestId('commit-info-toolbar-top')).not.toBeInTheDocument(); |
| b69ab31 | | | 792 | }); |
| b69ab31 | | | 793 | |
| b69ab31 | | | 794 | it('clicking commit mode starts editing both fields', () => { |
| b69ab31 | | | 795 | clickCommitMode(); |
| b69ab31 | | | 796 | |
| b69ab31 | | | 797 | expectIsEditingTitle(); |
| b69ab31 | | | 798 | expectIsEditingDescription(); |
| b69ab31 | | | 799 | }); |
| b69ab31 | | | 800 | |
| b69ab31 | | | 801 | it('commit mode message is saved separately', () => { |
| b69ab31 | | | 802 | clickCommitMode(); |
| b69ab31 | | | 803 | |
| b69ab31 | | | 804 | expectIsEditingTitle(); |
| b69ab31 | | | 805 | expectIsEditingDescription(); |
| b69ab31 | | | 806 | |
| b69ab31 | | | 807 | act(() => { |
| b69ab31 | | | 808 | userEvent.type(getTitleEditor(), 'new commit title'); |
| b69ab31 | | | 809 | userEvent.type(getDescriptionEditor(), 'my description'); |
| b69ab31 | | | 810 | }); |
| b69ab31 | | | 811 | |
| b69ab31 | | | 812 | clickToSelectCommit('a'); |
| b69ab31 | | | 813 | clickToSelectCommit('b'); |
| b69ab31 | | | 814 | |
| b69ab31 | | | 815 | expectIsEditingTitle(); |
| b69ab31 | | | 816 | expectIsEditingDescription(); |
| b69ab31 | | | 817 | |
| b69ab31 | | | 818 | expect(getTitleEditor().value).toBe('new commit title'); |
| b69ab31 | | | 819 | expect(getDescriptionEditor().value).toBe('my description'); |
| b69ab31 | | | 820 | }); |
| b69ab31 | | | 821 | |
| b69ab31 | | | 822 | it('focuses title when opening commit mode', async () => { |
| b69ab31 | | | 823 | clickCommitMode(); |
| b69ab31 | | | 824 | |
| b69ab31 | | | 825 | await waitFor(() => { |
| b69ab31 | | | 826 | expect(getTitleEditor()).toHaveFocus(); |
| b69ab31 | | | 827 | expect(getDescriptionEditor()).not.toHaveFocus(); |
| b69ab31 | | | 828 | }); |
| b69ab31 | | | 829 | }); |
| b69ab31 | | | 830 | |
| b69ab31 | | | 831 | it("disables commit button if there's no changed files", () => { |
| b69ab31 | | | 832 | clickCommitMode(); |
| b69ab31 | | | 833 | |
| b69ab31 | | | 834 | const commitButton = within(screen.getByTestId('commit-info-actions-bar')).queryByText( |
| b69ab31 | | | 835 | 'Commit', |
| b69ab31 | | | 836 | ) as HTMLButtonElement; |
| b69ab31 | | | 837 | expect(commitButton).toBeInTheDocument(); |
| b69ab31 | | | 838 | expect(commitButton!.disabled).toBe(true); |
| b69ab31 | | | 839 | }); |
| b69ab31 | | | 840 | |
| b69ab31 | | | 841 | it('does not disable commit button if there are changed files', () => { |
| b69ab31 | | | 842 | act(() => { |
| b69ab31 | | | 843 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 844 | value: [ |
| b69ab31 | | | 845 | {path: 'src/file1.js', status: 'M'}, |
| b69ab31 | | | 846 | {path: 'src/file2.js', status: 'M'}, |
| b69ab31 | | | 847 | ], |
| b69ab31 | | | 848 | }); |
| b69ab31 | | | 849 | }); |
| b69ab31 | | | 850 | |
| b69ab31 | | | 851 | clickCommitMode(); |
| b69ab31 | | | 852 | |
| b69ab31 | | | 853 | const commitButton = within(screen.getByTestId('commit-info-actions-bar')).queryByText( |
| b69ab31 | | | 854 | 'Commit', |
| b69ab31 | | | 855 | ) as HTMLButtonElement; |
| b69ab31 | | | 856 | expect(commitButton).toBeInTheDocument(); |
| b69ab31 | | | 857 | expect(commitButton!.disabled).not.toBe(true); |
| b69ab31 | | | 858 | }); |
| b69ab31 | | | 859 | |
| b69ab31 | | | 860 | it('runs commit with message', async () => { |
| b69ab31 | | | 861 | act(() => { |
| b69ab31 | | | 862 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 863 | value: [ |
| b69ab31 | | | 864 | {path: 'src/file1.js', status: 'M'}, |
| b69ab31 | | | 865 | {path: 'src/file2.js', status: 'M'}, |
| b69ab31 | | | 866 | ], |
| b69ab31 | | | 867 | }); |
| b69ab31 | | | 868 | }); |
| b69ab31 | | | 869 | |
| b69ab31 | | | 870 | clickCommitMode(); |
| b69ab31 | | | 871 | |
| b69ab31 | | | 872 | act(() => { |
| b69ab31 | | | 873 | userEvent.type(getTitleEditor(), 'new commit title'); |
| b69ab31 | | | 874 | userEvent.type(getDescriptionEditor(), 'my description'); |
| b69ab31 | | | 875 | }); |
| b69ab31 | | | 876 | |
| b69ab31 | | | 877 | clickCommitButton(); |
| b69ab31 | | | 878 | |
| b69ab31 | | | 879 | await waitFor(() => |
| b69ab31 | | | 880 | expectMessageSentToServer({ |
| b69ab31 | | | 881 | type: 'runOperation', |
| b69ab31 | | | 882 | operation: { |
| b69ab31 | | | 883 | args: [ |
| b69ab31 | | | 884 | 'commit', |
| b69ab31 | | | 885 | '--addremove', |
| b69ab31 | | | 886 | '--message', |
| b69ab31 | | | 887 | expect.stringMatching(/^new commit title\n+(Summary:\s+)?my description/), |
| b69ab31 | | | 888 | ], |
| b69ab31 | | | 889 | id: expect.anything(), |
| b69ab31 | | | 890 | runner: CommandRunner.Sapling, |
| b69ab31 | | | 891 | trackEventName: 'CommitOperation', |
| b69ab31 | | | 892 | }, |
| b69ab31 | | | 893 | }), |
| b69ab31 | | | 894 | ); |
| b69ab31 | | | 895 | }); |
| b69ab31 | | | 896 | |
| b69ab31 | | | 897 | it('resets to amend mode after committing', async () => { |
| b69ab31 | | | 898 | act(() => { |
| b69ab31 | | | 899 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 900 | value: [ |
| b69ab31 | | | 901 | {path: 'src/file1.js', status: 'M'}, |
| b69ab31 | | | 902 | {path: 'src/file2.js', status: 'M'}, |
| b69ab31 | | | 903 | ], |
| b69ab31 | | | 904 | }); |
| b69ab31 | | | 905 | }); |
| b69ab31 | | | 906 | |
| b69ab31 | | | 907 | clickCommitMode(); |
| b69ab31 | | | 908 | |
| b69ab31 | | | 909 | act(() => { |
| b69ab31 | | | 910 | userEvent.type(getTitleEditor(), 'new commit title'); |
| b69ab31 | | | 911 | userEvent.type(getDescriptionEditor(), 'my description'); |
| b69ab31 | | | 912 | }); |
| b69ab31 | | | 913 | |
| b69ab31 | | | 914 | clickCommitButton(); |
| b69ab31 | | | 915 | |
| b69ab31 | | | 916 | await waitFor(() => |
| b69ab31 | | | 917 | expectMessageSentToServer({ |
| b69ab31 | | | 918 | type: 'runOperation', |
| b69ab31 | | | 919 | operation: expect.objectContaining({ |
| b69ab31 | | | 920 | args: expect.arrayContaining(['commit']), |
| b69ab31 | | | 921 | }), |
| b69ab31 | | | 922 | }), |
| b69ab31 | | | 923 | ); |
| b69ab31 | | | 924 | |
| b69ab31 | | | 925 | const commitButtonAfter = within( |
| b69ab31 | | | 926 | screen.getByTestId('commit-info-actions-bar'), |
| b69ab31 | | | 927 | ).queryByText('Commit'); |
| b69ab31 | | | 928 | expect(commitButtonAfter).not.toBeInTheDocument(); |
| b69ab31 | | | 929 | }); |
| b69ab31 | | | 930 | |
| b69ab31 | | | 931 | it('does not have cancel button', () => { |
| b69ab31 | | | 932 | clickCommitMode(); |
| b69ab31 | | | 933 | |
| b69ab31 | | | 934 | const cancelButton: HTMLButtonElement | null = withinCommitInfo().queryByText('Cancel'); |
| b69ab31 | | | 935 | expect(cancelButton).not.toBeInTheDocument(); |
| b69ab31 | | | 936 | }); |
| b69ab31 | | | 937 | }); |
| b69ab31 | | | 938 | |
| b69ab31 | | | 939 | describe('edited messages indicator', () => { |
| b69ab31 | | | 940 | it('does not show edited message indicator when fields are not actually changed', () => { |
| b69ab31 | | | 941 | act(() => { |
| b69ab31 | | | 942 | clickToEditTitle(); |
| b69ab31 | | | 943 | clickToEditDescription(); |
| b69ab31 | | | 944 | }); |
| b69ab31 | | | 945 | expectIsEditingTitle(); |
| b69ab31 | | | 946 | expectIsEditingDescription(); |
| b69ab31 | | | 947 | |
| b69ab31 | | | 948 | expect(screen.queryByTestId('unsaved-message-indicator')).not.toBeInTheDocument(); |
| b69ab31 | | | 949 | |
| b69ab31 | | | 950 | { |
| b69ab31 | | | 951 | act(() => { |
| b69ab31 | | | 952 | // type something and delete it |
| b69ab31 | | | 953 | userEvent.type(getTitleEditor(), 'Q{Backspace}'); |
| b69ab31 | | | 954 | userEvent.type(getDescriptionEditor(), 'Q{Backspace}'); |
| b69ab31 | | | 955 | }); |
| b69ab31 | | | 956 | } |
| b69ab31 | | | 957 | |
| b69ab31 | | | 958 | expect(screen.queryByTestId('unsaved-message-indicator')).not.toBeInTheDocument(); |
| b69ab31 | | | 959 | }); |
| b69ab31 | | | 960 | |
| b69ab31 | | | 961 | it('shows edited message indicator when title changed', () => { |
| b69ab31 | | | 962 | act(() => { |
| b69ab31 | | | 963 | clickToEditTitle(); |
| b69ab31 | | | 964 | clickToEditDescription(); |
| b69ab31 | | | 965 | }); |
| b69ab31 | | | 966 | |
| b69ab31 | | | 967 | expect(screen.queryByTestId('unsaved-message-indicator')).not.toBeInTheDocument(); |
| b69ab31 | | | 968 | |
| b69ab31 | | | 969 | { |
| b69ab31 | | | 970 | act(() => { |
| b69ab31 | | | 971 | userEvent.type(getTitleEditor(), 'Q'); |
| b69ab31 | | | 972 | }); |
| b69ab31 | | | 973 | } |
| b69ab31 | | | 974 | |
| b69ab31 | | | 975 | expect(screen.queryByTestId('unsaved-message-indicator')).toBeInTheDocument(); |
| b69ab31 | | | 976 | expect( |
| b69ab31 | | | 977 | within(screen.queryByTestId('commit-b')!).queryByTestId('unsaved-message-indicator'), |
| b69ab31 | | | 978 | ).toBeInTheDocument(); |
| b69ab31 | | | 979 | }); |
| b69ab31 | | | 980 | |
| b69ab31 | | | 981 | it('shows edited message indicator when description changed', () => { |
| b69ab31 | | | 982 | act(() => { |
| b69ab31 | | | 983 | clickToEditTitle(); |
| b69ab31 | | | 984 | clickToEditDescription(); |
| b69ab31 | | | 985 | }); |
| b69ab31 | | | 986 | |
| b69ab31 | | | 987 | expect(screen.queryByTestId('unsaved-message-indicator')).not.toBeInTheDocument(); |
| b69ab31 | | | 988 | |
| b69ab31 | | | 989 | { |
| b69ab31 | | | 990 | act(() => { |
| b69ab31 | | | 991 | userEvent.type(getDescriptionEditor(), 'Q'); |
| b69ab31 | | | 992 | }); |
| b69ab31 | | | 993 | } |
| b69ab31 | | | 994 | |
| b69ab31 | | | 995 | expect(screen.queryByTestId('unsaved-message-indicator')).toBeInTheDocument(); |
| b69ab31 | | | 996 | expect( |
| b69ab31 | | | 997 | within(screen.queryByTestId('commit-b')!).queryByTestId('unsaved-message-indicator'), |
| b69ab31 | | | 998 | ).toBeInTheDocument(); |
| b69ab31 | | | 999 | }); |
| b69ab31 | | | 1000 | |
| b69ab31 | | | 1001 | it('appears for other commits', () => { |
| b69ab31 | | | 1002 | clickToSelectCommit('a'); |
| b69ab31 | | | 1003 | |
| b69ab31 | | | 1004 | act(() => { |
| b69ab31 | | | 1005 | clickToEditTitle(); |
| b69ab31 | | | 1006 | clickToEditDescription(); |
| b69ab31 | | | 1007 | }); |
| b69ab31 | | | 1008 | |
| b69ab31 | | | 1009 | expect(screen.queryByTestId('unsaved-message-indicator')).not.toBeInTheDocument(); |
| b69ab31 | | | 1010 | |
| b69ab31 | | | 1011 | { |
| b69ab31 | | | 1012 | act(() => { |
| b69ab31 | | | 1013 | userEvent.type(getTitleEditor(), 'Q'); |
| b69ab31 | | | 1014 | userEvent.type(getDescriptionEditor(), 'Q'); |
| b69ab31 | | | 1015 | }); |
| b69ab31 | | | 1016 | } |
| b69ab31 | | | 1017 | |
| b69ab31 | | | 1018 | expect(screen.queryByTestId('unsaved-message-indicator')).toBeInTheDocument(); |
| b69ab31 | | | 1019 | expect( |
| b69ab31 | | | 1020 | within(screen.queryByTestId('commit-a')!).queryByTestId('unsaved-message-indicator'), |
| b69ab31 | | | 1021 | ).toBeInTheDocument(); |
| b69ab31 | | | 1022 | }); |
| b69ab31 | | | 1023 | |
| b69ab31 | | | 1024 | it('commit mode does not cause indicator', () => { |
| b69ab31 | | | 1025 | clickCommitMode(); |
| b69ab31 | | | 1026 | |
| b69ab31 | | | 1027 | { |
| b69ab31 | | | 1028 | act(() => { |
| b69ab31 | | | 1029 | userEvent.type(getTitleEditor(), 'Q'); |
| b69ab31 | | | 1030 | userEvent.type(getDescriptionEditor(), 'Q'); |
| b69ab31 | | | 1031 | }); |
| b69ab31 | | | 1032 | } |
| b69ab31 | | | 1033 | expect(screen.queryByTestId('unsaved-message-indicator')).not.toBeInTheDocument(); |
| b69ab31 | | | 1034 | }); |
| b69ab31 | | | 1035 | }); |
| b69ab31 | | | 1036 | |
| b69ab31 | | | 1037 | describe('commit message template', () => { |
| b69ab31 | | | 1038 | it('requests commit template when opening commit form', () => { |
| b69ab31 | | | 1039 | clickCommitMode(); |
| b69ab31 | | | 1040 | expectMessageSentToServer({type: 'fetchCommitMessageTemplate'}); |
| b69ab31 | | | 1041 | }); |
| b69ab31 | | | 1042 | |
| b69ab31 | | | 1043 | it('loads template sent by server', () => { |
| b69ab31 | | | 1044 | clickCommitMode(); |
| b69ab31 | | | 1045 | act(() => { |
| b69ab31 | | | 1046 | simulateMessageFromServer({ |
| b69ab31 | | | 1047 | type: 'fetchedCommitMessageTemplate', |
| b69ab31 | | | 1048 | template: '[isl]\nSummary: Hello\nTest Plan:\n', |
| b69ab31 | | | 1049 | }); |
| b69ab31 | | | 1050 | }); |
| b69ab31 | | | 1051 | |
| b69ab31 | | | 1052 | expect(getTitleEditor().value).toBe('[isl]'); |
| b69ab31 | | | 1053 | expect(getDescriptionEditor().value).toEqual(expect.stringMatching(/(Summary: )?Hello/)); |
| b69ab31 | | | 1054 | }); |
| b69ab31 | | | 1055 | |
| b69ab31 | | | 1056 | it('only asynchronously overwrites default commit fields', () => { |
| b69ab31 | | | 1057 | clickCommitMode(); |
| b69ab31 | | | 1058 | |
| b69ab31 | | | 1059 | // type something in fields... |
| b69ab31 | | | 1060 | { |
| b69ab31 | | | 1061 | act(() => { |
| b69ab31 | | | 1062 | userEvent.type(getTitleEditor(), 'Q'); |
| b69ab31 | | | 1063 | userEvent.type(getDescriptionEditor(), 'W'); |
| b69ab31 | | | 1064 | }); |
| b69ab31 | | | 1065 | } |
| b69ab31 | | | 1066 | |
| b69ab31 | | | 1067 | // template arrives from server later |
| b69ab31 | | | 1068 | act(() => { |
| b69ab31 | | | 1069 | simulateMessageFromServer({ |
| b69ab31 | | | 1070 | type: 'fetchedCommitMessageTemplate', |
| b69ab31 | | | 1071 | template: '[isl]\nSummary:\nTest Plan:\n', |
| b69ab31 | | | 1072 | }); |
| b69ab31 | | | 1073 | }); |
| b69ab31 | | | 1074 | |
| b69ab31 | | | 1075 | // template shouldn't have overwritten fields since they're non-default now |
| b69ab31 | | | 1076 | expect(getTitleEditor().value).toBe('Q'); |
| b69ab31 | | | 1077 | expect(getDescriptionEditor().value).toBe('W'); |
| b69ab31 | | | 1078 | }); |
| b69ab31 | | | 1079 | }); |
| b69ab31 | | | 1080 | |
| b69ab31 | | | 1081 | describe('discarding message', () => { |
| b69ab31 | | | 1082 | it('confirms cancel button if you have made changes to the title', async () => { |
| b69ab31 | | | 1083 | clickToEditTitle(); |
| b69ab31 | | | 1084 | const confirmSpy = jest |
| b69ab31 | | | 1085 | .spyOn(platform, 'confirm') |
| b69ab31 | | | 1086 | .mockImplementation(() => Promise.resolve(true)); |
| b69ab31 | | | 1087 | |
| b69ab31 | | | 1088 | act(() => { |
| b69ab31 | | | 1089 | userEvent.type(getTitleEditor(), 'Q'); |
| b69ab31 | | | 1090 | }); |
| b69ab31 | | | 1091 | |
| b69ab31 | | | 1092 | clickCancel(); |
| b69ab31 | | | 1093 | |
| b69ab31 | | | 1094 | await waitFor(() => { |
| b69ab31 | | | 1095 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 1096 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 1097 | }); |
| b69ab31 | | | 1098 | expect(confirmSpy).toHaveBeenCalled(); |
| b69ab31 | | | 1099 | }); |
| b69ab31 | | | 1100 | |
| b69ab31 | | | 1101 | it('confirms cancel button if you have made changes to the description', async () => { |
| b69ab31 | | | 1102 | clickToEditDescription(); |
| b69ab31 | | | 1103 | const confirmSpy = jest |
| b69ab31 | | | 1104 | .spyOn(platform, 'confirm') |
| b69ab31 | | | 1105 | .mockImplementation(() => Promise.resolve(true)); |
| b69ab31 | | | 1106 | |
| b69ab31 | | | 1107 | act(() => { |
| b69ab31 | | | 1108 | userEvent.type(getDescriptionEditor(), 'W'); |
| b69ab31 | | | 1109 | }); |
| b69ab31 | | | 1110 | |
| b69ab31 | | | 1111 | clickCancel(); |
| b69ab31 | | | 1112 | |
| b69ab31 | | | 1113 | await waitFor(() => { |
| b69ab31 | | | 1114 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 1115 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 1116 | }); |
| b69ab31 | | | 1117 | expect(confirmSpy).toHaveBeenCalled(); |
| b69ab31 | | | 1118 | }); |
| b69ab31 | | | 1119 | |
| b69ab31 | | | 1120 | it('does not cancel if you do not confirm', async () => { |
| b69ab31 | | | 1121 | act(() => { |
| b69ab31 | | | 1122 | clickToEditTitle(); |
| b69ab31 | | | 1123 | clickToEditDescription(); |
| b69ab31 | | | 1124 | }); |
| b69ab31 | | | 1125 | const confirmSpy = jest |
| b69ab31 | | | 1126 | .spyOn(platform, 'confirm') |
| b69ab31 | | | 1127 | .mockImplementation(() => Promise.resolve(false)); |
| b69ab31 | | | 1128 | |
| b69ab31 | | | 1129 | act(() => { |
| b69ab31 | | | 1130 | userEvent.type(getTitleEditor(), 'Q'); |
| b69ab31 | | | 1131 | userEvent.type(getDescriptionEditor(), 'W'); |
| b69ab31 | | | 1132 | }); |
| b69ab31 | | | 1133 | |
| b69ab31 | | | 1134 | clickCancel(); |
| b69ab31 | | | 1135 | |
| b69ab31 | | | 1136 | await waitFor(() => { |
| b69ab31 | | | 1137 | expectIsEditingTitle(); |
| b69ab31 | | | 1138 | expectIsEditingDescription(); |
| b69ab31 | | | 1139 | |
| b69ab31 | | | 1140 | expect(getTitleEditor().value).toBe('Head CommitQ'); |
| b69ab31 | | | 1141 | expect(getDescriptionEditor().value).toEqual( |
| b69ab31 | | | 1142 | expect.stringContaining('stacked commitW'), |
| b69ab31 | | | 1143 | ); |
| b69ab31 | | | 1144 | }); |
| b69ab31 | | | 1145 | expect(confirmSpy).toHaveBeenCalled(); |
| b69ab31 | | | 1146 | }); |
| b69ab31 | | | 1147 | |
| b69ab31 | | | 1148 | it('does not confirm when clearing for amend', async () => { |
| b69ab31 | | | 1149 | act(() => |
| b69ab31 | | | 1150 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 1151 | value: [{path: 'src/file1.js', status: 'M'}], |
| b69ab31 | | | 1152 | }), |
| b69ab31 | | | 1153 | ); |
| b69ab31 | | | 1154 | |
| b69ab31 | | | 1155 | clickToEditDescription(); |
| b69ab31 | | | 1156 | const confirmSpy = jest.spyOn(platform, 'confirm'); |
| b69ab31 | | | 1157 | |
| b69ab31 | | | 1158 | act(() => { |
| b69ab31 | | | 1159 | userEvent.type(getDescriptionEditor(), 'W'); |
| b69ab31 | | | 1160 | }); |
| b69ab31 | | | 1161 | |
| b69ab31 | | | 1162 | clickAmendButton(); |
| b69ab31 | | | 1163 | |
| b69ab31 | | | 1164 | await waitForWithTick(() => { |
| b69ab31 | | | 1165 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 1166 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 1167 | expect(confirmSpy).not.toHaveBeenCalled(); |
| b69ab31 | | | 1168 | }); |
| b69ab31 | | | 1169 | }); |
| b69ab31 | | | 1170 | }); |
| b69ab31 | | | 1171 | |
| b69ab31 | | | 1172 | describe('optimistic state', () => { |
| b69ab31 | | | 1173 | it('takes previews into account when rendering head', async () => { |
| b69ab31 | | | 1174 | await CommitTreeListTestUtils.clickGoto('a'); |
| b69ab31 | | | 1175 | // while optimistic state happening... |
| b69ab31 | | | 1176 | // show new commit in commit info without clicking it (because head is auto-selected) |
| b69ab31 | | | 1177 | expect(withinCommitInfo().queryByText('My Commit')).toBeInTheDocument(); |
| b69ab31 | | | 1178 | expect(withinCommitInfo().queryByText('You are here')).toBeInTheDocument(); |
| b69ab31 | | | 1179 | }); |
| b69ab31 | | | 1180 | |
| b69ab31 | | | 1181 | it('shows new head when running goto', async () => { |
| b69ab31 | | | 1182 | clickToSelectCommit('b'); // explicitly select |
| b69ab31 | | | 1183 | await CommitTreeListTestUtils.clickGoto('a'); |
| b69ab31 | | | 1184 | |
| b69ab31 | | | 1185 | expect(withinCommitInfo().queryByText('My Commit')).toBeInTheDocument(); |
| b69ab31 | | | 1186 | expect(withinCommitInfo().queryByText('You are here')).toBeInTheDocument(); |
| b69ab31 | | | 1187 | }); |
| b69ab31 | | | 1188 | |
| b69ab31 | | | 1189 | it('renders metaedit operation smoothly', async () => { |
| b69ab31 | | | 1190 | clickToSelectCommit('a'); |
| b69ab31 | | | 1191 | |
| b69ab31 | | | 1192 | act(() => { |
| b69ab31 | | | 1193 | clickToEditTitle(); |
| b69ab31 | | | 1194 | clickToEditDescription(); |
| b69ab31 | | | 1195 | }); |
| b69ab31 | | | 1196 | act(() => { |
| b69ab31 | | | 1197 | userEvent.type(getTitleEditor(), ' with change!'); |
| b69ab31 | | | 1198 | userEvent.type(getDescriptionEditor(), '\nmore stuff!'); |
| b69ab31 | | | 1199 | }); |
| b69ab31 | | | 1200 | |
| b69ab31 | | | 1201 | const amendMessageButton = within( |
| b69ab31 | | | 1202 | screen.getByTestId('commit-info-actions-bar'), |
| b69ab31 | | | 1203 | ).queryByText('Amend Message'); |
| b69ab31 | | | 1204 | act(() => { |
| b69ab31 | | | 1205 | fireEvent.click(amendMessageButton!); |
| b69ab31 | | | 1206 | }); |
| b69ab31 | | | 1207 | |
| b69ab31 | | | 1208 | await waitFor(() => { |
| b69ab31 | | | 1209 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 1210 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 1211 | |
| b69ab31 | | | 1212 | expect(withinCommitInfo().getByText('My Commit with change!')).toBeInTheDocument(); |
| b69ab31 | | | 1213 | expect( |
| b69ab31 | | | 1214 | withinCommitInfo().getByText(/First commit in the stack\nmore stuff!/, { |
| b69ab31 | | | 1215 | collapseWhitespace: false, |
| b69ab31 | | | 1216 | }), |
| b69ab31 | | | 1217 | ).toBeInTheDocument(); |
| b69ab31 | | | 1218 | }); |
| b69ab31 | | | 1219 | }); |
| b69ab31 | | | 1220 | |
| b69ab31 | | | 1221 | it('renders commit operation smoothly', async () => { |
| b69ab31 | | | 1222 | act(() => { |
| b69ab31 | | | 1223 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 1224 | value: [{path: 'src/file1.js', status: 'M'}], |
| b69ab31 | | | 1225 | }); |
| b69ab31 | | | 1226 | }); |
| b69ab31 | | | 1227 | |
| b69ab31 | | | 1228 | clickCommitMode(); |
| b69ab31 | | | 1229 | act(() => { |
| b69ab31 | | | 1230 | userEvent.type(getTitleEditor(), 'New Commit'); |
| b69ab31 | | | 1231 | userEvent.type(getDescriptionEditor(), 'Message!'); |
| b69ab31 | | | 1232 | }); |
| b69ab31 | | | 1233 | |
| b69ab31 | | | 1234 | clickCommitButton(); |
| b69ab31 | | | 1235 | |
| b69ab31 | | | 1236 | // optimistic state should now be rendered, so we show a fake commit with the new title, |
| b69ab31 | | | 1237 | // but not in editing mode anymore |
| b69ab31 | | | 1238 | |
| b69ab31 | | | 1239 | await waitFor(() => { |
| b69ab31 | | | 1240 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 1241 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 1242 | |
| b69ab31 | | | 1243 | expect(withinCommitInfo().queryByText('New Commit')).toBeInTheDocument(); |
| b69ab31 | | | 1244 | expect(withinCommitInfo().queryByText(/Message!/)).toBeInTheDocument(); |
| b69ab31 | | | 1245 | expect(withinCommitInfo().queryByText('You are here')).toBeInTheDocument(); |
| b69ab31 | | | 1246 | }); |
| b69ab31 | | | 1247 | |
| b69ab31 | | | 1248 | // finish commit operation with hg log |
| b69ab31 | | | 1249 | act(() => { |
| b69ab31 | | | 1250 | simulateCommits({ |
| b69ab31 | | | 1251 | value: [ |
| b69ab31 | | | 1252 | COMMIT('1', 'some public base', '0', {phase: 'public'}), |
| b69ab31 | | | 1253 | COMMIT('a', 'My Commit', '1'), |
| b69ab31 | | | 1254 | COMMIT('b', 'Head Commit', 'a'), |
| b69ab31 | | | 1255 | COMMIT('c', 'New Commit', 'b', { |
| b69ab31 | | | 1256 | isDot: true, |
| b69ab31 | | | 1257 | description: 'Summary: Message!', |
| b69ab31 | | | 1258 | }), |
| b69ab31 | | | 1259 | ], |
| b69ab31 | | | 1260 | }); |
| b69ab31 | | | 1261 | }); |
| b69ab31 | | | 1262 | expect(withinCommitInfo().queryByText('New Commit')).toBeInTheDocument(); |
| b69ab31 | | | 1263 | expect(withinCommitInfo().getByText(/Message!/)).toBeInTheDocument(); |
| b69ab31 | | | 1264 | expect(withinCommitInfo().queryByText('You are here')).toBeInTheDocument(); |
| b69ab31 | | | 1265 | }); |
| b69ab31 | | | 1266 | |
| b69ab31 | | | 1267 | it('doesnt let you edit on optimistic commit', async () => { |
| b69ab31 | | | 1268 | act(() => { |
| b69ab31 | | | 1269 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 1270 | value: [{path: 'src/file1.js', status: 'M'}], |
| b69ab31 | | | 1271 | }); |
| b69ab31 | | | 1272 | }); |
| b69ab31 | | | 1273 | |
| b69ab31 | | | 1274 | clickCommitMode(); |
| b69ab31 | | | 1275 | act(() => { |
| b69ab31 | | | 1276 | userEvent.type(getTitleEditor(), 'New Commit'); |
| b69ab31 | | | 1277 | userEvent.type(getDescriptionEditor(), 'Message!'); |
| b69ab31 | | | 1278 | }); |
| b69ab31 | | | 1279 | clickCommitButton(); |
| b69ab31 | | | 1280 | |
| b69ab31 | | | 1281 | await waitFor(() => |
| b69ab31 | | | 1282 | expectMessageSentToServer({ |
| b69ab31 | | | 1283 | type: 'runOperation', |
| b69ab31 | | | 1284 | operation: expect.objectContaining({ |
| b69ab31 | | | 1285 | args: expect.arrayContaining(['commit']), |
| b69ab31 | | | 1286 | }), |
| b69ab31 | | | 1287 | }), |
| b69ab31 | | | 1288 | ); |
| b69ab31 | | | 1289 | |
| b69ab31 | | | 1290 | clickToEditTitle(); |
| b69ab31 | | | 1291 | clickToEditDescription(); |
| b69ab31 | | | 1292 | // cannot click to edit optimistic commit |
| b69ab31 | | | 1293 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 1294 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 1295 | |
| b69ab31 | | | 1296 | // finish commit operation with hg log |
| b69ab31 | | | 1297 | act(() => { |
| b69ab31 | | | 1298 | simulateCommits({ |
| b69ab31 | | | 1299 | value: [ |
| b69ab31 | | | 1300 | COMMIT('1', 'some public base', '0', {phase: 'public'}), |
| b69ab31 | | | 1301 | COMMIT('a', 'My Commit', '1'), |
| b69ab31 | | | 1302 | COMMIT('b', 'Head Commit', 'a'), |
| b69ab31 | | | 1303 | COMMIT('c', 'New Commit', 'b', {isDot: true, description: 'Summary: Message!'}), |
| b69ab31 | | | 1304 | ], |
| b69ab31 | | | 1305 | }); |
| b69ab31 | | | 1306 | }); |
| b69ab31 | | | 1307 | |
| b69ab31 | | | 1308 | act(() => { |
| b69ab31 | | | 1309 | clickToEditTitle(); |
| b69ab31 | | | 1310 | clickToEditDescription(); |
| b69ab31 | | | 1311 | }); |
| b69ab31 | | | 1312 | // now you can edit just fine |
| b69ab31 | | | 1313 | expectIsEditingTitle(); |
| b69ab31 | | | 1314 | expectIsEditingDescription(); |
| b69ab31 | | | 1315 | }); |
| b69ab31 | | | 1316 | |
| b69ab31 | | | 1317 | it('renders amend operation smoothly', async () => { |
| b69ab31 | | | 1318 | act(() => |
| b69ab31 | | | 1319 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 1320 | value: [{path: 'src/file1.js', status: 'M'}], |
| b69ab31 | | | 1321 | }), |
| b69ab31 | | | 1322 | ); |
| b69ab31 | | | 1323 | |
| b69ab31 | | | 1324 | act(() => { |
| b69ab31 | | | 1325 | clickToEditTitle(); |
| b69ab31 | | | 1326 | clickToEditDescription(); |
| b69ab31 | | | 1327 | }); |
| b69ab31 | | | 1328 | act(() => { |
| b69ab31 | | | 1329 | userEvent.type(getTitleEditor(), ' Hey'); |
| b69ab31 | | | 1330 | userEvent.type(getDescriptionEditor(), '\nHello'); |
| b69ab31 | | | 1331 | }); |
| b69ab31 | | | 1332 | |
| b69ab31 | | | 1333 | clickAmendButton(); |
| b69ab31 | | | 1334 | |
| b69ab31 | | | 1335 | // optimistic state should now be rendered, so we update the head commit |
| b69ab31 | | | 1336 | // but not in editing mode anymore |
| b69ab31 | | | 1337 | |
| b69ab31 | | | 1338 | await waitFor(() => { |
| b69ab31 | | | 1339 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 1340 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 1341 | |
| b69ab31 | | | 1342 | expect(withinCommitInfo().getByText('Head Commit Hey')).toBeInTheDocument(); |
| b69ab31 | | | 1343 | expect( |
| b69ab31 | | | 1344 | withinCommitInfo().getByText(/stacked commit\nHello/, { |
| b69ab31 | | | 1345 | collapseWhitespace: false, |
| b69ab31 | | | 1346 | }), |
| b69ab31 | | | 1347 | ).toBeInTheDocument(); |
| b69ab31 | | | 1348 | expect(withinCommitInfo().getByText('You are here')).toBeInTheDocument(); |
| b69ab31 | | | 1349 | }); |
| b69ab31 | | | 1350 | |
| b69ab31 | | | 1351 | // finish amend operation with hg log |
| b69ab31 | | | 1352 | act(() => { |
| b69ab31 | | | 1353 | simulateCommits({ |
| b69ab31 | | | 1354 | value: [ |
| b69ab31 | | | 1355 | COMMIT('1', 'some public base', '0', {phase: 'public'}), |
| b69ab31 | | | 1356 | COMMIT('a', 'My Commit', '1'), |
| b69ab31 | | | 1357 | COMMIT('b2', 'Head Commit Hey', 'a', { |
| b69ab31 | | | 1358 | isDot: true, |
| b69ab31 | | | 1359 | description: 'Summary: stacked commit\nHello', |
| b69ab31 | | | 1360 | }), |
| b69ab31 | | | 1361 | ], |
| b69ab31 | | | 1362 | }); |
| b69ab31 | | | 1363 | }); |
| b69ab31 | | | 1364 | expect(withinCommitInfo().getByText('Head Commit Hey')).toBeInTheDocument(); |
| b69ab31 | | | 1365 | expect( |
| b69ab31 | | | 1366 | withinCommitInfo().getByText(/stacked commit\nHello/, { |
| b69ab31 | | | 1367 | collapseWhitespace: false, |
| b69ab31 | | | 1368 | }), |
| b69ab31 | | | 1369 | ).toBeInTheDocument(); |
| b69ab31 | | | 1370 | expect(withinCommitInfo().getByText('You are here')).toBeInTheDocument(); |
| b69ab31 | | | 1371 | }); |
| b69ab31 | | | 1372 | }); |
| b69ab31 | | | 1373 | |
| b69ab31 | | | 1374 | describe('Opening form in edit mode from uncommitted changes', () => { |
| b69ab31 | | | 1375 | beforeEach(() => { |
| b69ab31 | | | 1376 | act(() => { |
| b69ab31 | | | 1377 | simulateUncommittedChangedFiles({ |
| b69ab31 | | | 1378 | value: [{path: 'src/file1.js', status: 'M'}], |
| b69ab31 | | | 1379 | }); |
| b69ab31 | | | 1380 | }); |
| b69ab31 | | | 1381 | }); |
| b69ab31 | | | 1382 | |
| b69ab31 | | | 1383 | const clickAmendAs = async () => { |
| b69ab31 | | | 1384 | const amendAsButton = screen.getByText('Amend as...'); |
| b69ab31 | | | 1385 | act(() => { |
| b69ab31 | | | 1386 | fireEvent.click(amendAsButton!); |
| b69ab31 | | | 1387 | }); |
| b69ab31 | | | 1388 | |
| b69ab31 | | | 1389 | await waitFor(() => { |
| b69ab31 | | | 1390 | expectIsEditingTitle(); |
| b69ab31 | | | 1391 | expectIsEditingDescription(); |
| b69ab31 | | | 1392 | }); |
| b69ab31 | | | 1393 | }; |
| b69ab31 | | | 1394 | const clickCommitAs = () => { |
| b69ab31 | | | 1395 | const commitAsButton = screen.getByText('Commit as...'); |
| b69ab31 | | | 1396 | act(() => { |
| b69ab31 | | | 1397 | fireEvent.click(commitAsButton!); |
| b69ab31 | | | 1398 | }); |
| b69ab31 | | | 1399 | }; |
| b69ab31 | | | 1400 | |
| b69ab31 | | | 1401 | it('Opens form if closed', async () => { |
| b69ab31 | | | 1402 | act(() => { |
| b69ab31 | | | 1403 | closeCommitInfoSidebar(); |
| b69ab31 | | | 1404 | }); |
| b69ab31 | | | 1405 | |
| b69ab31 | | | 1406 | await clickAmendAs(); |
| b69ab31 | | | 1407 | |
| b69ab31 | | | 1408 | expect(screen.getByTestId('commit-info-view')).toBeInTheDocument(); |
| b69ab31 | | | 1409 | }); |
| b69ab31 | | | 1410 | |
| b69ab31 | | | 1411 | it('Deselects so head commit is shown', async () => { |
| b69ab31 | | | 1412 | clickToSelectCommit('a'); |
| b69ab31 | | | 1413 | await clickAmendAs(); |
| b69ab31 | | | 1414 | |
| b69ab31 | | | 1415 | await waitFor(() => { |
| b69ab31 | | | 1416 | // no commit is selected anymore |
| b69ab31 | | | 1417 | expect(screen.queryByTestId('selected-commit')).not.toBeInTheDocument(); |
| b69ab31 | | | 1418 | expect(withinCommitInfo().queryByText('Head Commit')).toBeInTheDocument(); |
| b69ab31 | | | 1419 | }); |
| b69ab31 | | | 1420 | }); |
| b69ab31 | | | 1421 | |
| b69ab31 | | | 1422 | describe('Amend as...', () => { |
| b69ab31 | | | 1423 | it('Opens form in amend mode', async () => { |
| b69ab31 | | | 1424 | clickCommitMode(); |
| b69ab31 | | | 1425 | await clickAmendAs(); |
| b69ab31 | | | 1426 | |
| b69ab31 | | | 1427 | const amendButton: HTMLButtonElement | null = within( |
| b69ab31 | | | 1428 | screen.getByTestId('commit-info-actions-bar'), |
| b69ab31 | | | 1429 | ).queryByText('Amend'); |
| b69ab31 | | | 1430 | expect(amendButton).toBeInTheDocument(); |
| b69ab31 | | | 1431 | }); |
| b69ab31 | | | 1432 | |
| b69ab31 | | | 1433 | it('starts editing fields', async () => { |
| b69ab31 | | | 1434 | clickCommitMode(); |
| b69ab31 | | | 1435 | await clickAmendAs(); |
| b69ab31 | | | 1436 | |
| b69ab31 | | | 1437 | await waitFor(() => { |
| b69ab31 | | | 1438 | expectIsEditingTitle(); |
| b69ab31 | | | 1439 | expectIsEditingDescription(); |
| b69ab31 | | | 1440 | }); |
| b69ab31 | | | 1441 | }); |
| b69ab31 | | | 1442 | |
| b69ab31 | | | 1443 | it('focuses fields', async () => { |
| b69ab31 | | | 1444 | await clickAmendAs(); |
| b69ab31 | | | 1445 | |
| b69ab31 | | | 1446 | await waitFor(() => { |
| b69ab31 | | | 1447 | expect(getTitleEditor()).toHaveFocus(); |
| b69ab31 | | | 1448 | }); |
| b69ab31 | | | 1449 | }); |
| b69ab31 | | | 1450 | }); |
| b69ab31 | | | 1451 | |
| b69ab31 | | | 1452 | describe('Commit as...', () => { |
| b69ab31 | | | 1453 | it('Opens form in commit mode', () => { |
| b69ab31 | | | 1454 | clickCommitAs(); |
| b69ab31 | | | 1455 | |
| b69ab31 | | | 1456 | const commitButton: HTMLButtonElement | null = within( |
| b69ab31 | | | 1457 | screen.getByTestId('commit-info-actions-bar'), |
| b69ab31 | | | 1458 | ).queryByText('Commit'); |
| b69ab31 | | | 1459 | expect(commitButton).toBeInTheDocument(); |
| b69ab31 | | | 1460 | }); |
| b69ab31 | | | 1461 | |
| b69ab31 | | | 1462 | it('focuses fields', async () => { |
| b69ab31 | | | 1463 | clickCommitAs(); |
| b69ab31 | | | 1464 | |
| b69ab31 | | | 1465 | await waitFor(() => { |
| b69ab31 | | | 1466 | expect(getTitleEditor()).toHaveFocus(); |
| b69ab31 | | | 1467 | }); |
| b69ab31 | | | 1468 | }); |
| b69ab31 | | | 1469 | |
| b69ab31 | | | 1470 | it('focuses fields even if amend fields already being edited', async () => { |
| b69ab31 | | | 1471 | await clickAmendAs(); |
| b69ab31 | | | 1472 | |
| b69ab31 | | | 1473 | await waitFor(() => { |
| b69ab31 | | | 1474 | expect(getTitleEditor()).toHaveFocus(); |
| b69ab31 | | | 1475 | }); |
| b69ab31 | | | 1476 | expect(getTitleEditor().value).toEqual('Head Commit'); |
| b69ab31 | | | 1477 | |
| b69ab31 | | | 1478 | act(() => { |
| b69ab31 | | | 1479 | // explicitly blur title so "commit as" really has to focus it again |
| b69ab31 | | | 1480 | getTitleEditor().blur(); |
| b69ab31 | | | 1481 | }); |
| b69ab31 | | | 1482 | |
| b69ab31 | | | 1483 | clickCommitAs(); |
| b69ab31 | | | 1484 | |
| b69ab31 | | | 1485 | await waitFor(() => { |
| b69ab31 | | | 1486 | expect(getTitleEditor().value).toEqual(''); |
| b69ab31 | | | 1487 | }); |
| b69ab31 | | | 1488 | expect(getTitleEditor()).toHaveFocus(); |
| b69ab31 | | | 1489 | }); |
| b69ab31 | | | 1490 | |
| b69ab31 | | | 1491 | it('copies commit title from quick commit form', () => { |
| b69ab31 | | | 1492 | const title = screen.getByTestId('quick-commit-title'); |
| b69ab31 | | | 1493 | act(() => { |
| b69ab31 | | | 1494 | userEvent.type(title, 'Hello, world!'); |
| b69ab31 | | | 1495 | }); |
| b69ab31 | | | 1496 | clickCommitAs(); |
| b69ab31 | | | 1497 | |
| b69ab31 | | | 1498 | expect((screen.getByTestId('quick-commit-title') as HTMLInputElement).value).toEqual( |
| b69ab31 | | | 1499 | '', |
| b69ab31 | | | 1500 | ); |
| b69ab31 | | | 1501 | expect(getTitleEditor().value).toBe('Hello, world!'); |
| b69ab31 | | | 1502 | }); |
| b69ab31 | | | 1503 | }); |
| b69ab31 | | | 1504 | }); |
| b69ab31 | | | 1505 | }); |
| b69ab31 | | | 1506 | |
| b69ab31 | | | 1507 | function expectAmendDisabled() { |
| b69ab31 | | | 1508 | it('does not allow submitting', () => { |
| b69ab31 | | | 1509 | expect(withinCommitInfo().queryByText('Submit')).not.toBeInTheDocument(); |
| b69ab31 | | | 1510 | }); |
| b69ab31 | | | 1511 | |
| b69ab31 | | | 1512 | it('does not show changes to amend', () => { |
| b69ab31 | | | 1513 | expect(withinCommitInfo().queryByText('Changes to Amend')).not.toBeInTheDocument(); |
| b69ab31 | | | 1514 | }); |
| b69ab31 | | | 1515 | |
| b69ab31 | | | 1516 | it('does not allow clicking to edit fields', () => { |
| b69ab31 | | | 1517 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 1518 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 1519 | |
| b69ab31 | | | 1520 | clickToEditTitle(); |
| b69ab31 | | | 1521 | clickToEditDescription(); |
| b69ab31 | | | 1522 | |
| b69ab31 | | | 1523 | expectIsNOTEditingTitle(); |
| b69ab31 | | | 1524 | expectIsNOTEditingDescription(); |
| b69ab31 | | | 1525 | }); |
| b69ab31 | | | 1526 | } |
| b69ab31 | | | 1527 | |
| b69ab31 | | | 1528 | describe('Public commits in amend mode', () => { |
| b69ab31 | | | 1529 | beforeEach(() => { |
| b69ab31 | | | 1530 | act(() => { |
| b69ab31 | | | 1531 | simulateCommits({ |
| b69ab31 | | | 1532 | value: [ |
| b69ab31 | | | 1533 | COMMIT('1', 'some public base', '0', {phase: 'public', isDot: true}), |
| b69ab31 | | | 1534 | COMMIT('a', 'My Commit', '1'), |
| b69ab31 | | | 1535 | COMMIT('b', 'Head Commit', 'a'), |
| b69ab31 | | | 1536 | ], |
| b69ab31 | | | 1537 | }); |
| b69ab31 | | | 1538 | }); |
| b69ab31 | | | 1539 | }); |
| b69ab31 | | | 1540 | |
| b69ab31 | | | 1541 | it('shows public label', () => { |
| b69ab31 | | | 1542 | expect(withinCommitInfo().getByText('Public')).toBeInTheDocument(); |
| b69ab31 | | | 1543 | }); |
| b69ab31 | | | 1544 | |
| b69ab31 | | | 1545 | expectAmendDisabled(); |
| b69ab31 | | | 1546 | }); |
| b69ab31 | | | 1547 | |
| b69ab31 | | | 1548 | describe('Obsoleted commits in amend mode', () => { |
| b69ab31 | | | 1549 | beforeEach(() => { |
| b69ab31 | | | 1550 | act(() => { |
| b69ab31 | | | 1551 | simulateCommits({ |
| b69ab31 | | | 1552 | value: [ |
| b69ab31 | | | 1553 | COMMIT('1', 'some public base', '0', {phase: 'public'}), |
| b69ab31 | | | 1554 | COMMIT('a', 'My Commit V1', '1', { |
| b69ab31 | | | 1555 | successorInfo: {hash: 'b', type: 'amend'}, |
| b69ab31 | | | 1556 | isDot: true, |
| b69ab31 | | | 1557 | }), |
| b69ab31 | | | 1558 | COMMIT('b', 'Head Commit', '1'), |
| b69ab31 | | | 1559 | ], |
| b69ab31 | | | 1560 | }); |
| b69ab31 | | | 1561 | }); |
| b69ab31 | | | 1562 | }); |
| b69ab31 | | | 1563 | |
| b69ab31 | | | 1564 | expectAmendDisabled(); |
| b69ab31 | | | 1565 | }); |
| b69ab31 | | | 1566 | }); |
| b69ab31 | | | 1567 | }); |