Add BDD tests for new history code
This commit is contained in:
parent
f17d4388fd
commit
b6e534f9b8
10
tests/end2end/data/äöü.html
Normal file
10
tests/end2end/data/äöü.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Chäschüechli</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
foo
|
||||||
|
</body>
|
||||||
|
</html>
|
47
tests/end2end/features/history.feature
Normal file
47
tests/end2end/features/history.feature
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
Feature: Page history
|
||||||
|
|
||||||
|
Make sure the global page history is saved correctly.
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given I run :history-clear
|
||||||
|
|
||||||
|
Scenario: Simple history saving
|
||||||
|
When I open data/numbers/1.txt
|
||||||
|
And I open data/numbers/2.txt
|
||||||
|
Then the history file should contain:
|
||||||
|
http://localhost:(port)/data/numbers/1.txt
|
||||||
|
http://localhost:(port)/data/numbers/2.txt
|
||||||
|
|
||||||
|
Scenario: History item with title
|
||||||
|
When I open data/title.html
|
||||||
|
Then the history file should contain:
|
||||||
|
http://localhost:(port)/data/title.html Test title
|
||||||
|
|
||||||
|
Scenario: History item with redirect
|
||||||
|
When I open redirect-to?url=data/title.html without waiting
|
||||||
|
And I wait until data/title.html is loaded
|
||||||
|
Then the history file should contain:
|
||||||
|
http://localhost:(port)/redirect-to?url=data/title.html Test title
|
||||||
|
http://localhost:(port)/data/title.html Test title
|
||||||
|
|
||||||
|
Scenario: History item with spaces in URL
|
||||||
|
When I open data/title with spaces.html
|
||||||
|
Then the history file should contain:
|
||||||
|
http://localhost:(port)/data/title%20with%20spaces.html Test title
|
||||||
|
|
||||||
|
Scenario: History item with umlauts
|
||||||
|
When I open data/äöü.html
|
||||||
|
Then the history file should contain:
|
||||||
|
http://localhost:(port)/data/%C3%A4%C3%B6%C3%BC.html Chäschüechli
|
||||||
|
|
||||||
|
Scenario: History with an error
|
||||||
|
When I run :open file:///does/not/exist
|
||||||
|
And I wait for "Error while loading file:///does/not/exist: Error opening /does/not/exist: *" in the log
|
||||||
|
Then the history file should contain:
|
||||||
|
file:///does/not/exist Error loading page: file:///does/not/exist
|
||||||
|
|
||||||
|
Scenario: History with a 404
|
||||||
|
When I open status/404 without waiting
|
||||||
|
And I wait for "Error while loading http://localhost:*/status/404: NOT FOUND" in the log
|
||||||
|
Then the history file should contain:
|
||||||
|
http://localhost:(port)/status/404 Error loading page: http://localhost:(port)/status/404
|
44
tests/end2end/features/test_history_bdd.py
Normal file
44
tests/end2end/features/test_history_bdd.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||||
|
|
||||||
|
# Copyright 2016 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||||
|
#
|
||||||
|
# This file is part of qutebrowser.
|
||||||
|
#
|
||||||
|
# qutebrowser is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# qutebrowser is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
import pytest_bdd as bdd
|
||||||
|
bdd.scenarios('history.feature')
|
||||||
|
|
||||||
|
|
||||||
|
@bdd.then(bdd.parsers.parse("the history file should contain:\n{expected}"))
|
||||||
|
def check_history(quteproc, httpbin, expected):
|
||||||
|
history_file = os.path.join(quteproc.basedir, 'data', 'history')
|
||||||
|
quteproc.send_cmd(':save history')
|
||||||
|
quteproc.wait_for(message='Saved to *history')
|
||||||
|
|
||||||
|
expected = expected.replace('(port)', str(httpbin.port)).splitlines()
|
||||||
|
|
||||||
|
with open(history_file, 'r', encoding='utf-8') as f:
|
||||||
|
lines = []
|
||||||
|
for line in f:
|
||||||
|
if not line.strip():
|
||||||
|
continue
|
||||||
|
print('history line: ' + line)
|
||||||
|
line = line.split(' ', maxsplit=1)[1] # Strip off timestamp
|
||||||
|
line = line.rstrip()
|
||||||
|
lines.append(line)
|
||||||
|
|
||||||
|
assert lines == expected
|
Loading…
Reference in New Issue
Block a user