Beispiel #1
0
def test_ability_scores_persist(player_wizard, browser): # noqa
    """As a player, ability scores persist after page refresh."""
    print('As a player, ability scores persist after page refresh.')
    ability_scores_edit = AbilityScoresEditModal(browser)
    ability_scores_table = AbilityScoresTable(browser)

    tabs = Tabs(browser)
    tabs.stats.click()

    ability_scores_table.table.click()
    ability_scores_edit.strength = 15
    ability_scores_edit.dexterity = 16
    ability_scores_edit.constitution = 17
    ability_scores_edit.intelligence = 16
    ability_scores_edit.wisdom = 15
    ability_scores_edit.charisma = 14

    ability_scores_edit.done.click()

    WebDriverWait(browser, 10).until(
        EC.text_to_be_present_in_element(
            (By.ID, ability_scores_table.strength.get_attribute('id')),
            '15'
        )
    )

    browser.refresh()

    assert ability_scores_table.strength.text == '15'
    assert ability_scores_table.dexterity.text == '16'
    assert ability_scores_table.constitution.text == '17'
    assert ability_scores_table.intelligence.text == '16'
    assert ability_scores_table.wisdom.text == '15'
    assert ability_scores_table.charisma.text == '14'
Beispiel #2
0
def test_ability_scores_modifiers(player_wizard, browser): # noqa
    """As a player, I can view my ability score modifiers."""
    print('As a player, I can view my ability score modifiers.')
    ability_scores_edit = AbilityScoresEditModal(browser)
    ability_scores_table = AbilityScoresTable(browser)

    tabs = Tabs(browser)
    tabs.stats.click()

    ability_scores_table.table.click()
    ability_scores_edit.strength = 15
    ability_scores_edit.dexterity = 16
    ability_scores_edit.constitution = 17
    ability_scores_edit.intelligence = 16
    ability_scores_edit.wisdom = 15
    ability_scores_edit.charisma = 14

    ability_scores_edit.done.click()

    WebDriverWait(browser, 10).until(
        EC.text_to_be_present_in_element(
            (By.ID, ability_scores_table.strength.get_attribute('id')),
            '15'
        )
    )

    assert ability_scores_table.strength_modifier.text == '+ 2'
    assert ability_scores_table.dexterity_modifier.text == '+ 3'
    assert ability_scores_table.constitution_modifier.text == '+ 3'
    assert ability_scores_table.intelligence_modifier.text == '+ 3'
    assert ability_scores_table.wisdom_modifier.text == '+ 2'
    assert ability_scores_table.charisma_modifier.text == '+ 2'
Beispiel #3
0
def test_edit_ability_scores(player_wizard, browser):  # noqa
    """As a player, I can edit my ability scores."""

    print('As a player, I can edit my ability scores.')

    time.sleep(8)

    ability_scores_edit = AbilityScoresEditModal(browser)
    ability_scores_table = AbilityScoresTable(browser)

    ability_scores_table.table.click()
    ability_scores_edit.strength = 15
    ability_scores_edit.dexterity = 16
    ability_scores_edit.constitution = 17
    ability_scores_edit.intelligence = 16
    ability_scores_edit.wisdom = 15
    ability_scores_edit.charisma = 14

    ability_scores_edit.done.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.text_to_be_present_in_element(
            (By.ID, ability_scores_table.strength.get_attribute('id')), '15'))

    assert ability_scores_table.strength.text.strip() == '15'
    assert ability_scores_table.dexterity.text.strip() == '16'
    assert ability_scores_table.constitution.text.strip() == '17'
    assert ability_scores_table.intelligence.text.strip() == '16'
    assert ability_scores_table.wisdom.text.strip() == '15'
    assert ability_scores_table.charisma.text.strip() == '14'
def test_dexterity_increase(player_wizard, browser):  # noqa
    """When dexterity is increased or decreased, relevant skills, savings
       throws, initiative, and to hit (finesse weapons) reflect the change."""

    print(('When dexterity is increased or decreased, relevant skills, '
           'savings throws, initiative, and to hit (finesse weapons) reflect '
           'the change.'))

    saving_throw = SavingThrowTable(browser)
    skills = SkillsTable(browser)
    ability_scores_table = AbilityScoresTable(browser)
    ability_scores_edit = AbilityScoresEditModal(browser)
    weapon_table = WeaponTable(browser)
    weapon_add = WeaponAddModal(browser)
    stats = OtherStats(browser)
    tabs = Tabs(browser)

    ability_scores_table.table.click()
    # str needs to be less than dex as we are testing finesse weapon
    # i.e. the higher of str and dex is used
    ability_scores_edit.strength = 10
    ability_scores_edit.dexterity = 14
    ability_scores_edit.done.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        table_cell_updated(saving_throw, 'blank2', '+ 2', 'table', 3))

    dexterity = ut.get_table_row(saving_throw, 'table', row_number=3)
    initiative = stats.initiative.text

    tabs.skills.click()

    acrobatics = ut.get_table_row(skills, 'table', row_number=1)
    sleight_of_hand = ut.get_table_row(skills, 'table', row_number=16)
    stealth = ut.get_table_row(skills, 'table', row_number=17)

    tabs.equipment.click()

    weapon_table.add.click()
    # select a dagger
    ut.select_from_autocomplete(weapon_add,
                                'name',
                                browser,
                                has_search_term=False,
                                arrow_down_count=7)
    weapon_add.add.click()

    to_hit = ut.get_table_row(weapon_table, 'table').to_hit

    assert dexterity.blank2.strip() == '+ 2'
    assert initiative.strip() == '2'
    assert to_hit.strip() == '+ 4'
    assert acrobatics.blank2.strip() == '+ 2 (Dex)'
    assert sleight_of_hand.blank2.strip() == '+ 2 (Dex)'
    assert stealth.blank2.strip() == '+ 2 (Dex)'
def test_strength_increase(player_wizard, browser):  # noqa
    """When strength is increased or decreased, relevant skills, savings
       throws, to hit, and encumbrance reflect the change."""

    print(('When strength is increased or decreased, relevant skills, savings '
           'throws, to hit, and encumbrance reflect the change.'))

    saving_throw = SavingThrowTable(browser)
    skills = SkillsTable(browser)
    ability_scores_table = AbilityScoresTable(browser)
    ability_scores_edit = AbilityScoresEditModal(browser)
    hud = HUD(browser)
    weapon_table = WeaponTable(browser)
    weapon_add = WeaponAddModal(browser)
    tabs = Tabs(browser)

    ability_scores_table.table.click()
    ability_scores_edit.strength = 14
    ability_scores_edit.done.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        table_cell_updated(saving_throw, 'blank2', '+ 2', 'table', 5))

    strength = ut.get_table_row(saving_throw, 'table', row_number=5)

    tabs.skills.click()

    athletics = ut.get_table_row(skills, 'table', row_number=4)

    tabs.equipment.click()

    weapon_table.add.click()
    # select battleaxe
    ut.select_from_autocomplete(weapon_add,
                                'name',
                                browser,
                                has_search_term=False)
    weapon_add.add.click()

    to_hit = ut.get_table_row(weapon_table, 'table').to_hit

    status = hud.status_line.find_elements_by_tag_name('span')
    encumbrance_color = status[1].get_attribute('class')

    assert strength.blank2.strip() == '+ 2'
    assert to_hit.strip() == '+ 4'
    assert athletics.blank2.strip() == '+ 2 (Str)'
    assert 'text-info' in encumbrance_color
Beispiel #6
0
def test_data_persists(player_wizard, browser):  # noqa
    """As a player, all changes I make to hit points, hit dice, ability scores,
       savings throws, and other stats persist after I refresh the browser."""

    print(('As a player, all changes I make to hit points, hit dice, ability '
           'scores, savings throws, and other stats persist after I refresh '
           ' the browser.'))

    time.sleep(8)

    ability_scores_edit = AbilityScoresEditModal(browser)
    ability_scores_table = AbilityScoresTable(browser)
    hp_hd = HitPointHitDice(browser)
    other_stats = OtherStats(browser)
    saving_throw = SavingThrowTable(browser)
    saving_throw_edit = SavingThrowEditModal(browser)

    ability_scores_table.table.click()

    ability_scores_edit.strength = 15
    ability_scores_edit.strength.send_keys(Keys.TAB)
    ability_scores_edit.done.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    hp_hd.damage_up.click()

    hp_hd.hitdice1.click()

    row = ut.get_table_row(saving_throw, 'table', values=False)
    # open edit modal
    row[0].click()

    saving_throw_edit.modifier = 1
    saving_throw_edit.proficiency.click()
    saving_throw_edit.done.click()

    time.sleep(3)

    other_stats.edit_btn.click()

    other_stats.ac_modifier_input = 1
    other_stats.ac_modifier_input.send_keys(Keys.TAB)

    other_stats.initiative_modifier_input = 1
    other_stats.initiative_modifier_input.send_keys(Keys.TAB)

    other_stats.proficiency_bonus_input = 1
    other_stats.proficiency_bonus_input.send_keys(Keys.TAB)

    other_stats.speed_input = 40
    other_stats.speed_input.send_keys(Keys.TAB)

    other_stats.level_input = 3
    other_stats.level_input.send_keys(Keys.TAB)

    other_stats.experience_input = 2000
    time.sleep(1)
    other_stats.experience_input.send_keys(Keys.TAB)

    other_stats.inspiration_input.click()

    other_stats.save_btn.click()

    time.sleep(2)

    browser.refresh()

    time.sleep(10)

    row = ut.get_table_row(saving_throw, 'table', values=False)
    proficiency = row[0].find_elements(By.TAG_NAME, 'span')

    assert ability_scores_table.strength.text.strip() == '15'
    assert hp_hd.hit_points_bar_label.text.strip() == 'HP: 9'
    assert hp_hd.hitdice3.get_attribute('class').strip() == 'dice-empty'
    assert proficiency[0].get_attribute('class').strip() == 'fa fa-check'
    assert other_stats.initiative_label.text.strip() == '5'
    assert other_stats.proficiency_bonus_label.text.strip() == '3'
    assert other_stats.speed_label.text.strip() == '40'
    assert other_stats.level_label.text.strip() == '3'
    assert other_stats.experience_label.text.strip() == '2000'