This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 975
Add "forget this domain" feature #12754
Merged
bsclifton
merged 2 commits into
brave:master
from
AlexRobinson-:arobinson/forget-this-domain
Mar 15, 2018
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -86,6 +86,17 @@ describe('historyReducer unit test', function () { | |
partitionNumber: 0, | ||
themeColor: undefined, | ||
title: 'Brave' | ||
}, | ||
{ | ||
count: 2, | ||
favicon: undefined, | ||
key: 'https://brave.com/|1', | ||
lastAccessedTime: 0, | ||
location: 'https://brave.com/', | ||
objectId: null, | ||
partitionNumber: 0, | ||
themeColor: undefined, | ||
title: 'Brave | Another Page' | ||
} | ||
] | ||
} | ||
|
@@ -350,6 +361,83 @@ describe('historyReducer unit test', function () { | |
}) | ||
}) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for adding tests! |
||
describe('APP_REMOVE_HISTORY_DOMAIN', function () { | ||
let spy, spyAbout | ||
|
||
before(function () { | ||
spy = sinon.spy(historyState, 'removeSite') | ||
spyAbout = sinon.spy(aboutHistoryState, 'setHistory') | ||
}) | ||
|
||
afterEach(function () { | ||
spy.reset() | ||
spyAbout.reset() | ||
}) | ||
|
||
after(function () { | ||
spy.restore() | ||
spyAbout.restore() | ||
}) | ||
|
||
it('null case', function () { | ||
const newState = historyReducer(state, { | ||
actionType: appConstants.APP_REMOVE_HISTORY_DOMAIN | ||
}) | ||
assert.equal(spy.notCalled, true) | ||
assert.equal(spyAbout.notCalled, true) | ||
assert.deepEqual(newState.toJS(), state.toJS()) | ||
}) | ||
|
||
it('domain is a string', function () { | ||
const newState = historyReducer(stateWithData, { | ||
actionType: appConstants.APP_REMOVE_HISTORY_DOMAIN, | ||
domain: 'https://brave.com' | ||
}) | ||
const expectedState = state | ||
.set('historySites', Immutable.fromJS({ | ||
'https://clifton.io/|0': { | ||
count: 1, | ||
favicon: undefined, | ||
key: 'https://clifton.io/|0', | ||
lastAccessedTime: 0, | ||
location: 'https://clifton.io/', | ||
objectId: null, | ||
partitionNumber: 0, | ||
themeColor: undefined, | ||
title: 'Clifton' | ||
} | ||
})) | ||
.setIn(['about', 'history'], Immutable.fromJS({ | ||
entries: [ | ||
{ | ||
count: 1, | ||
favicon: undefined, | ||
key: 'https://clifton.io/|0', | ||
lastAccessedTime: 0, | ||
location: 'https://clifton.io/', | ||
objectId: null, | ||
partitionNumber: 0, | ||
themeColor: undefined, | ||
title: 'Clifton' | ||
} | ||
], | ||
updatedStamp: 0 | ||
})) | ||
|
||
it('calls remove for each matching domain', () => { | ||
assert.equal(spy.calledTwice, true) | ||
}) | ||
|
||
it('sets the history with the update site list', () => { | ||
assert.equal(spyAbout.calledOnce, true) | ||
}) | ||
|
||
it('returns the updated state', () => { | ||
assert.deepEqual(newState.toJS(), expectedState.toJS()) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('APP_REMOVE_HISTORY_SITE', function () { | ||
let spy, spyAbout | ||
|
||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably check that
urlParse(historySite.get('location'))
is non-falseyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems
urlParse
always returns an objecthttps://github.com/brave/browser-laptop/blob/master/app/common/urlParse.js#L19
So it should always be non-falsey
Would you still prefer a check in there? If so should we display any errors to the user? Or just ignore the fail and do nothing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any thoughts on this @diracdeltas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm original comment