Improve download BDD tests
This reorganizes the existing tests a bit and adds some new ones.
This commit is contained in:
parent
7611281563
commit
2177aa574c
BIN
tests/end2end/data/downloads/download2.bin
Normal file
BIN
tests/end2end/data/downloads/download2.bin
Normal file
Binary file not shown.
11
tests/end2end/data/downloads/downloads.html
Normal file
11
tests/end2end/data/downloads/downloads.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Simple downloads</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a href="download.bin" id="download">download.bin</a>
|
||||||
|
<a href="download2.bin">download2.bin</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -4,6 +4,41 @@ Feature: Downloading things from a website.
|
|||||||
Given I set up a temporary download dir
|
Given I set up a temporary download dir
|
||||||
And I clean old downloads
|
And I clean old downloads
|
||||||
|
|
||||||
|
## starting downloads
|
||||||
|
|
||||||
|
Scenario: Clicking an unknown link
|
||||||
|
When I set storage -> prompt-download-directory to false
|
||||||
|
And I open data/downloads/downloads.html
|
||||||
|
And I run :click-element id download
|
||||||
|
And I wait until the download is finished
|
||||||
|
Then the downloaded file download.bin should exist
|
||||||
|
|
||||||
|
Scenario: Using :download
|
||||||
|
When I set storage -> prompt-download-directory to false
|
||||||
|
When I run :download http://localhost:(port)/data/downloads/download.bin
|
||||||
|
And I wait until the download is finished
|
||||||
|
Then the downloaded file download.bin should exist
|
||||||
|
|
||||||
|
Scenario: Using hints
|
||||||
|
When I set storage -> prompt-download-directory to false
|
||||||
|
And I open data/downloads/downloads.html
|
||||||
|
And I hint with args "links download" and follow a
|
||||||
|
And I wait until the download is finished
|
||||||
|
Then the downloaded file download.bin should exist
|
||||||
|
|
||||||
|
Scenario: Using rapid hints
|
||||||
|
# We don't expect any prompts with rapid hinting even if this is true
|
||||||
|
When I set storage -> prompt-download-directory to true
|
||||||
|
And I open data/downloads/downloads.html
|
||||||
|
And I hint with args "--rapid links download" and follow a
|
||||||
|
And I run :follow-hint s
|
||||||
|
And I wait until the download download.bin is finished
|
||||||
|
And I wait until the download download2.bin is finished
|
||||||
|
Then the downloaded file download.bin should exist
|
||||||
|
Then the downloaded file download2.bin should exist
|
||||||
|
|
||||||
|
## Regression tests
|
||||||
|
|
||||||
Scenario: Downloading which redirects with closed tab (issue 889)
|
Scenario: Downloading which redirects with closed tab (issue 889)
|
||||||
When I set tabs -> last-close to blank
|
When I set tabs -> last-close to blank
|
||||||
And I open data/downloads/issue889.html
|
And I open data/downloads/issue889.html
|
||||||
@ -47,6 +82,25 @@ Feature: Downloading things from a website.
|
|||||||
And I run :prompt-accept
|
And I run :prompt-accept
|
||||||
Then the error "Download error: SSL handshake failed" should be shown
|
Then the error "Download error: SSL handshake failed" should be shown
|
||||||
|
|
||||||
|
Scenario: Closing window with remove-finished-downloads timeout (issue 1242)
|
||||||
|
When I set ui -> remove-finished-downloads to 500
|
||||||
|
And I open data/downloads/download.bin in a new window
|
||||||
|
And I wait until the download is finished
|
||||||
|
And I run :close
|
||||||
|
And I wait 0.5s
|
||||||
|
Then no crash should happen
|
||||||
|
|
||||||
|
Scenario: Quitting with finished downloads and confirm-quit=downloads (issue 846)
|
||||||
|
Given I have a fresh instance
|
||||||
|
When I set storage -> prompt-download-directory to false
|
||||||
|
And I set ui -> confirm-quit to downloads
|
||||||
|
And I open data/downloads/download.bin
|
||||||
|
And I wait until the download is finished
|
||||||
|
And I run :close
|
||||||
|
Then qutebrowser should quit
|
||||||
|
|
||||||
|
## :download-retry
|
||||||
|
|
||||||
Scenario: Retrying a failed download
|
Scenario: Retrying a failed download
|
||||||
When I run :download http://localhost:(port)/does-not-exist
|
When I run :download http://localhost:(port)/does-not-exist
|
||||||
And I wait for the error "Download error: * - server replied: NOT FOUND"
|
And I wait for the error "Download error: * - server replied: NOT FOUND"
|
||||||
@ -66,6 +120,8 @@ Feature: Downloading things from a website.
|
|||||||
When I run :download-retry
|
When I run :download-retry
|
||||||
Then the error "No failed downloads!" should be shown
|
Then the error "No failed downloads!" should be shown
|
||||||
|
|
||||||
|
## Wrong invocations
|
||||||
|
|
||||||
Scenario: :download with deprecated dest-old argument
|
Scenario: :download with deprecated dest-old argument
|
||||||
When I run :download http://localhost:(port)/ deprecated-argument
|
When I run :download http://localhost:(port)/ deprecated-argument
|
||||||
Then the warning ":download [url] [dest] is deprecated - use download --dest [dest] [url]" should be shown
|
Then the warning ":download [url] [dest] is deprecated - use download --dest [dest] [url]" should be shown
|
||||||
@ -79,6 +135,8 @@ Feature: Downloading things from a website.
|
|||||||
When I run :download --mhtml http://foobar/
|
When I run :download --mhtml http://foobar/
|
||||||
Then the error "Can only download the current page as mhtml." should be shown
|
Then the error "Can only download the current page as mhtml." should be shown
|
||||||
|
|
||||||
|
## mhtml downloads
|
||||||
|
|
||||||
Scenario: Downloading as mhtml is available
|
Scenario: Downloading as mhtml is available
|
||||||
When I open html
|
When I open html
|
||||||
And I run :download --mhtml
|
And I run :download --mhtml
|
||||||
@ -183,7 +241,7 @@ Feature: Downloading things from a website.
|
|||||||
And I wait until the download is finished
|
And I wait until the download is finished
|
||||||
Then "Opening *download.bin* with [*python*]" should be logged
|
Then "Opening *download.bin* with [*python*]" should be logged
|
||||||
|
|
||||||
## https://github.com/The-Compiler/qutebrowser/issues/1728
|
# https://github.com/The-Compiler/qutebrowser/issues/1728
|
||||||
|
|
||||||
Scenario: Cancelling a download that should be opened
|
Scenario: Cancelling a download that should be opened
|
||||||
When I set storage -> prompt-download-directory to true
|
When I set storage -> prompt-download-directory to true
|
||||||
@ -192,7 +250,7 @@ Feature: Downloading things from a website.
|
|||||||
And I run :download-cancel
|
And I run :download-cancel
|
||||||
Then "* finished but not successful, not opening!" should be logged
|
Then "* finished but not successful, not opening!" should be logged
|
||||||
|
|
||||||
## https://github.com/The-Compiler/qutebrowser/issues/1725
|
# https://github.com/The-Compiler/qutebrowser/issues/1725
|
||||||
|
|
||||||
Scenario: Directly open a download with a very long filename
|
Scenario: Directly open a download with a very long filename
|
||||||
When I set storage -> prompt-download-directory to true
|
When I set storage -> prompt-download-directory to true
|
||||||
@ -223,23 +281,26 @@ Feature: Downloading things from a website.
|
|||||||
And I open data/downloads/download.bin
|
And I open data/downloads/download.bin
|
||||||
Then the download prompt should be shown with "{downloaddir}/download.bin"
|
Then the download prompt should be shown with "{downloaddir}/download.bin"
|
||||||
|
|
||||||
## https://github.com/The-Compiler/qutebrowser/issues/1242
|
## storage -> remember-download-directory
|
||||||
|
|
||||||
Scenario: Closing window with remove-finished-downloads timeout
|
Scenario: Remembering the last download directory
|
||||||
When I set ui -> remove-finished-downloads to 500
|
When I set storage -> prompt-download-directory to true
|
||||||
And I open data/downloads/download.bin in a new window
|
And I set completion -> download-path-suggestion to both
|
||||||
And I wait until the download is finished
|
And I set storage -> remember-download-directory to true
|
||||||
And I run :close
|
|
||||||
And I wait 0.5s
|
|
||||||
Then no crash should happen
|
|
||||||
|
|
||||||
## https://github.com/The-Compiler/qutebrowser/issues/846
|
|
||||||
|
|
||||||
Scenario: Quitting with finished downloads and confirm-quit=downloads
|
|
||||||
Given I have a fresh instance
|
|
||||||
When I set storage -> prompt-download-directory to false
|
|
||||||
And I set ui -> confirm-quit to downloads
|
|
||||||
And I open data/downloads/download.bin
|
And I open data/downloads/download.bin
|
||||||
And I wait until the download is finished
|
And I wait for the download prompt for "*/download.bin"
|
||||||
And I run :close
|
# (tmpdir) equals {downloaddir}
|
||||||
Then qutebrowser should quit
|
And I run :prompt-accept (tmpdir)/subdir
|
||||||
|
And I open data/downloads/download2.bin
|
||||||
|
Then the download prompt should be shown with "{downloaddir}/subdir/download2.bin"
|
||||||
|
|
||||||
|
Scenario: Not remembering the last download directory
|
||||||
|
When I set storage -> prompt-download-directory to true
|
||||||
|
And I set completion -> download-path-suggestion to both
|
||||||
|
And I set storage -> remember-download-directory to false
|
||||||
|
And I open data/downloads/download.bin
|
||||||
|
And I wait for the download prompt for "{downloaddir}/download.bin"
|
||||||
|
# (tmpdir) equals {downloaddir}
|
||||||
|
And I run :prompt-accept (tmpdir)/subdir
|
||||||
|
And I open data/downloads/download2.bin
|
||||||
|
Then the download prompt should be shown with "{downloaddir}/download2.bin"
|
||||||
|
@ -30,11 +30,17 @@ pytestmark = pytest.mark.qtwebengine_todo("Downloads not implemented yet",
|
|||||||
run=False)
|
run=False)
|
||||||
|
|
||||||
|
|
||||||
|
PROMPT_MSG = ("Asking question <qutebrowser.utils.usertypes.Question "
|
||||||
|
"default={!r} mode=<PromptMode.download: 5> "
|
||||||
|
"text='Save file to:'>, *")
|
||||||
|
|
||||||
|
|
||||||
@bdd.given("I set up a temporary download dir")
|
@bdd.given("I set up a temporary download dir")
|
||||||
def temporary_download_dir(quteproc, tmpdir):
|
def temporary_download_dir(quteproc, tmpdir):
|
||||||
quteproc.set_setting('storage', 'prompt-download-directory', 'false')
|
quteproc.set_setting('storage', 'prompt-download-directory', 'false')
|
||||||
quteproc.set_setting('storage', 'remember-download-directory', 'false')
|
quteproc.set_setting('storage', 'remember-download-directory', 'false')
|
||||||
quteproc.set_setting('storage', 'download-directory', str(tmpdir))
|
quteproc.set_setting('storage', 'download-directory', str(tmpdir))
|
||||||
|
(tmpdir / 'subdir').ensure(dir=True)
|
||||||
|
|
||||||
|
|
||||||
@bdd.given("I clean old downloads")
|
@bdd.given("I clean old downloads")
|
||||||
@ -54,6 +60,12 @@ def wait_for_download_finished_name(quteproc, name):
|
|||||||
message='Download {} finished'.format(name))
|
message='Download {} finished'.format(name))
|
||||||
|
|
||||||
|
|
||||||
|
@bdd.when(bdd.parsers.parse('I wait for the download prompt for "{path}"'))
|
||||||
|
def wait_for_download_prompt(tmpdir, quteproc, path):
|
||||||
|
full_path = path.replace('{downloaddir}', str(tmpdir)).replace('/', os.sep)
|
||||||
|
quteproc.wait_for(message=PROMPT_MSG.format(full_path))
|
||||||
|
|
||||||
|
|
||||||
@bdd.when("I download an SSL page")
|
@bdd.when("I download an SSL page")
|
||||||
def download_ssl_page(quteproc, ssl_server):
|
def download_ssl_page(quteproc, ssl_server):
|
||||||
quteproc.send_cmd(':download https://localhost:{}/'
|
quteproc.send_cmd(':download https://localhost:{}/'
|
||||||
@ -76,10 +88,7 @@ def download_should_exist(filename, tmpdir):
|
|||||||
'"{path}"'))
|
'"{path}"'))
|
||||||
def download_prompt(tmpdir, quteproc, path):
|
def download_prompt(tmpdir, quteproc, path):
|
||||||
full_path = path.replace('{downloaddir}', str(tmpdir)).replace('/', os.sep)
|
full_path = path.replace('{downloaddir}', str(tmpdir)).replace('/', os.sep)
|
||||||
msg = ("Asking question <qutebrowser.utils.usertypes.Question "
|
quteproc.wait_for(message=PROMPT_MSG.format(full_path))
|
||||||
"default={full_path!r} mode=<PromptMode.download: 5> "
|
|
||||||
"text='Save file to:'>, *".format(full_path=full_path))
|
|
||||||
quteproc.wait_for(message=msg)
|
|
||||||
quteproc.send_cmd(':leave-mode')
|
quteproc.send_cmd(':leave-mode')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user