test_resizing.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import inspect
  2. from importlib import util
  3. import pandas
  4. import pytest
  5. if util.find_spec("playwright"):
  6. from playwright._impl._page import Page
  7. from taipy.gui import Gui
  8. @pytest.mark.extension
  9. def test_has_default_value(page: Page, gui: Gui, helpers):
  10. percentages = [
  11. (1852, 50.83),
  12. (1856, 45.29),
  13. (1860, 39.65),
  14. (1864, 55.03),
  15. (1868, 52.66),
  16. (1872, 55.58),
  17. (1876, 47.92),
  18. (1880, 48.31),
  19. (1884, 48.85),
  20. (1888, 47.80),
  21. (1892, 46.02),
  22. (1896.0, 51.02),
  23. (1900, 51.64),
  24. (1904, 56.42),
  25. (1908, 51.57),
  26. (1912, 41.84),
  27. (1916, 49.24),
  28. (1920, 60.32),
  29. (1924, 54.04),
  30. (1928, 58.21),
  31. (1932, 57.41),
  32. (1936, 60.80),
  33. (1940, 54.74),
  34. (1944, 53.39),
  35. (1948, 49.55),
  36. (1952, 55.18),
  37. (1956, 57.37),
  38. (1960, 49.72),
  39. (1964, 61.05),
  40. (1968, 43.42),
  41. (1972, 60.67),
  42. (1976, 50.08),
  43. (1980, 50.75),
  44. (1984, 58.77),
  45. (1988, 53.37),
  46. (1992, 43.01),
  47. (1996, 49.23),
  48. (2000, 47.87),
  49. (2004, 50.73),
  50. (2008, 52.93),
  51. (2012, 51.06),
  52. (2016, 46.09),
  53. (2020, 51.31),
  54. ]
  55. data = pandas.DataFrame(percentages, columns=["Year", "%"])
  56. page_md = """
  57. <|{data}|chart|type=bar|x=Year|y=%|>
  58. """
  59. gui._set_frame(inspect.currentframe())
  60. gui.add_page(name="test", page=page_md)
  61. helpers.run_e2e(gui) # Changed port number
  62. page.goto("./test")
  63. page.wait_for_timeout(3000)
  64. page.wait_for_selector(".plot-container")
  65. # Set the initial viewport size
  66. page.set_viewport_size({"width": 800, "height": 600})
  67. elements = page.locator(
  68. 'path[style*="vector-effect: non-scaling-stroke; opacity: 1; stroke-width: 0px; fill: rgb(99, 110, 250); fill-opacity: 1;"]')
  69. first_element = elements.first
  70. # Get the bounding box before resizing
  71. box_before = first_element.bounding_box()
  72. # Perform the resize operation
  73. page.set_viewport_size({"width": 1920, "height": 1080})
  74. # Wait for any potential re-rendering or layout changes
  75. page.wait_for_timeout(1000)
  76. # Get the bounding box after resizing
  77. box_after = first_element.bounding_box()
  78. # Compare the bounding boxes
  79. assert box_after['width'] > box_before['width']