bdd: Add some tests for quickmarks.
This commit is contained in:
parent
c385580b81
commit
fce4351463
@ -26,21 +26,25 @@ from helpers import utils
|
||||
bdd.scenarios('urlmarks.feature')
|
||||
|
||||
|
||||
def _check_bookmarks(quteproc, expected, contains):
|
||||
def _check_marks(quteproc, quickmarks, expected, contains):
|
||||
"""Make sure the given line does (not) exist in the bookmarks.
|
||||
|
||||
Args:
|
||||
quickmarks: True to check the quickmarks file instead of bookmarks.
|
||||
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',
|
||||
if quickmarks:
|
||||
mark_file = os.path.join(quteproc.basedir, 'config', 'quickmarks')
|
||||
else:
|
||||
mark_file = os.path.join(quteproc.basedir, 'config', 'bookmarks',
|
||||
'urls')
|
||||
|
||||
quteproc.clear_data() # So we don't match old messages
|
||||
quteproc.send_cmd(':save')
|
||||
quteproc.wait_for(message='Saved to {}'.format(bookmark_file))
|
||||
quteproc.wait_for(message='Saved to {}'.format(mark_file))
|
||||
|
||||
with open(bookmark_file, 'r', encoding='utf-8') as f:
|
||||
with open(mark_file, 'r', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
matched_line = any(
|
||||
@ -52,9 +56,19 @@ def _check_bookmarks(quteproc, expected, contains):
|
||||
|
||||
@bdd.then(bdd.parsers.parse('the bookmark file should contain "{line}"'))
|
||||
def bookmark_file_contains(quteproc, line):
|
||||
_check_bookmarks(quteproc, line, True)
|
||||
_check_marks(quteproc, quickmarks=False, expected=line, contains=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)
|
||||
_check_marks(quteproc, quickmarks=False, expected=line, contains=False)
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.parse('the quickmark file should contain "{line}"'))
|
||||
def quickmark_file_contains(quteproc, line):
|
||||
_check_marks(quteproc, quickmarks=True, expected=line, contains=True)
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.parse('the quickmark file should not contain "{line}"'))
|
||||
def quickmark_file_does_not_contain(quteproc, line):
|
||||
_check_marks(quteproc, quickmarks=True, expected=line, contains=False)
|
||||
|
@ -1,6 +1,6 @@
|
||||
Feature: quickmarks and bookmarks
|
||||
|
||||
# bookmarks
|
||||
## bookmarks
|
||||
|
||||
Scenario: Saving a bookmark
|
||||
When I open data/title.html
|
||||
@ -71,3 +71,104 @@ Feature: quickmarks and bookmarks
|
||||
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 "
|
||||
|
||||
## quickmarks
|
||||
|
||||
Scenario: Saving a quickmark (:quickmark-add)
|
||||
When I run :quickmark-add http://localhost:(port)/data/numbers/6.txt six
|
||||
Then the quickmark file should contain "six http://localhost:*/data/numbers/6.txt"
|
||||
|
||||
Scenario: Saving a quickmark (:quickmark-save)
|
||||
When I open http://localhost:(port)/data/numbers/7.txt
|
||||
And I run :quickmark-save
|
||||
And I wait for "Entering mode KeyMode.prompt (reason: question asked)" in the log
|
||||
And I press the keys "seven"
|
||||
And I press the keys "<Enter>"
|
||||
Then the quickmark file should contain "seven http://localhost:*/data/numbers/7.txt"
|
||||
|
||||
Scenario: Saving a duplicate quickmark (without override)
|
||||
When I run :quickmark-add http://localhost:(port)/data/numbers/8.txt eight
|
||||
And I run :quickmark-add http://localhost:(port)/data/numbers/8_2.txt eight
|
||||
And I wait for "Entering mode KeyMode.yesno (reason: question asked)" in the log
|
||||
And I run :prompt-no
|
||||
Then the quickmark file should contain "eight http://localhost:*/data/numbers/8.txt"
|
||||
|
||||
Scenario: Saving a duplicate quickmark (with override)
|
||||
When I run :quickmark-add http://localhost:(port)/data/numbers/9.txt nine
|
||||
And I run :quickmark-add http://localhost:(port)/data/numbers/9_2.txt nine
|
||||
And I wait for "Entering mode KeyMode.yesno (reason: question asked)" in the log
|
||||
And I run :prompt-yes
|
||||
Then the quickmark file should contain "nine http://localhost:*/data/numbers/9_2.txt"
|
||||
|
||||
Scenario: Adding a quickmark with an empty name
|
||||
When I run :quickmark-add about:blank ""
|
||||
Then the error "Can't set mark with empty name!" should be shown
|
||||
|
||||
Scenario: Adding a quickmark with an empty URL
|
||||
When I run :quickmark-add "" foo
|
||||
Then the error "Can't set mark with empty URL!" should be shown
|
||||
|
||||
Scenario: Loading a quickmark
|
||||
Given I have a fresh instance
|
||||
When I run :quickmark-add http://localhost:(port)/data/numbers/10.txt ten
|
||||
And I run :quickmark-load ten
|
||||
Then data/numbers/10.txt should be loaded
|
||||
And the following tabs should be open:
|
||||
- data/numbers/10.txt (active)
|
||||
|
||||
Scenario: Loading a quickmark in a new tab
|
||||
Given I open about:blank
|
||||
When I run :tab-only
|
||||
And I run :quickmark-add http://localhost:(port)/data/numbers/11.txt eleven
|
||||
And I run :quickmark-load -t eleven
|
||||
Then data/numbers/11.txt should be loaded
|
||||
And the following tabs should be open:
|
||||
- about:blank
|
||||
- data/numbers/11.txt (active)
|
||||
|
||||
Scenario: Loading a quickmark in a background tab
|
||||
Given I open about:blank
|
||||
When I run :tab-only
|
||||
And I run :quickmark-add http://localhost:(port)/data/numbers/12.txt twelve
|
||||
And I run :quickmark-load -b twelve
|
||||
Then data/numbers/12.txt should be loaded
|
||||
And the following tabs should be open:
|
||||
- about:blank (active)
|
||||
- data/numbers/12.txt
|
||||
|
||||
Scenario: Loading a quickmark in a new window
|
||||
Given I open about:blank
|
||||
When I run :tab-only
|
||||
And I run :quickmark-add http://localhost:(port)/data/numbers/13.txt thirteen
|
||||
And I run :quickmark-load -w thirteen
|
||||
And I wait until data/numbers/13.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/13.txt
|
||||
|
||||
Scenario: Loading a quickmark which does not exist
|
||||
When I run :quickmark-load -b doesnotexist
|
||||
Then the error "Quickmark 'doesnotexist' does not exist!" should be shown
|
||||
|
||||
Scenario: Loading a quickmark with -t and -b
|
||||
When I run :quickmark-add http://localhost:(port)/data/numbers/14.txt fourteen
|
||||
When I run :quickmark-load -t -b fourteen
|
||||
Then the error "Only one of -t/-b/-w can be given!" should be shown
|
||||
|
||||
Scenario: Deleting a quickmark which does not exist
|
||||
When I run :quickmark-del doesnotexist
|
||||
Then the error "Quickmark 'doesnotexist' not found!" should be shown
|
||||
|
||||
Scenario: Deleting a quickmark
|
||||
When I run :quickmark-add http://localhost:(port)/data/numbers/15.txt fifteen
|
||||
And I run :quickmark-del fifteen
|
||||
Then the quickmark file should not contain "fourteen http://localhost:*/data/numbers/15.txt "
|
||||
|
Loading…
Reference in New Issue
Block a user