Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Restore ability to delete bookmark custom title
Browse files Browse the repository at this point in the history
Fix #7691

Test Plan:
1. automated bookmark tests should pass
2. try editing a bookmark and fully deleting the title. the title field should be empty.
  • Loading branch information
diracdeltas committed Mar 14, 2017
1 parent 7dfeeb0 commit a4f8401
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/renderer/components/addEditBookmarkHanger.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AddEditBookmarkHanger extends ImmutableComponent {
get displayBookmarkName () {
const customTitle = this.props.currentDetail.get('customTitle')
if (customTitle !== undefined && customTitle !== '') {
return this.props.currentDetail.get('customTitle')
return customTitle || ''
}
return this.props.currentDetail.get('title') || ''
}
Expand Down Expand Up @@ -109,7 +109,11 @@ class AddEditBookmarkHanger extends ImmutableComponent {
if (currentDetail.get('title') === name && name) {
currentDetail = currentDetail.delete('customTitle')
} else {
currentDetail = currentDetail.set('customTitle', name)
// '' is reserved for the default customTitle value of synced bookmarks,
// so replace '' with 0 if the user is deleting the customTitle.
// Note that non-string bookmark titles fail bookmarkNameValid so they
// are not saved.
currentDetail = currentDetail.set('customTitle', name || 0)
}
windowActions.setBookmarkDetail(currentDetail, this.props.originalDetail, this.props.destinationDetail, this.props.shouldShowLocation, !this.props.isModal)
}
Expand Down
9 changes: 9 additions & 0 deletions test/components/bookmarksTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ describe('bookmark tests', function () {
.getValue('#bookmarkName input').should.eventually.be.equal('Custom Page 1')
.click(doneButton)
})
it('can delete custom title', function * () {
yield this.app.client
.activateURLMode()
.waitForVisible(navigatorBookmarked)
.click(navigatorBookmarked)
.waitForVisible(doneButton)
.keys(Brave.keys.BACKSPACE)
.getValue('#bookmarkName input').should.eventually.be.equal('')
})
it('display punycode custom title and location', function * () {
yield this.app.client
.activateURLMode()
Expand Down
15 changes: 15 additions & 0 deletions test/unit/state/syncUtilTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ describe('syncUtil', () => {
}
assert.deepEqual(syncUtil.createSiteData(bookmark), expectedBookmark)
})

it('bookmark with undefined custom title', () => {
const bookmark = Object.assign({}, site, {tags: ['bookmark'], customTitle: undefined})
const newValue = Object.assign({}, expectedSite.value, {customTitle: undefined})
const expectedBookmark = {
name: 'bookmark',
objectId,
value: {
site: newValue,
isFolder: false,
parentFolderObjectId: undefined
}
}
assert.deepEqual(syncUtil.createSiteData(bookmark), expectedBookmark)
})
})

describe('ipcSafeObject()', () => {
Expand Down

0 comments on commit a4f8401

Please sign in to comment.