| 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, screen, waitFor, within} from '@testing-library/react'; |
| b69ab31 | | | 9 | import {initRepo} from './setup'; |
| b69ab31 | | | 10 | |
| b69ab31 | | | 11 | describe('multiple merge conflicts integration test', () => { |
| b69ab31 | | | 12 | it('shows conflicts, supports resolving, and continuing the operation', async () => { |
| b69ab31 | | | 13 | const {cleanup, sl, drawdag, writeFileInRepo, refresh} = await initRepo(); |
| b69ab31 | | | 14 | |
| b69ab31 | | | 15 | const {MergeConflictTestUtils, ignoreRTL} = await import('../src/testQueries'); |
| b69ab31 | | | 16 | const { |
| b69ab31 | | | 17 | expectInMergeConflicts, |
| b69ab31 | | | 18 | expectNotInMergeConflicts, |
| b69ab31 | | | 19 | waitForContinueButtonNotDisabled, |
| b69ab31 | | | 20 | clickContinueConflicts, |
| b69ab31 | | | 21 | } = MergeConflictTestUtils; |
| b69ab31 | | | 22 | |
| b69ab31 | | | 23 | await act(() => |
| b69ab31 | | | 24 | drawdag(` |
| b69ab31 | | | 25 | C |
| b69ab31 | | | 26 | | |
| b69ab31 | | | 27 | B |
| b69ab31 | | | 28 | | |
| b69ab31 | | | 29 | A |
| b69ab31 | | | 30 | . |
| b69ab31 | | | 31 | python: |
| b69ab31 | | | 32 | commit('C', files={"file2.txt": "baz\\n"}) |
| b69ab31 | | | 33 | commit('B', files={"file1.txt": "foo\\n"}) |
| b69ab31 | | | 34 | commit('A', files={"file1.txt": "base\\n", "file2.txt": "base\\n"}) |
| b69ab31 | | | 35 | `), |
| b69ab31 | | | 36 | ); |
| b69ab31 | | | 37 | |
| b69ab31 | | | 38 | await act(async () => { |
| b69ab31 | | | 39 | await sl(['goto', 'desc(A)']); |
| b69ab31 | | | 40 | await writeFileInRepo('file1.txt', 'conflict'); |
| b69ab31 | | | 41 | await writeFileInRepo('file2.txt', 'conflict'); |
| b69ab31 | | | 42 | // this amend onto B will hit conflicts with C |
| b69ab31 | | | 43 | await sl(['amend', '--rebase']).catch(() => undefined); |
| b69ab31 | | | 44 | }); |
| b69ab31 | | | 45 | |
| b69ab31 | | | 46 | await waitFor(() => expectInMergeConflicts()); |
| b69ab31 | | | 47 | await waitFor(() => |
| b69ab31 | | | 48 | within(screen.getByTestId('commit-tree-root')).getByText(ignoreRTL('file1.txt')), |
| b69ab31 | | | 49 | ); |
| b69ab31 | | | 50 | |
| b69ab31 | | | 51 | await act(async () => { |
| b69ab31 | | | 52 | await sl(['resolve', '--tool', 'internal:union', 'file1.txt']); |
| b69ab31 | | | 53 | }); |
| b69ab31 | | | 54 | refresh(); |
| b69ab31 | | | 55 | |
| b69ab31 | | | 56 | await waitForContinueButtonNotDisabled(); |
| b69ab31 | | | 57 | clickContinueConflicts(); |
| b69ab31 | | | 58 | |
| b69ab31 | | | 59 | await waitFor(() => |
| b69ab31 | | | 60 | within(screen.getByTestId('commit-tree-root')).getByText(ignoreRTL('file2.txt')), |
| b69ab31 | | | 61 | ); |
| b69ab31 | | | 62 | await act(async () => { |
| b69ab31 | | | 63 | await sl(['resolve', '--tool', 'internal:union', 'file2.txt']); |
| b69ab31 | | | 64 | }); |
| b69ab31 | | | 65 | refresh(); |
| b69ab31 | | | 66 | |
| b69ab31 | | | 67 | await waitForContinueButtonNotDisabled(); |
| b69ab31 | | | 68 | clickContinueConflicts(); |
| b69ab31 | | | 69 | |
| b69ab31 | | | 70 | await waitFor(() => expectNotInMergeConflicts()); |
| b69ab31 | | | 71 | |
| b69ab31 | | | 72 | await act(cleanup); |
| b69ab31 | | | 73 | }); |
| b69ab31 | | | 74 | }); |