Skip to content

Commit ab5a850

Browse files
Merge pull request #15 from jaseci-labs/e2e-test-cases-added
Adding E2E tests
2 parents e37e3eb + b5f4f25 commit ab5a850

2 files changed

Lines changed: 22 additions & 21 deletions

File tree

.github/workflows/e2e-tests.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,10 @@ name: JaSketch E2E Tests
33
on:
44
push:
55
branches: [main, dev]
6-
paths:
7-
- "jasketch/**"
86
pull_request:
97
branches: [main]
10-
paths:
11-
- "jasketch/**"
128
workflow_dispatch:
139

14-
defaults:
15-
run:
16-
working-directory: jasketch
17-
1810
jobs:
1911
e2e-tests:
2012
runs-on: ubuntu-latest
@@ -38,8 +30,7 @@ jobs:
3830
uses: oven-sh/setup-bun@v2
3931

4032
- name: Install Jac and dependencies
41-
run: |
42-
pip install jaclang jac-client jac-scale pytest pytest-playwright pytest-timeout
33+
run: pip install jaclang jac-client jac-scale pytest pytest-playwright pytest-timeout
4334

4435
- name: Install Playwright browsers
4536
run: python -m playwright install --with-deps chromium
@@ -55,5 +46,5 @@ jobs:
5546
uses: actions/upload-artifact@v4
5647
with:
5748
name: e2e-test-results
58-
path: jasketch/tests/e2e/
49+
path: tests/e2e/
5950
retention-days: 7

tests/e2e/test_jasketch.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,12 @@ class TestToolSelection:
174174
"""Verify tool switching works."""
175175

176176
def test_select_rectangle_tool(self, app: Page):
177+
"""Clicking Rectangle tool makes it the active tool."""
177178
select_tool(app, "Rectangle")
178179
btn = app.locator("button[title^='Rectangle']")
179180
expect(btn).to_be_visible()
181+
btn_class = btn.get_attribute("class")
182+
assert "text-orange-600" in btn_class, f"Rectangle should be active, class: {btn_class}"
180183

181184
def test_select_tool_via_keyboard(self, app: Page):
182185
"""Pressing number keys selects corresponding tools."""
@@ -455,14 +458,17 @@ def test_context_menu_appears(self, app: Page):
455458
press_key(app, "Escape")
456459

457460
def test_duplicate_from_menu(self, app: Page):
458-
"""Duplicating via Ctrl+D creates a copy."""
461+
"""Duplicating via Ctrl+D creates a copy with same type."""
459462
clear_canvas(app)
460463
draw_shape(app, "Rectangle", S_X1, S_Y1, S_X2, S_Y2)
461464
wait_for_elements(app, 1)
462465
select_tool(app, "Select")
463466
click_canvas(app, S_CX, S_CY)
464467
press_key(app, "Control+d")
465468
wait_for_elements(app, 2)
469+
elements = get_elements(app)
470+
assert elements[0]["type"] == "rectangle", "Original should be rectangle"
471+
assert elements[1]["type"] == "rectangle", "Duplicate should also be rectangle"
466472

467473

468474
# -- Zoom tests ----------------------------------------------------------------
@@ -472,13 +478,17 @@ class TestZoom:
472478
"""Verify zoom controls work."""
473479

474480
def test_zoom_in_button(self, app: Page):
475-
"""Clicking + zoom button increases zoom."""
481+
"""Clicking + zoom button increases zoom above 100%."""
476482
clear_canvas(app)
483+
press_key(app, "Control+0") # Reset to 100% first
477484
zoom_buttons = app.locator("button", has_text="+")
478485
zoom_buttons.last.click()
479486
app.wait_for_timeout(ACTION_DELAY)
480-
zoom_text = app.locator("text=100%")
481-
expect(zoom_text).not_to_be_visible()
487+
# Zoom should now be above 100% (e.g., 110%)
488+
zoom_btn = app.locator("button", has_text="%")
489+
zoom_label = zoom_btn.text_content()
490+
zoom_val = int(zoom_label.replace("%", ""))
491+
assert zoom_val > 100, f"Zoom should be above 100% after zoom in, got {zoom_val}%"
482492

483493
def test_zoom_reset(self, app: Page):
484494
"""Ctrl+0 resets zoom to 100%."""
@@ -730,12 +740,12 @@ def test_ungroup_elements(self, app: Page):
730740
canvas.click(position={"x": 450, "y": 115}, button="right", force=True)
731741
app.wait_for_timeout(ACTION_DELAY)
732742
ungroup_btn = app.locator("button", has_text="Ungroup")
733-
if ungroup_btn.is_visible():
734-
ungroup_btn.click()
735-
app.wait_for_timeout(1000)
736-
elements = get_elements(app)
737-
gid0 = elements[0].get("groupId")
738-
assert gid0 is None or gid0 == "", f"Element 0 groupId should be cleared, got {gid0}"
743+
expect(ungroup_btn).to_be_visible(timeout=3_000)
744+
ungroup_btn.click()
745+
app.wait_for_timeout(1000)
746+
elements = get_elements(app)
747+
gid0 = elements[0].get("groupId")
748+
assert gid0 is None or gid0 == "", f"Element 0 groupId should be cleared, got {gid0}"
739749

740750
def test_move_grouped_elements(self, app: Page):
741751
"""Moving one element in a group moves all group members."""

0 commit comments

Comments
 (0)