|
| 1 | +from appium.webdriver.webdriver import WebDriver |
| 2 | + |
| 3 | +from util.config import read_theme_config |
| 4 | +from util.button import get_undo_redo, is_enabled |
| 5 | +from util.color import get_color_value, set_color_value |
| 6 | +from util.message import ( |
| 7 | + BUTTON_SHOULD_BE_DISABLED, |
| 8 | + BUTTON_SHOULD_BE_ENABLED, |
| 9 | + CHANGE_NOT_SAVED, |
| 10 | + UI_NOT_UPDATED, |
| 11 | +) |
| 12 | +from util.window import find_element_by_id, open_theme_config |
| 13 | + |
| 14 | + |
| 15 | +LIGHT_SECTION = "LightMode" |
| 16 | +COLOR_ID = "HighlightColor" |
| 17 | + |
| 18 | + |
| 19 | +def test_highlight_color(driver: WebDriver, app: str): |
| 20 | + open_theme_config(driver) |
| 21 | + find_element_by_id(driver, LIGHT_SECTION).click() |
| 22 | + |
| 23 | + def read_config_value() -> str: |
| 24 | + cfg = read_theme_config(app) |
| 25 | + return cfg[LIGHT_SECTION][COLOR_ID].lstrip("#") |
| 26 | + |
| 27 | + field = find_element_by_id(driver, COLOR_ID) |
| 28 | + initial_value = get_color_value(field) |
| 29 | + new_value = "abcdef" |
| 30 | + undo, _ = get_undo_redo(driver) |
| 31 | + |
| 32 | + set_color_value(field, new_value) |
| 33 | + assert get_color_value(field) == new_value, UI_NOT_UPDATED |
| 34 | + assert is_enabled(undo) is True, BUTTON_SHOULD_BE_ENABLED |
| 35 | + assert read_config_value() == new_value, CHANGE_NOT_SAVED |
| 36 | + |
| 37 | + undo.click() |
| 38 | + assert get_color_value(field) == initial_value, UI_NOT_UPDATED |
| 39 | + assert is_enabled(undo) is False, BUTTON_SHOULD_BE_DISABLED |
| 40 | + assert read_config_value() == initial_value, CHANGE_NOT_SAVED |
0 commit comments