From 20da259de6995ab9143969e0caa38cb5f8e77d67 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 8 Sep 2018 16:01:38 +0200 Subject: [PATCH] Rewrite some :follow-selected tests as unit tests --- tests/end2end/features/caret.feature | 25 ------------------------- tests/unit/browser/test_caret.py | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/tests/end2end/features/caret.feature b/tests/end2end/features/caret.feature index 422919cea..e540bafcb 100644 --- a/tests/end2end/features/caret.feature +++ b/tests/end2end/features/caret.feature @@ -45,31 +45,6 @@ Feature: Caret mode # :follow-selected - Scenario: :follow-selected without a selection - When I run :follow-selected - Then no crash should happen - - Scenario: :follow-selected with text - When I run :move-to-next-word - And I run :toggle-selection - And I run :move-to-end-of-word - And I run :follow-selected - Then no crash should happen - - Scenario: :follow-selected with link (with JS) - When I set content.javascript.enabled to true - And I run :toggle-selection - And I run :move-to-end-of-word - And I run :follow-selected - Then data/hello.txt should be loaded - - Scenario: :follow-selected with link (without JS) - When I set content.javascript.enabled to false - And I run :toggle-selection - And I run :move-to-end-of-word - And I run :follow-selected - Then data/hello.txt should be loaded - Scenario: :follow-selected with --tab (with JS) When I set content.javascript.enabled to true And I run :tab-only diff --git a/tests/unit/browser/test_caret.py b/tests/unit/browser/test_caret.py index c7e100a59..0fd434a77 100644 --- a/tests/unit/browser/test_caret.py +++ b/tests/unit/browser/test_caret.py @@ -315,3 +315,25 @@ class TestSearch: caret.move_to_end_of_line() selection.check('wei drei') + + +class TestFollowSelected: + + def test_follow_selected_without_a_selection(self, caret, selection): + caret.follow_selected() + + def test_follow_selected_with_text(self, caret, selection): + caret.move_to_next_word() + selection.toggle() + caret.move_to_end_of_word() + caret.follow_selected() + + @pytest.mark.parametrize('with_js', [True, False]) + def test_follow_selected_with_link(self, caret, selection, config_stub, + qtbot, web_tab, with_js): + config_stub.val.content.javascript.enabled = with_js + selection.toggle() + caret.move_to_end_of_word() + with qtbot.wait_signal(web_tab.load_finished): + caret.follow_selected() + assert web_tab.url().path() == '/data/hello.txt'