bdd: Add some tests for bookmarks.
This commit is contained in:
parent
4ef0c3e09f
commit
c385580b81
@ -26,8 +26,13 @@ from helpers import utils
|
||||
bdd.scenarios('urlmarks.feature')
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.parse('the bookmark file should contain "{expected}"'))
|
||||
def bookmark_file_contains(quteproc, expected):
|
||||
def _check_bookmarks(quteproc, expected, contains):
|
||||
"""Make sure the given line does (not) exist in the bookmarks.
|
||||
|
||||
Args:
|
||||
expected: The line to search for.
|
||||
contains: True if the line should be there, False otherwise.
|
||||
"""
|
||||
bookmark_file = os.path.join(quteproc.basedir, 'config', 'bookmarks',
|
||||
'urls')
|
||||
|
||||
@ -42,4 +47,14 @@ def bookmark_file_contains(quteproc, expected):
|
||||
utils.pattern_match(pattern=expected, value=line.rstrip('\n'))
|
||||
for line in lines)
|
||||
|
||||
assert matched_line, lines
|
||||
assert matched_line == contains, lines
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.parse('the bookmark file should contain "{line}"'))
|
||||
def bookmark_file_contains(quteproc, line):
|
||||
_check_bookmarks(quteproc, line, True)
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.parse('the bookmark file should not contain "{line}"'))
|
||||
def bookmark_file_does_not_contain(quteproc, line):
|
||||
_check_bookmarks(quteproc, line, False)
|
||||
|
@ -1,7 +1,73 @@
|
||||
Feature: quickmarks and bookmarks
|
||||
|
||||
# bookmarks
|
||||
|
||||
Scenario: Saving a bookmark
|
||||
When I open data/title.html
|
||||
And I run :bookmark-add
|
||||
Then the message "Bookmarked http://localhost:*/data/title.html!" should be shown
|
||||
And the bookmark file should contain "http://localhost:*/data/title.html Test title"
|
||||
|
||||
Scenario: Saving a duplicate bookmark
|
||||
Given I have a fresh instance
|
||||
When I open data/title.html
|
||||
And I run :bookmark-add
|
||||
And I run :bookmark-add
|
||||
Then the error "Bookmark already exists!" should be shown
|
||||
|
||||
Scenario: Loading a bookmark
|
||||
When I run :tab-only
|
||||
And I run :bookmark-load http://localhost:(port)/data/numbers/1.txt
|
||||
Then data/numbers/1.txt should be loaded
|
||||
And the following tabs should be open:
|
||||
- data/numbers/1.txt (active)
|
||||
|
||||
Scenario: Loading a bookmark in a new tab
|
||||
Given I open about:blank
|
||||
When I run :tab-only
|
||||
And I run :bookmark-load -t http://localhost:(port)/data/numbers/2.txt
|
||||
Then data/numbers/2.txt should be loaded
|
||||
And the following tabs should be open:
|
||||
- about:blank
|
||||
- data/numbers/2.txt (active)
|
||||
|
||||
Scenario: Loading a bookmark in a background tab
|
||||
Given I open about:blank
|
||||
When I run :tab-only
|
||||
And I run :bookmark-load -b http://localhost:(port)/data/numbers/3.txt
|
||||
Then data/numbers/3.txt should be loaded
|
||||
And the following tabs should be open:
|
||||
- about:blank (active)
|
||||
- data/numbers/3.txt
|
||||
|
||||
Scenario: Loading a bookmark in a new window
|
||||
Given I open about:blank
|
||||
When I run :tab-only
|
||||
And I run :bookmark-load -w http://localhost:(port)/data/numbers/4.txt
|
||||
And I wait until data/numbers/4.txt is loaded
|
||||
Then the session should look like:
|
||||
windows:
|
||||
- tabs:
|
||||
- active: true
|
||||
history:
|
||||
- active: true
|
||||
url: about:blank
|
||||
- tabs:
|
||||
- active: true
|
||||
history:
|
||||
- active: true
|
||||
url: http://localhost:*/data/numbers/4.txt
|
||||
|
||||
Scenario: Loading a bookmark with -t and -b
|
||||
When I run :bookmark-load -t -b about:blank
|
||||
Then the error "Only one of -t/-b/-w can be given!" should be shown
|
||||
|
||||
Scenario: Deleting a bookmark which does not exist
|
||||
When I run :bookmark-del doesnotexist
|
||||
Then the error "Bookmark 'doesnotexist' not found!" should be shown
|
||||
|
||||
Scenario: Deleting a bookmark
|
||||
When I open data/numbers/5.txt
|
||||
And I run :bookmark-add
|
||||
And I run :bookmark-del http://localhost:(port)/data/numbers/5.txt
|
||||
Then the bookmark file should not contain "http://localhost:*/data/numbers/5.txt "
|
||||
|
Loading…
Reference in New Issue
Block a user