mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-22 14:38:03 +01:00
Improve effects tests
This commit is contained in:
parent
8afde36807
commit
89f868f48f
1 changed files with 20 additions and 7 deletions
|
@ -143,8 +143,11 @@ def test_player_can_add_effect_to_group(
|
||||||
|
|
||||||
go_to_party(selenium, live_server, party, user, password)
|
go_to_party(selenium, live_server, party, user, password)
|
||||||
fill_effect(selenium, name, description, target, remaining_rounds)
|
fill_effect(selenium, name, description, target, remaining_rounds)
|
||||||
assert_effect_is_created(name, description, target, remaining_rounds)
|
effect = assert_effect_is_created(name, description, target, remaining_rounds)
|
||||||
# Todo: assert effect is displayed
|
element = selenium.find_element(By.CSS_SELECTOR, f'.effect[data-id="{effect.pk}"]')
|
||||||
|
assert effect.name in element.text
|
||||||
|
assert effect.target in element.text
|
||||||
|
assert effect.description in element.text
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
@ -171,8 +174,11 @@ def test_gm_can_add_effect_to_group(
|
||||||
|
|
||||||
go_to_party(selenium, live_server, party, user, password)
|
go_to_party(selenium, live_server, party, user, password)
|
||||||
fill_effect(selenium, name, description, target, remaining_rounds)
|
fill_effect(selenium, name, description, target, remaining_rounds)
|
||||||
assert_effect_is_created(name, description, target, remaining_rounds)
|
effect = assert_effect_is_created(name, description, target, remaining_rounds)
|
||||||
# Todo: assert effect is displayed
|
element = selenium.find_element(By.CSS_SELECTOR, f'.effect[data-id="{effect.pk}"]')
|
||||||
|
assert effect.name in element.text
|
||||||
|
assert effect.target in element.text
|
||||||
|
assert effect.description in element.text
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
@ -296,7 +302,9 @@ def test_player_cant_change_existing_running_effect(
|
||||||
selenium.find_element(By.ID, "decrease-rounds")
|
selenium.find_element(By.ID, "decrease-rounds")
|
||||||
|
|
||||||
|
|
||||||
def fill_effect(selenium, name, description, target, remaining_rounds):
|
def fill_effect(
|
||||||
|
selenium: WebDriver, name: str, description: str, target: str, remaining_rounds: str
|
||||||
|
) -> None:
|
||||||
selenium.find_element(By.ID, "add-effect").click()
|
selenium.find_element(By.ID, "add-effect").click()
|
||||||
selenium.find_element(By.ID, "id_name").send_keys(name)
|
selenium.find_element(By.ID, "id_name").send_keys(name)
|
||||||
selenium.find_element(By.ID, "id_target").send_keys(target)
|
selenium.find_element(By.ID, "id_target").send_keys(target)
|
||||||
|
@ -307,16 +315,21 @@ def fill_effect(selenium, name, description, target, remaining_rounds):
|
||||||
selenium.find_element(By.CSS_SELECTOR, "button[type=submit]").click()
|
selenium.find_element(By.CSS_SELECTOR, "button[type=submit]").click()
|
||||||
|
|
||||||
|
|
||||||
def assert_effect_is_created(name, description, target, remaining_rounds):
|
def assert_effect_is_created(
|
||||||
|
name: str, description: str, target: str, remaining_rounds: str
|
||||||
|
) -> BattleEffect:
|
||||||
assert BattleEffect.objects.count() == 1
|
assert BattleEffect.objects.count() == 1
|
||||||
effect = BattleEffect.objects.first()
|
effect = BattleEffect.objects.first()
|
||||||
assert effect.name == name
|
assert effect.name == name
|
||||||
assert effect.target == target
|
assert effect.target == target
|
||||||
assert effect.description == description
|
assert effect.description == description
|
||||||
assert str(effect.remaining_rounds) == remaining_rounds
|
assert str(effect.remaining_rounds) == remaining_rounds
|
||||||
|
return effect
|
||||||
|
|
||||||
|
|
||||||
def go_to_party(selenium, live_server, party, user, password):
|
def go_to_party(
|
||||||
|
selenium: WebDriver, live_server: LiveServer, party: Party, user: str, password: str
|
||||||
|
) -> None:
|
||||||
login(selenium, live_server, user, password)
|
login(selenium, live_server, user, password)
|
||||||
url = reverse("party:details", kwargs={"pk": party.pk})
|
url = reverse("party:details", kwargs={"pk": party.pk})
|
||||||
selenium.get(live_server.url + url)
|
selenium.get(live_server.url + url)
|
||||||
|
|
Loading…
Reference in a new issue