diff --git a/tests/end2end/features/navigate.feature b/tests/end2end/features/navigate.feature index 94fa6b9c5..ec295c4d1 100644 --- a/tests/end2end/features/navigate.feature +++ b/tests/end2end/features/navigate.feature @@ -8,21 +8,6 @@ Feature: Using :navigate # up - Scenario: Navigating up - When I open data/navigate/sub - And I run :navigate up - Then data/navigate should be loaded - - Scenario: Navigating up with a query - When I open data/navigate/sub?foo=bar - And I run :navigate up - Then data/navigate should be loaded - - Scenario: Navigating up by count - When I open data/navigate/sub/index.html - And I run :navigate up with count 2 - Then data/navigate should be loaded - Scenario: Navigating up in qute://help/ When the documentation is up to date And I open qute://help/commands.html @@ -90,67 +75,8 @@ Feature: Using :navigate # increment/decrement - Scenario: Incrementing number in URL - When I open data/numbers/1.txt - And I run :navigate increment - Then data/numbers/2.txt should be loaded - - Scenario: Decrementing number in URL - When I open data/numbers/4.txt - And I run :navigate decrement - Then data/numbers/3.txt should be loaded - - Scenario: Decrementing with no number in URL - When I open data/navigate - And I run :navigate decrement - Then the error "No number found in URL!" should be shown - - Scenario: Incrementing with no number in URL - When I open data/navigate - And I run :navigate increment - Then the error "No number found in URL!" should be shown - - Scenario: Incrementing number in URL by count - When I open data/numbers/3.txt - And I run :navigate increment with count 3 - Then data/numbers/6.txt should be loaded - - Scenario: Decrementing number in URL by count - When I open data/numbers/8.txt - And I run :navigate decrement with count 5 - Then data/numbers/3.txt should be loaded - - Scenario: Setting url.incdec_segments - When I set url.incdec_segments to [anchor] - And I open data/numbers/1.txt - And I run :navigate increment - Then the error "No number found in URL!" should be shown - - Scenario: Incrementing query - When I set url.incdec_segments to ["query"] - And I open data/numbers/1.txt?value=2 - And I run :navigate increment - Then data/numbers/1.txt?value=3 should be loaded - @qtwebengine_todo: Doesn't find any elements Scenario: Navigating multiline links When I open data/navigate/multilinelinks.html And I run :navigate next Then data/numbers/5.txt should be loaded - - # strip - - Scenario: Stripping a query - When I open data/navigate?foo=bar - And I run :navigate strip - Then data/navigate should be loaded - - Scenario: Stripping a label - When I open data/navigate#label - And I run :navigate strip - Then data/navigate should be loaded - - Scenario: Stripping a query and a label - When I open data/navigate?foo=bar#label - And I run :navigate strip - Then data/navigate should be loaded diff --git a/tests/unit/browser/test_navigate.py b/tests/unit/browser/test_navigate.py index efabc3040..40f7a4673 100644 --- a/tests/unit/browser/test_navigate.py +++ b/tests/unit/browser/test_navigate.py @@ -179,3 +179,40 @@ class TestIncDec: valid_url = QUrl("http://example.com/0") with pytest.raises(ValueError): navigate.incdec(valid_url, 1, "foobar") + + +class TestUp: + + @pytest.mark.parametrize('url_suffix, count, expected_suffix', [ + ('/one/two/three', 1, '/one/two'), + ('/one/two/three?foo=bar', 1, '/one/two'), + ('/one/two/three', 2, '/one'), + ]) + def test_up(self, url_suffix, count, expected_suffix): + url_base = 'https://example.com' + url = QUrl(url_base + url_suffix) + assert url.isValid() + + new = navigate.path_up(url, count) + assert new == QUrl(url_base + expected_suffix) + + +class TestStrip: + + @pytest.mark.parametrize('url_suffix', [ + '?foo=bar', + '#label', + '?foo=bar#label', + ]) + def test_strip(self, url_suffix): + url_base = 'https://example.com/test' + url = QUrl(url_base + url_suffix) + assert url.isValid() + + stripped = navigate.strip(url, count=1) + assert stripped.isValid() + assert stripped == QUrl(url_base) + + def test_count(self): + with pytest.raises(navigate.Error, match='Count is not supported'): + navigate.strip(QUrl('https://example.com/'), count=2)