diff --git a/tests/integration/features/conftest.py b/tests/integration/features/conftest.py index 70d74d5ef..33710ce74 100644 --- a/tests/integration/features/conftest.py +++ b/tests/integration/features/conftest.py @@ -229,3 +229,29 @@ def check_contents(quteproc, filename): 'data', os.path.join(*filename.split('/'))) with open(path, 'r', encoding='utf-8') as f: assert content == f.read() + + +@bdd.then(bdd.parsers.parse("the following tabs should be open:\n{tabs}")) +def check_open_tabs(quteproc, tabs): + session = quteproc.get_session() + active_suffix = ' (active)' + tabs = tabs.splitlines() + assert len(session['windows']) == 1 + assert len(session['windows'][0]['tabs']) == len(tabs) + + for i, line in enumerate(tabs): + line = line.strip() + line = line[2:] # remove "- " prefix + if line.endswith(active_suffix): + path = line[:-len(active_suffix)] + active = True + else: + path = line + active = False + + session_tab = session['windows'][0]['tabs'][i] + assert session_tab['history'][-1]['url'] == quteproc.path_to_url(path) + if active: + assert session_tab['active'] + else: + assert 'active' not in session_tab diff --git a/tests/integration/features/set.feature b/tests/integration/features/set.feature index a0c3a8c55..21d8dc11d 100644 --- a/tests/integration/features/set.feature +++ b/tests/integration/features/set.feature @@ -59,14 +59,8 @@ Feature: Setting settings. Scenario: Opening qute:settings When I run :set And I wait for "load status for : LoadStatus.success" in the log - Then the session should look like: - windows: - - tabs: - - active: true - history: - - url: about:blank - - active: true - url: qute:settings + Then the following tabs should be open: + - qute:settings (active) Scenario: Empty option with ? (issue 1109) When I run :set general ? diff --git a/tests/integration/features/tabs.feature b/tests/integration/features/tabs.feature index 99e42b60c..c58bca55c 100644 --- a/tests/integration/features/tabs.feature +++ b/tests/integration/features/tabs.feature @@ -11,46 +11,28 @@ Feature: Tab management And I open data/numbers/2.txt in a new tab And I open data/numbers/3.txt in a new tab And I run :tab-close - Then the session should look like: - windows: - - tabs: - - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - active: true - history: - - url: http://localhost:*/data/numbers/2.txt + Then the following tabs should be open: + - data/numbers/1.txt + - data/numbers/2.txt (active) Scenario: :tab-close with count When I open data/numbers/1.txt And I open data/numbers/2.txt in a new tab And I open data/numbers/3.txt in a new tab And I run :tab-close with count 1 - Then the session should look like: - windows: - - tabs: - - history: - - url: http://localhost:*/data/numbers/2.txt - - active: true - history: - - url: http://localhost:*/data/numbers/3.txt + Then the following tabs should be open: + - data/numbers/2.txt + - data/numbers/3.txt (active) Scenario: :tab-close with invalid count When I open data/numbers/1.txt And I open data/numbers/2.txt in a new tab And I open data/numbers/3.txt in a new tab And I run :tab-close with count 23 - Then the session should look like: - windows: - - tabs: - - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - history: - - url: http://localhost:*/data/numbers/2.txt - - active: true - history: - - url: http://localhost:*/data/numbers/3.txt + Then the following tabs should be open: + - data/numbers/1.txt + - data/numbers/2.txt + - data/numbers/3.txt (active) Scenario: :tab-close with select-on-remove = right When I set tabs -> select-on-remove to right @@ -59,15 +41,9 @@ Feature: Tab management And I open data/numbers/3.txt in a new tab And I run :tab-focus 2 And I run :tab-close - Then the session should look like: - windows: - - tabs: - - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - active: true - history: - - url: http://localhost:*/data/numbers/3.txt + Then the following tabs should be open: + - data/numbers/1.txt + - data/numbers/3.txt (active) Scenario: :tab-close with select-on-remove = left When I set tabs -> select-on-remove to left @@ -76,15 +52,9 @@ Feature: Tab management And I open data/numbers/3.txt in a new tab And I run :tab-focus 2 And I run :tab-close - Then the session should look like: - windows: - - tabs: - - active: true - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - history: - - url: http://localhost:*/data/numbers/3.txt + Then the following tabs should be open: + - data/numbers/1.txt (active) + - data/numbers/3.txt Scenario: :tab-close with select-on-remove = previous When I set tabs -> select-on-remove to previous @@ -94,17 +64,10 @@ Feature: Tab management And I open data/numbers/4.txt in a new tab And I run :tab-focus 2 And I run :tab-close - Then the session should look like: - windows: - - tabs: - - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - history: - - url: http://localhost:*/data/numbers/3.txt - - active: true - history: - - url: http://localhost:*/data/numbers/4.txt + Then the following tabs should be open: + - data/numbers/1.txt + - data/numbers/3.txt + - data/numbers/4.txt (active) Scenario: :tab-close with select-on-remove = left and --right When I set tabs -> select-on-remove to left @@ -113,15 +76,9 @@ Feature: Tab management And I open data/numbers/3.txt in a new tab And I run :tab-focus 2 And I run :tab-close --right - Then the session should look like: - windows: - - tabs: - - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - active: true - history: - - url: http://localhost:*/data/numbers/3.txt + Then the following tabs should be open: + - data/numbers/1.txt + - data/numbers/3.txt (active) Scenario: :tab-close with select-on-remove = right and --left When I set tabs -> select-on-remove to right @@ -130,15 +87,9 @@ Feature: Tab management And I open data/numbers/3.txt in a new tab And I run :tab-focus 2 And I run :tab-close --left - Then the session should look like: - windows: - - tabs: - - active: true - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - history: - - url: http://localhost:*/data/numbers/3.txt + Then the following tabs should be open: + - data/numbers/1.txt (active) + - data/numbers/3.txt Scenario: :tab-close with select-on-remove = left and --opposite When I set tabs -> select-on-remove to left @@ -147,15 +98,9 @@ Feature: Tab management And I open data/numbers/3.txt in a new tab And I run :tab-focus 2 And I run :tab-close --opposite - Then the session should look like: - windows: - - tabs: - - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - active: true - history: - - url: http://localhost:*/data/numbers/3.txt + Then the following tabs should be open: + - data/numbers/1.txt + - data/numbers/3.txt (active) Scenario: :tab-close with select-on-remove = right and --opposite When I set tabs -> select-on-remove to right @@ -164,15 +109,9 @@ Feature: Tab management And I open data/numbers/3.txt in a new tab And I run :tab-focus 2 And I run :tab-close --opposite - Then the session should look like: - windows: - - tabs: - - active: true - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - history: - - url: http://localhost:*/data/numbers/3.txt + Then the following tabs should be open: + - data/numbers/1.txt (active) + - data/numbers/3.txt Scenario: :tab-close with select-on-remove = previous and --opposite When I set tabs -> select-on-remove to previous @@ -189,15 +128,9 @@ Feature: Tab management And I run :tab-close --left And I run :tab-focus 2 And I run :tab-close - Then the session should look like: - windows: - - tabs: - - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - active: true - history: - - url: http://localhost:*/data/numbers/4.txt + Then the following tabs should be open: + - data/numbers/1.txt + - data/numbers/4.txt (active) # :tab-only @@ -206,12 +139,8 @@ Feature: Tab management And I open data/numbers/2.txt in a new tab And I open data/numbers/3.txt in a new tab And I run :tab-only - Then the session should look like: - windows: - - tabs: - - active: true - history: - - url: http://localhost:*/data/numbers/3.txt + Then the following tabs should be open: + - data/numbers/3.txt (active) Scenario: :tab-only with --left When I open data/numbers/1.txt @@ -219,15 +148,9 @@ Feature: Tab management And I open data/numbers/3.txt in a new tab And I run :tab-focus 2 And I run :tab-only --left - Then the session should look like: - windows: - - tabs: - - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - active: true - history: - - url: http://localhost:*/data/numbers/2.txt + Then the following tabs should be open: + - data/numbers/1.txt + - data/numbers/2.txt (active) Scenario: :tab-only with --right When I open data/numbers/1.txt @@ -235,14 +158,9 @@ Feature: Tab management And I open data/numbers/3.txt in a new tab And I run :tab-focus 2 And I run :tab-only --right - Then the session should look like: - windows: - - tabs: - - active: true - history: - - url: http://localhost:*/data/numbers/2.txt - - history: - - url: http://localhost:*/data/numbers/3.txt + Then the following tabs should be open: + - data/numbers/2.txt (active) + - data/numbers/3.txt Scenario: :tab-only with --left and --right When I run :tab-only --left --right @@ -259,17 +177,10 @@ Feature: Tab management And I open data/numbers/2.txt in a new tab And I open data/numbers/3.txt in a new tab And I run :tab-focus 2 - Then the session should look like: - windows: - - tabs: - - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - active: true - history: - - url: http://localhost:*/data/numbers/2.txt - - history: - - url: http://localhost:*/data/numbers/3.txt + Then the following tabs should be open: + - data/numbers/1.txt + - data/numbers/2.txt (active) + - data/numbers/3.txt Scenario: :tab-focus without index/count When I open data/numbers/1.txt @@ -277,17 +188,10 @@ Feature: Tab management And I open data/numbers/3.txt in a new tab And I run :tab-focus 2 And I run :tab-focus - Then the session should look like: - windows: - - tabs: - - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - history: - - url: http://localhost:*/data/numbers/2.txt - - active: true - history: - - url: http://localhost:*/data/numbers/3.txt + Then the following tabs should be open: + - data/numbers/1.txt + - data/numbers/2.txt + - data/numbers/3.txt (active) Scenario: :tab-focus with invalid index When I run :tab-focus 23 @@ -302,17 +206,10 @@ Feature: Tab management And I open data/numbers/2.txt in a new tab And I open data/numbers/3.txt in a new tab And I run :tab-focus with count 2 - Then the session should look like: - windows: - - tabs: - - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - active: true - history: - - url: http://localhost:*/data/numbers/2.txt - - history: - - url: http://localhost:*/data/numbers/3.txt + Then the following tabs should be open: + - data/numbers/1.txt + - data/numbers/2.txt (active) + - data/numbers/3.txt Scenario: :tab-focus with count and index When I run :tab-focus 2 with count 2 @@ -325,17 +222,10 @@ Feature: Tab management And I run :tab-focus 1 And I run :tab-focus 3 And I run :tab-focus last - Then the session should look like: - windows: - - tabs: - - active: true - history: - - ... - - url: http://localhost:*/data/numbers/1.txt - - history: - - url: http://localhost:*/data/numbers/2.txt - - history: - - url: http://localhost:*/data/numbers/3.txt + Then the following tabs should be open: + - data/numbers/1.txt (active) + - data/numbers/2.txt + - data/numbers/3.txt Scenario: :tab-focus last with no last focused tab Given I have a fresh instance diff --git a/tests/integration/features/yankpaste.feature b/tests/integration/features/yankpaste.feature index 371abe1c1..28557e78a 100644 --- a/tests/integration/features/yankpaste.feature +++ b/tests/integration/features/yankpaste.feature @@ -67,16 +67,9 @@ Feature: Yanking and pasting. And I put "http://localhost:(port)/data/hello.txt" into the clipboard And I run :paste -t And I wait until data/hello.txt is loaded - Then the session should look like: - windows: - - tabs: - - history: - - active: true - url: about:blank - - active: true - history: - - active: true - url: http://localhost:*/data/hello.txt + Then the following tabs should be open: + - about:blank + - data/hello.txt (active) Scenario: Pasting in a background tab Given I open about:blank @@ -84,16 +77,9 @@ Feature: Yanking and pasting. And I put "http://localhost:(port)/data/hello.txt" into the clipboard And I run :paste -b And I wait until data/hello.txt is loaded - Then the session should look like: - windows: - - tabs: - - active: true - history: - - active: true - url: about:blank - - history: - - active: true - url: http://localhost:*/data/hello.txt + Then the following tabs should be open: + - about:blank (active) + - data/hello.txt Scenario: Pasting in a new window Given I have a fresh instance