Skip to content

Commit 1ca8ae3

Browse files
committed
Fix
1 parent e35caf2 commit 1ca8ae3

File tree

2 files changed

+109
-15
lines changed

2 files changed

+109
-15
lines changed

tests/integration/_interactions.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
from enum import Enum
88
from typing import NamedTuple
9+
from typing import Any
10+
from typing import TypedDict
11+
12+
from ansible_navigator.utils.definitions import ExitMessage
13+
from ansible_navigator.utils.definitions import LogMessage
914

1015

1116
class SearchFor(Enum):
@@ -61,6 +66,64 @@ def join(self) -> str:
6166
return cmd
6267

6368

69+
class Action(TypedDict):
70+
"""A definition of an action."""
71+
72+
#: The action to be performed
73+
value: str
74+
#: A comment to be added to the fixture file
75+
comment: str | None
76+
#: The key to be pressed
77+
keystroke: str
78+
79+
80+
# A list of actions that can be performed
81+
# The value is the name of the action, which is also the name of the file
82+
# The keystroke is the key that will be sent to the TUI
83+
# The comment is a comment that will be added to the fixture file
84+
# The last entry in the list is the one that will be used for the test
85+
# if the test is run with the --update-fixtures option
86+
ACTIONS: dict[str, list[Action]] = {
87+
"0": [{"value": "0", "keystroke": "0", "comment": None}],
88+
"1": [{"value": "1", "keystroke": "1", "comment": None}],
89+
"2": [{"value": "2", "keystroke": "2", "comment": None}],
90+
"3": [{"value": "3", "keystroke": "3", "comment": None}],
91+
"4": [{"value": "4", "keystroke": "4", "comment": None}],
92+
"5": [{"value": "5", "keystroke": "5", "comment": None}],
93+
"6": [{"value": "6", "keystroke": "6", "comment": None}],
94+
"7": [{"value": "7", "keystroke": "7", "comment": None}],
95+
"8": [{"value": "8", "keystroke": "8", "comment": None}],
96+
"9": [{"value": "9", "keystroke": "9", "comment": None}],
97+
"10": [{"value": "10", "keystroke": "10", "comment": None}],
98+
"11": [{"value": "11", "keystroke": "11", "comment": None}],
99+
"12": [{"value": "12", "keystroke": "12", "comment": None}],
100+
"13": [{"value": "13", "keystroke": "13", "comment": None}],
101+
"14": [{"value": "14", "keystroke": "14", "comment": None}],
102+
"15": [{"value": "15", "keystroke": "15", "comment": None}],
103+
"16": [{"value": "16", "keystroke": "16", "comment": None}],
104+
"17": [{"value": "17", "keystroke": "17", "comment": None}],
105+
"18": [{"value": "18", "keystroke": "18", "comment": None}],
106+
"19": [{"value": "19", "keystroke": "19", "comment": None}],
107+
"20": [{"value": "20", "keystroke": "20", "comment": None}],
108+
"21": [{"value": "21", "keystroke": "21", "comment": None}],
109+
"22": [{"value": "22", "keystroke": "22", "comment": None}],
110+
"23": [{"value": "23", "keystroke": "23", "comment": None}],
111+
"24": [{"value": "24", "keystroke": "24", "comment": None}],
112+
"25": [{"value": "25", "keystroke": "25", "comment": None}],
113+
"26": [{"value": "26", "keystroke": "26", "comment": None}],
114+
"27": [{"value": "27", "keystroke": "27", "comment": None}],
115+
"28": [{"value": "28", "keystroke": "28", "comment": None}],
116+
"29": [{"value": "29", "keystroke": "29", "comment": None}],
117+
"30": [{"value": "30", "keystroke": "30", "comment": None}],
118+
"down": [{"value": "down", "keystroke": "KEY_DOWN", "comment": "menu down"}],
119+
"up": [{"value": "up", "keystroke": "KEY_UP", "comment": "menu up"}],
120+
"esc": [{"value": "escape", "keystroke": "KEY_ESCAPE", "comment": "escape"}],
121+
"top": [{"value": "top", "keystroke": "KEY_HOME", "comment": "home"}],
122+
"bottom": [{"value": "bottom", "keystroke": "KEY_END", "comment": "end"}],
123+
"enter": [{"value": "enter", "keystroke": "KEY_ENTER", "comment": "enter"}],
124+
}
125+
126+
64127
class UiTestStep(NamedTuple):
65128
"""A simulated user interaction with the user interface."""
66129

tests/integration/actions/collections/base.py

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,46 @@
2121
EXPECTED_COLLECTIONS = ["ansible.builtin", "company_name.coll_1", "company_name.coll_2"]
2222

2323
base_steps = (
24-
UiTestStep(user_input=":1", comment="Browse company_name.coll_1 plugins window"),
25-
UiTestStep(user_input=":0", comment="filter_1 plugin docs window"),
24+
# In collections list, start at ansible.builtin (0)
25+
# Select company_name.coll_1 (1)
26+
UiTestStep(user_input="down", comment="select company_name.coll_1"),
27+
UiTestStep(user_input="enter", comment="Browse company_name.coll_1 plugins window"),
28+
# In company_name.coll_1 plugins list, start at filter_1 (0)
29+
UiTestStep(user_input="enter", comment="filter_1 plugin docs window"),
2630
UiTestStep(user_input=":back", comment="Back to browse company_name.coll_1 plugins window"),
27-
UiTestStep(user_input=":1", comment="lookup_1 plugin docs window"),
31+
# from filter_1 (0) to lookup_1 (1)
32+
UiTestStep(user_input="down", comment="select lookup_1"),
33+
UiTestStep(user_input="enter", comment="lookup_1 plugin docs window"),
2834
UiTestStep(user_input=":back", comment="Back to browse company_name.coll_1 plugins window"),
29-
UiTestStep(user_input=":2", comment="mod_1 plugin docs window"),
35+
# from lookup_1 (1) to mod_1 (2)
36+
UiTestStep(user_input="down", comment="select mod_1"),
37+
UiTestStep(user_input="enter", comment="mod_1 plugin docs window"),
3038
UiTestStep(user_input=":back", comment="Back to browse company_name.coll_1 plugins window"),
31-
UiTestStep(user_input=":3", comment="role_full details window"),
39+
# from mod_1 (2) to role_full (3)
40+
UiTestStep(user_input="down", comment="select role_full"),
41+
UiTestStep(user_input="enter", comment="role_full details window"),
3242
UiTestStep(user_input=":back", comment="Back to browse company_name.coll_1 plugins window"),
33-
UiTestStep(user_input=":4", comment="role_minimal details window"),
43+
# from role_full (3) to role_minimal (4)
44+
UiTestStep(user_input="down", comment="select role_minimal"),
45+
UiTestStep(user_input="enter", comment="role_minimal details window"),
3446
UiTestStep(user_input=":back", comment="Back to browse company_name.coll_1 plugins window"),
47+
# Back to collections list window
3548
UiTestStep(
3649
user_input=":back",
3750
comment="Back to ansible-navigator collections browse window",
3851
present=EXPECTED_COLLECTIONS,
3952
),
40-
UiTestStep(user_input=":2", comment="Browse company_name.coll_2 plugins window"),
41-
UiTestStep(user_input=":0", comment="lookup_2 plugin docs window"),
53+
# From company_name.coll_1 (1) to company_name.coll_2 (2)
54+
UiTestStep(user_input="down", comment="select company_name.coll_2"),
55+
UiTestStep(user_input="enter", comment="Browse company_name.coll_2 plugins window"),
56+
# In company_name.coll_2, start at lookup_2 (0)
57+
UiTestStep(user_input="enter", comment="lookup_2 plugin docs window"),
4258
UiTestStep(user_input=":back", comment="Back to browse company_name.coll_2 plugins window"),
43-
UiTestStep(user_input=":1", comment="mod_2 plugin docs window"),
59+
# From lookup_2 (0) to mod_2 (1)
60+
UiTestStep(user_input="down", comment="select mod_2"),
61+
UiTestStep(user_input="enter", comment="mod_2 plugin docs window"),
4462
UiTestStep(user_input=":back", comment="Back to browse company_name.coll_2 plugins window"),
63+
# Back to collections list window
4564
UiTestStep(
4665
user_input=":back",
4766
comment="Back to ansible-navigator collections browse window",
@@ -56,28 +75,40 @@
5675
),
5776
# Dismiss the warning
5877
UiTestStep(
59-
user_input="Enter",
78+
user_input="enter",
6079
comment="ansible-navigator collections browse window",
6180
present=EXPECTED_COLLECTIONS,
6281
),
6382
# and repeat some basic browsing
64-
UiTestStep(user_input=":1", comment="Browse company_name.coll_1 plugins window"),
65-
UiTestStep(user_input=":0", comment="filter_1 plugin docs window"),
83+
# Select company_name.coll_1 (1)
84+
UiTestStep(user_input="down", comment="select company_name.coll_1"),
85+
UiTestStep(user_input="enter", comment="Browse company_name.coll_1 plugins window"),
86+
# In company_name.coll_1, start at filter_1 (0)
87+
UiTestStep(user_input="enter", comment="filter_1 plugin docs window"),
6688
UiTestStep(user_input=":back", comment="Back to browse company_name.coll_1 plugins window"),
67-
UiTestStep(user_input=":1", comment="lookup_1 plugin docs window"),
89+
# from filter_1 (0) to lookup_1 (1)
90+
UiTestStep(user_input="down", comment="select lookup_1"),
91+
UiTestStep(user_input="enter", comment="lookup_1 plugin docs window"),
6892
UiTestStep(user_input=":back", comment="Back to browse company_name.coll_1 plugins window"),
93+
# Back to collections list window
6994
UiTestStep(
7095
user_input=":back",
7196
comment="Back to ansible-navigator collections browse window",
7297
present=EXPECTED_COLLECTIONS,
7398
),
99+
# From company_name.coll_1 (1) to ansible.builtin (0)
100+
UiTestStep(user_input="up", comment="select ansible.builtin"),
74101
UiTestStep(
75-
user_input=":0",
102+
user_input="enter",
76103
comment="Browse ansible.builtin plugins window",
77104
present=["yum_repository"],
78105
),
79106
UiTestStep(
80-
user_input=":1",
107+
user_input="down",
108+
comment="Browse ansible.builtin.add_host module",
109+
),
110+
UiTestStep(
111+
user_input="enter",
81112
comment="Browse ansible.builtin.add_host module",
82113
present=["ansible.builtin.add_host"],
83114
),

0 commit comments

Comments
 (0)