-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Desktop: Fixes #16167: Fix conflict created when syncing a just-published note #16182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
personalizedrefrigerator
wants to merge
11
commits into
laurent22:dev
Choose a base branch
from
personalizedrefrigerator:pr/desktop/fix-conflict-on-publish-only
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+160
−28
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b28635a
Desktop: Fixes #16167: Fix conflict created when syncing a
personalizedrefrigerator 45c7371
Refactoring
personalizedrefrigerator 37ba58e
Add test for setting is_shared=1 recursively
personalizedrefrigerator 01a458f
Refactoring
personalizedrefrigerator 13b5731
Refactoring
personalizedrefrigerator 02822e7
Refactor test file
personalizedrefrigerator c30c52d
Reword test title
personalizedrefrigerator 5b84ef6
Refactoring
personalizedrefrigerator c1708ab
Revert changes to sample-fuzzer-setup.json
personalizedrefrigerator 6c40e58
Address CodeRabbit feedback: Avoid setting is_shared=1 for conflicts …
personalizedrefrigerator 67791bf
Address code review feedback: Improve error handling
personalizedrefrigerator 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import { setupDatabaseAndSynchronizer, switchClient, resourceService, createFolderTree } from '../testing/test-utils'; | ||
| import Folder from '../models/Folder'; | ||
| import { ShareType, StateShare } from '../services/share/reducer'; | ||
| import Note from './Note'; | ||
|
|
||
| const publishedFolderShareState = (folderId: string): StateShare => ({ | ||
| id: `share-${folderId}`, | ||
| type: ShareType.PublishedFolder, | ||
| folder_id: folderId, | ||
| note_id: '', | ||
| master_key_id: '', | ||
| }); | ||
|
|
||
| type ItemSlice = { title: string }; | ||
|
|
||
| const expectPublished = async (items: ItemSlice[], published = true) => { | ||
| for (let item of items) { | ||
| item = (await Folder.loadByTitle(item.title)) ?? await Note.loadByTitle(item.title); | ||
| expect(item).toMatchObject({ | ||
| title: item.title, | ||
| is_shared: published ? 1 : 0, | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| const expectUnpublished = (items: ItemSlice[]) => expectPublished(items, false); | ||
|
|
||
| describe('models/Folder.publishing', () => { | ||
|
|
||
| beforeEach(async () => { | ||
| await setupDatabaseAndSynchronizer(1); | ||
| await switchClient(1); | ||
| }); | ||
|
|
||
| it('should set is_shared=1 on descendants of a published folder', async () => { | ||
| const root = await createFolderTree('', [ | ||
| { | ||
| title: 'root', | ||
| children: [ | ||
| { | ||
| title: 'sub-folder 1', | ||
| children: [], | ||
| }, | ||
| { | ||
| title: 'sub-folder 2', | ||
| children: [ | ||
| { title: 'sub-sub-folder', children: [] }, | ||
| { title: 'published note 1' }, | ||
| { title: 'published note 2' }, | ||
| ], | ||
| }, | ||
| { title: 'published note 3' }, | ||
| ], | ||
| }, | ||
| { | ||
| title: 'unpublished folder', | ||
| children: [ | ||
| { title: 'unpublished note' }, | ||
| ], | ||
| }, | ||
| ]); | ||
|
|
||
| const shareState: StateShare[] = [ | ||
| publishedFolderShareState(root.id), | ||
| ]; | ||
|
|
||
| await Folder.updateAllShareIds( | ||
| resourceService(), | ||
| shareState, | ||
| ); | ||
|
|
||
| // After the first round, only folders should have is_shared=1 | ||
| await expectPublished([ | ||
| 'root', | ||
| 'sub-folder 1', | ||
| 'sub-folder 2', | ||
| 'sub-sub-folder', | ||
| ].map(title => ({ title }))); | ||
| await expectUnpublished([ | ||
| 'published note 1', | ||
| 'published note 2', | ||
| 'published note 3', | ||
| 'unpublished folder', | ||
| 'unpublished note', | ||
| ].map(title => ({ title }))); | ||
|
|
||
| // Should update published notes when calling Note.updateNotePublicationStatus | ||
| await Note.updatePublishedNotes(shareState); | ||
|
|
||
| await expectPublished([ | ||
| 'root', | ||
| 'sub-folder 1', | ||
| 'sub-folder 2', | ||
| 'sub-sub-folder', | ||
| 'published note 1', | ||
| 'published note 2', | ||
| 'published note 3', | ||
| ].map(title => ({ title }))); | ||
| await expectUnpublished([ | ||
| 'unpublished folder', | ||
| 'unpublished note', | ||
| ].map(title => ({ title }))); | ||
| }); | ||
| }); |
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
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.
Uh oh!
There was an error while loading. Please reload this page.