Skip to content

Commit 753762d

Browse files
committed
Add reading/term form interaction acceptance smoke test.
1 parent acf20b2 commit 753762d

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

tests/acceptance/conftest.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,50 @@ def when_click_word(luteclient, word):
426426
luteclient.click_word(word)
427427

428428

429+
@then(parsers.parse('the reading page term form shows term "{text}"'))
430+
def then_reading_page_term_form_iframe_shows_term(luteclient, text):
431+
"Have to get and read the iframe content, it's not in the main browser page."
432+
with luteclient.browser.get_iframe("wordframe") as iframe:
433+
time.sleep(0.4) # Hack, test failing.
434+
term_field = iframe.find_by_css("#text").first
435+
zws = "\u200B"
436+
val = term_field.value.replace(zws, "")
437+
assert val == text, "check field value"
438+
439+
440+
@then("the bulk edit term form is shown")
441+
def then_reading_page_bulk_edit_term_form_is_shown(luteclient):
442+
"Check content."
443+
then_reading_page_term_form_iframe_contains(luteclient, "Updating")
444+
445+
446+
@then("the term form is hidden")
447+
def then_reading_page_term_form_is_hidden(luteclient):
448+
"Set to blankn"
449+
iframe_element = luteclient.browser.find_by_id("wordframeid").first
450+
iframe_src = iframe_element["src"]
451+
assert iframe_src == "about:blank"
452+
453+
429454
@when(parsers.parse("I shift click:\n{words}"))
430455
def shift_click_terms(luteclient, words):
431456
"Shift-click"
432457
words = words.split("\n")
433458
luteclient.shift_click_words(words)
434459

435460

461+
@when(parsers.parse('I shift-drag from "{wstart}" to "{wend}"'))
462+
def shift_drag(luteclient, wstart, wend):
463+
"shift-drag highlights multiple words, copies to clipboard."
464+
luteclient.shift_drag(wstart, wend)
465+
466+
467+
@when(parsers.parse('I drag from "{wstart}" to "{wend}"'))
468+
def drag(luteclient, wstart, wend):
469+
"shift-drag highlights multiple words, copies to clipboard."
470+
luteclient.drag(wstart, wend)
471+
472+
436473
@when(parsers.parse('I click "{word}" and press hotkey "{hotkey}"'))
437474
def when_click_word_press_hotkey(luteclient, word, hotkey):
438475
"Click word and press hotkey."

tests/acceptance/lute_test_client.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,36 @@ def shift_click_words(self, words):
339339
ac = ac.key_up(Keys.SHIFT)
340340
ac.perform()
341341

342+
def shift_drag(self, fromword, toword):
343+
"Shift-drag over words."
344+
# https://stackoverflow.com/questions/27775759/
345+
# send-keys-control-click-in-selenium-with-python-bindings
346+
# pylint: disable=protected-access
347+
[fromel, toel] = [
348+
self._get_element_for_word(w)._element for w in [fromword, toword]
349+
]
350+
actions = ActionChains(self.browser.driver)
351+
actions.key_down(Keys.SHIFT)
352+
actions.click_and_hold(fromel)
353+
actions.move_to_element(toel)
354+
actions.key_up(Keys.SHIFT)
355+
actions.release()
356+
actions.perform()
357+
358+
def drag(self, fromword, toword):
359+
"drag over words."
360+
# https://stackoverflow.com/questions/27775759/
361+
# send-keys-control-click-in-selenium-with-python-bindings
362+
# pylint: disable=protected-access
363+
[fromel, toel] = [
364+
self._get_element_for_word(w)._element for w in [fromword, toword]
365+
]
366+
actions = ActionChains(self.browser.driver)
367+
actions.click_and_hold(fromel)
368+
actions.move_to_element(toel)
369+
actions.release()
370+
actions.perform()
371+
342372
def fill_reading_bulk_edit_form(self, updates=None):
343373
"""
344374
Click a word in the reading frame, fill in the term form iframe.
@@ -367,6 +397,7 @@ def fill_reading_bulk_edit_form(self, updates=None):
367397
def press_hotkey(self, hotkey):
368398
"Send a hotkey."
369399
key_to_code_map = {
400+
"escape": "Escape",
370401
"1": "Digit1",
371402
"2": "Digit2",
372403
"3": "Digit3",

tests/acceptance/reading.feature

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,34 @@ Feature: User can actually read and stuff.
220220
Tengo (1)/ /otro/ /amigo (1)/.
221221

222222

223+
Scenario: Edit forms are shown at appropriate times
224+
Given a Spanish book "Hola" with content:
225+
Tengo un amigo y una bebida.
226+
227+
When I click "amigo"
228+
Then the reading page term form shows term "amigo"
229+
When I shift-drag from "Tengo" to "un"
230+
Then the reading page term form shows term "amigo"
231+
232+
When I shift click:
233+
una
234+
bebida
235+
Then the bulk edit term form is shown
236+
When I press hotkey "1"
237+
Then the term form is hidden
238+
239+
When I drag from "una" to "bebida"
240+
Then the reading page term form shows term "una bebida"
241+
242+
When I press hotkey "escape"
243+
Then the term form is hidden
244+
245+
When I drag from "una" to "bebida"
246+
Then the reading page term form shows term "una bebida"
247+
When I shift-drag from "Tengo" to "un"
248+
Then the reading page term form shows term "una bebida"
249+
250+
223251
Scenario: Bulk editing terms while reading
224252
Given a Spanish book "Hola" with content:
225253
Tengo otro amigo.

0 commit comments

Comments
 (0)