From fd60bac1fa0d3282a964f02471e199d8d62e8c10 Mon Sep 17 00:00:00 2001 From: bridiver Date: Tue, 23 Aug 2016 14:14:01 -0700 Subject: [PATCH] default bookmark title to the url if no title is present fixes #3344 --- js/components/addEditBookmark.js | 2 +- test/components/bookmarksTest.js | 79 ++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 test/components/bookmarksTest.js diff --git a/js/components/addEditBookmark.js b/js/components/addEditBookmark.js index 779e08089cd..501e43e7e87 100644 --- a/js/components/addEditBookmark.js +++ b/js/components/addEditBookmark.js @@ -103,7 +103,7 @@ class AddEditBookmark extends ImmutableComponent { if (this.props.currentDetail.get('customTitle') !== undefined) { return this.props.currentDetail.get('customTitle') } - return this.props.currentDetail.get('title') || '' + return this.props.currentDetail.get('title') || this.props.currentDetail.get('location') } render () { return diff --git a/test/components/bookmarksTest.js b/test/components/bookmarksTest.js new file mode 100644 index 00000000000..9883b3d2e8f --- /dev/null +++ b/test/components/bookmarksTest.js @@ -0,0 +1,79 @@ +/* global describe, it, before */ + +const Brave = require('../lib/brave') +const {urlInput, navigator, navigatorNotBookmarked, saveButton} = require('../lib/selectors') + +describe('bookmarks', function () { + function * setup (client) { + yield client + .waitUntilWindowLoaded() + .waitForUrl(Brave.newTabUrl) + .waitForBrowserWindow() + .waitForVisible('#window') + .waitForEnabled(urlInput) + } + + describe('with title', function () { + Brave.beforeAll(this) + + before(function * () { + this.page1Url = Brave.server.url('page1.html') + + yield setup(this.app.client) + + yield this.app.client + .waitForUrl(Brave.newTabUrl) + .loadUrl(this.page1Url) + .windowParentByUrl(this.page1Url) + .moveToObject(navigator) + .waitForExist(navigatorNotBookmarked) + .moveToObject(navigator) + .click(navigatorNotBookmarked) + .waitForVisible(saveButton) + }) + + it('fills in the title field', function * () { + yield this.app.client + .waitForExist('#bookmarkName input') + .getValue('#bookmarkName input').should.eventually.be.equal('Page 1') + }) + + it('fills in the url field', function * () { + yield this.app.client + .waitForExist('#bookmarkLocation input') + .getValue('#bookmarkLocation input').should.eventually.be.equal(this.page1Url) + }) + }) + + describe('without title', function () { + Brave.beforeAll(this) + + before(function * () { + this.page1Url = Brave.server.url('page_no_title.html') + + yield setup(this.app.client) + + yield this.app.client + .waitForUrl(Brave.newTabUrl) + .loadUrl(this.page1Url) + .windowParentByUrl(this.page1Url) + .moveToObject(navigator) + .waitForExist(navigatorNotBookmarked) + .moveToObject(navigator) + .click(navigatorNotBookmarked) + .waitForVisible(saveButton) + }) + + it('fills in the url for the title field', function * () { + yield this.app.client + .waitForExist('#bookmarkName input') + .getValue('#bookmarkName input').should.eventually.be.equal(this.page1Url) + }) + + it('fills in the url field', function * () { + yield this.app.client + .waitForExist('#bookmarkLocation input') + .getValue('#bookmarkLocation input').should.eventually.be.equal(this.page1Url) + }) + }) +})