mirror-kde-plasma-desktop/appiumtests/emojiertest.py
Tobias Ozór 5b8c6a28c6 emojier: Use consistent emoji order
Most emojis and their variants in the "People" category follow the order
"Person, Man, Woman". But for a few, the order is random.
Also, for the "Select Variant" pop-up feature, Emojier expects variants
with mixed skin tones to be placed near the base emoji or variants with
only one skin tone. Emoji Version 17 adds six emojis that do not follow
this ordering, breaking the feature.

Sort the emojis by this pattern.
2026-08-12 11:15:41 -04:00

79 lines
2.7 KiB
Python
Executable file

#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2023 Fushan Wen <qydwhotmail@gmail.com>
# SPDX-License-Identifier: MIT
import subprocess
import time
import unittest
from typing import Final
from appium import webdriver
from appium.options.common.base import AppiumOptions
from appium.webdriver.common.appiumby import AppiumBy
KDE_VERSION: Final = 6
class EmojierTest(unittest.TestCase):
"""
Tests for plasma-emojier
"""
driver: webdriver.Remote
@classmethod
def setUpClass(cls) -> None:
options = AppiumOptions()
options.set_capability("app", f"plasma-emojier")
options.set_capability("timeouts", {'implicit': 10000})
cls.driver = webdriver.Remote(command_executor='http://127.0.0.1:4723', options=options)
def tearDown(self) -> None:
"""
Take screenshot when the current test fails
"""
if not self._outcome.result.wasSuccessful():
self.driver.get_screenshot_as_file(f"failed_test_shot_emojier_#{self.id()}.png")
@classmethod
def tearDownClass(cls) -> None:
"""
Make sure to terminate the driver again, lest it dangles.
"""
subprocess.check_call([f"kquitapp{KDE_VERSION}", "plasma.emojier"])
cls.driver.quit()
def test_0_open(self) -> None:
"""
Tests the app does not crash on opening
Note that, since there are no recent emojis by default, the application
opens on the "All" page so this should check for elements that are
visible on that page.
@see https://bugs.kde.org/show_bug.cgi?id=478458
"""
self.driver.find_element(AppiumBy.NAME, "All")
self.driver.find_element(AppiumBy.NAME, "Search")
def test_1_open_category(self) -> None:
self.driver.find_element(AppiumBy.NAME, "All").click()
self.driver.find_element(AppiumBy.NAME, "grinning face").click()
time.sleep(1)
self.assertEqual(self.driver.get_clipboard_text(), "😀")
def test_2_recent_usage(self) -> None:
self.driver.find_element(AppiumBy.NAME, "Recent").click()
self.driver.find_element(AppiumBy.NAME, "grinning face")
def test_3_select_variant(self) -> None:
self.driver.find_element(AppiumBy.NAME, "All").click()
self.driver.find_element(AppiumBy.NAME, "Search").send_keys("handshake")
self.driver.find_element(AppiumBy.NAME, "Select Variant of \"handshake\"").click()
self.driver.find_element(AppiumBy.NAME, "handshake: light skin tone, medium skin tone").click()
time.sleep(1)
self.assertEqual(self.driver.get_clipboard_text(), "🫱🏻‍🫲🏽")
if __name__ == '__main__':
unittest.main()