@@ -17,10 +17,11 @@ def test_no_codename_hint_on_second_login(self, sd_servers_v2, tor_browser_web_d
1717 )
1818
1919 # Given a source user who creates an account
20- # When they first login
20+ # When they first submit a message
2121 navigator .source_visits_source_homepage ()
2222 navigator .source_clicks_submit_documents_on_homepage ()
2323 navigator .source_continues_to_submit_page ()
24+ navigator .source_submits_a_message ("they're here" )
2425
2526 # Then they are able to retrieve their codename from the UI
2627 source_codename = navigator .source_retrieves_codename_from_hint ()
@@ -72,10 +73,16 @@ def test_submission_notifications_on_second_login(self, sd_servers_v2, tor_brows
7273 web_driver = tor_browser_web_driver ,
7374 )
7475
75- # Given a source user who creates an account
76+ # Given a source user who creates an account by submitting a
77+ # message on first login
7678 navigator .source_visits_source_homepage ()
7779 navigator .source_clicks_submit_documents_on_homepage ()
7880 navigator .source_continues_to_submit_page ()
81+ confirmation_text_first_submission = navigator .source_submits_a_message ()
82+
83+ # And they see the expected confirmation messages for a first submission on second login
84+ assert self .FIRST_SUBMISSION_TEXT in confirmation_text_first_submission
85+
7986 source_codename = navigator .source_retrieves_codename_from_hint ()
8087 assert source_codename
8188
@@ -85,12 +92,6 @@ def test_submission_notifications_on_second_login(self, sd_servers_v2, tor_brows
8592 navigator .source_chooses_to_login ()
8693 navigator .source_proceeds_to_login (codename = source_codename )
8794
88- # Then it succeeds
89- confirmation_text_first_submission = navigator .source_submits_a_message ()
90-
91- # And they see the expected confirmation messages for a first submission on second login
92- assert self .FIRST_SUBMISSION_TEXT in confirmation_text_first_submission
93-
9495 # And when they submit a second message
9596 confirmation_text_second_submission = navigator .source_submits_a_message ()
9697
@@ -127,110 +128,37 @@ def test_generate_codenames_in_multiple_tabs(self, sd_servers_v2, tor_browser_we
127128 web_driver = tor_browser_web_driver ,
128129 )
129130
130- # Given a user who generated a codename in Tab A
131+ # Given a user who opens /lookup in tab A
131132 tab_a = navigator .driver .window_handles [0 ]
132133 navigator .source_visits_source_homepage ()
133134 navigator .source_clicks_submit_documents_on_homepage ()
134- codename_a = self . _extract_generated_codename ( navigator )
135+ navigator . source_continues_to_submit_page ( )
135136
136137 # And they then opened a new tab, Tab B
137138 navigator .driver .execute_script ("window.open('about:blank', '_blank')" )
138139 tab_b = navigator .driver .window_handles [1 ]
139140 navigator .driver .switch_to .window (tab_b )
140141 assert tab_a != tab_b
141142
142- # And they also generated another codename in Tab B
143+ # And they also opened /lookup in Tab B
143144 navigator .source_visits_source_homepage ()
144145 navigator .source_clicks_submit_documents_on_homepage ()
145- codename_b = self ._extract_generated_codename (navigator )
146- assert codename_a != codename_b
146+ navigator .source_continues_to_submit_page ()
147147
148148 # And they ended up creating their account and submitting documents in Tab A
149149 navigator .driver .switch_to .window (tab_a )
150150 navigator .source_continues_to_submit_page ()
151151 self ._assert_is_on_lookup_page (navigator )
152- assert navigator .source_retrieves_codename_from_hint () == codename_a
153152 navigator .source_submits_a_message ()
153+ passphrase_a = navigator .source_retrieves_codename_from_hint ()
154154
155155 # When the user tries to create an account and submit documents in Tab B
156156 navigator .driver .switch_to .window (tab_b )
157- navigator .source_continues_to_submit_page ()
158-
159- # Then the submission fails and the user sees the corresponding flash message in Tab B
160- self ._assert_is_on_lookup_page (navigator )
161- notification = navigator .source_sees_flash_message ()
162- if not navigator .accept_languages :
163- assert "You are already logged in." in notification .text
164-
165- # And the user's actual codename is the one initially generated in Tab A
166- assert navigator .source_retrieves_codename_from_hint () == codename_a
167-
168- def test_generate_and_refresh_codenames_in_multiple_tabs (
169- self , sd_servers_v2 , tor_browser_web_driver
170- ):
171- navigator = SourceAppNagivator (
172- source_app_base_url = sd_servers_v2 .source_app_base_url ,
173- web_driver = tor_browser_web_driver ,
174- )
175-
176- # Given a user who generated a codename in Tab A
177- tab_a = navigator .driver .window_handles [0 ]
178- navigator .source_visits_source_homepage ()
179- navigator .source_clicks_submit_documents_on_homepage ()
180- codename_a1 = self ._extract_generated_codename (navigator )
181-
182- # And they then re-generated their codename in Tab
183- navigator .source_visits_source_homepage ()
184- navigator .source_clicks_submit_documents_on_homepage ()
185- codename_a2 = self ._extract_generated_codename (navigator )
186- assert codename_a1 != codename_a2
187-
188- # And they then opened a new tab, Tab B
189- navigator .driver .execute_script ("window.open('about:blank', '_blank')" )
190- tab_b = navigator .driver .window_handles [1 ]
191- navigator .driver .switch_to .window (tab_b )
192- assert tab_a != tab_b
193-
194- # And they also generated another codename in Tab B
195- navigator .source_visits_source_homepage ()
196- navigator .source_clicks_submit_documents_on_homepage ()
197- codename_b = self ._extract_generated_codename (navigator )
198- assert codename_a2 != codename_b
199-
200- # And they ended up creating their account and submitting documents in Tab A
201- navigator .driver .switch_to .window (tab_a )
202- navigator .source_continues_to_submit_page ()
203- self ._assert_is_on_lookup_page (navigator )
204- assert navigator .source_retrieves_codename_from_hint () == codename_a2
205157 navigator .source_submits_a_message ()
158+ passphrase_b = navigator .source_retrieves_codename_from_hint ()
206159
207- # When they try to re-generate a codename in Tab B
208- navigator .driver .switch_to .window (tab_b )
209- navigator .source_visits_source_homepage ()
210- navigator .nav_helper .safe_click_by_css_selector ("#started-form button" )
211-
212- # Then they get redirected to /lookup with the corresponding flash message
160+ # Then the submission succeeds
213161 self ._assert_is_on_lookup_page (navigator )
214- notification = navigator .source_sees_flash_message ()
215- if not navigator .accept_languages :
216- assert "You were redirected because you are already logged in." in notification .text
217-
218- # And the user's actual codename is the expected one
219- assert navigator .source_retrieves_codename_from_hint () == codename_a2
220-
221- # TODO(AD): This test takes ~50s ; we could refactor it to speed it up
222- def test_codenames_exceed_max_cookie_size (self , sd_servers_v2 , tor_browser_web_driver ):
223- """Test generation of enough codenames that the resulting cookie exceeds the recommended
224- `werkzeug.Response.max_cookie_size` = 4093 bytes. (#6043)
225- """
226- navigator = SourceAppNagivator (
227- source_app_base_url = sd_servers_v2 .source_app_base_url ,
228- web_driver = tor_browser_web_driver ,
229- )
230162
231- too_many = 2 * (werkzeug .Response .max_cookie_size // len (VALID_PASSWORD ))
232- for _ in range (too_many ):
233- navigator .source_visits_source_homepage ()
234- navigator .source_clicks_submit_documents_on_homepage ()
235-
236- navigator .source_continues_to_submit_page ()
163+ # And the user's actual codename is the one initially generated in Tab A
164+ assert passphrase_b == passphrase_a
0 commit comments