Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions beam/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@
},
"phone": "(704) 885-0542",
"roles": ["Stock Manager", "Item Manager"],
# "department": "Operations",
"department": "Management - APC",
"designation": "Bakery Manager",
},
{
Expand All @@ -745,7 +745,7 @@
"phone": "(658) 583-5499",
"roles": ["Stock User", "BEAM Mobile User"],
"reports_to": "Tristan Hawkins",
# "department": "Operations",
"department": "Management - APC",
"designation": "Baker",
},
{
Expand All @@ -762,7 +762,7 @@
"phone": "(962) 762-5895",
"roles": ["Stock User", "BEAM Mobile User"],
"reports_to": "Tristan Hawkins",
# "department": "Operations",
"department": "Management - APC",
"designation": "Baker",
},
{
Expand All @@ -779,7 +779,7 @@
"phone": "(366) 357-8223",
"roles": ["Stock User", "BEAM Mobile User"],
"reports_to": "Tristan Hawkins",
# "department": "Operations",
"department": "Management - APC",
"designation": "Bakery Manager",
},
{
Expand All @@ -796,7 +796,7 @@
"phone": "(930) 920-4520",
"roles": ["Stock User", "BEAM Mobile User"],
"reports_to": "Tristan Hawkins",
# "department": "Operations",
"department": "Management - APC",
"designation": "Baker",
},
{
Expand All @@ -813,7 +813,7 @@
"phone": "(054) 893-8970",
"roles": ["Stock User", "BEAM Mobile User"],
"reports_to": "Tristan Hawkins",
# "department": "Operations",
"department": "Management - APC",
"designation": "Baker",
},
{
Expand All @@ -830,7 +830,7 @@
"phone": "(814) 677-9322",
"roles": ["Stock User", "BEAM Mobile User"],
"reports_to": "Tristan Hawkins",
# "department": "Operations",
"department": "Management - APC",
"designation": "Baker",
},
{
Expand All @@ -847,7 +847,7 @@
"phone": "(133) 195-7828",
"roles": ["Stock User", "BEAM Mobile User"],
"reports_to": "Tristan Hawkins",
# "department": "Operations",
"department": "Management - APC",
"designation": "Baker",
},
{
Expand All @@ -864,7 +864,24 @@
"phone": "(041) 000-2569",
"roles": ["Stock User", "BEAM Mobile User"],
"reports_to": "Tristan Hawkins",
# "department": "Operations",
"department": "Management - APC",
"designation": "Baker",
},
{
"name": "Marcus Reynolds",
"gender": "Male",
"date_of_birth": "1990-05-15",
"date_of_joining": "2023-03-01",
"address": {
"address_line1": "456 Testing Lane",
"city": "Boston",
"state": "MA",
"postal_code": "02101",
},
"phone": "(555) 123-4567",
"roles": ["Stock User"], # NO BEAM Mobile User role - for restriction tests
"reports_to": "Tristan Hawkins",
"department": "Operations - APC",
"designation": "Warehouse Associate",
},
]
17 changes: 11 additions & 6 deletions beam/tests/mobile/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,24 @@ def browser_context_args(browser_context_args):


@pytest.fixture(autouse=True)
def setup(page):
def setup(page, request):
# delete all existing draft Purchase Receipts
delete_draft_records(["Purchase Receipt", "Stock Entry"])

page.set_default_timeout(5000)

base_url = frappe.utils.get_url()
page.goto(base_url)

# visiting the home page redirects to login page
page.get_by_role("textbox", name="Email").fill("support@agritheory.dev")
page.get_by_role("textbox", name="Password").fill("admin")
page.get_by_role("button", name="Login").click() # this will redirect to `/beam`
# Skip auto-login for scan-to-login tests (they need to start from login page)
is_login_test = "scan_to_login" in request.node.name

if not is_login_test:
page.goto(base_url)
# visiting the home page redirects to login page
page.get_by_role("textbox", name="Email").fill("support@agritheory.dev")
page.get_by_role("textbox", name="Password").fill("admin")
page.get_by_role("button", name="Login").click() # this will redirect to `/beam`

yield

# delete all Purchase Receipts created during the test
Expand Down
3 changes: 3 additions & 0 deletions beam/tests/mobile/test_manufacture.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ def test_complete_partial_stock_entry(page):

# navigate in the following order: Home -> Manufacture -> Work Order
page.get_by_text("Manufacture").click()

expect(page.locator("css=.beam_list-item").first).to_be_visible()
page.locator("css=.beam_list-item").first.click()

# get the selected Work Order
order_id = page.url.split("/")[-1]
assert order_id

expect(page.locator("css=.box .beam_list-item").first).to_be_visible()
# ensure there are no existing Stock Entries against this Work Order
entry = frappe.db.exists(
"Stock Entry",
Expand Down
6 changes: 5 additions & 1 deletion beam/tests/mobile/test_mobile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
# `page.expect_navigation()` since the latter won't work with Beam's hash-based routes


@pytest.mark.order(6)
@pytest.mark.order(1)
@pytest.mark.parametrize("route", ["Ship"])
def test_scan_item_barcode(page, route):
# navigate in the following order: Home -> List -> Form
page.get_by_text(route).click()
# wait for list to load
expect(page.locator("css=.beam_list-item").first).to_be_visible()
page.locator("css=.beam_list-item").first.click()

# wait for items to load after navigation
expect(page.locator("css=.box .beam_list-item").first).to_be_visible()
# find the first item in the list
item = page.locator("css=.box .beam_list-item").first
item_name, *others = item.inner_text().split("\n")
Expand Down
23 changes: 19 additions & 4 deletions beam/tests/mobile/test_receive.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
# `page.expect_navigation()` won't work with Beam's hash-based routes


@pytest.mark.order(2)
@pytest.mark.order(1)
def test_scan_invalid_barcode(page):
page.get_by_text("Receive").click()
# wait for list to load
expect(page.locator("css=.beam_list-item").first).to_be_visible()
page.locator("css=.beam_list-item").first.click()

# get the selected Purchase Order
Expand All @@ -30,6 +32,8 @@ def test_scan_invalid_barcode(page):
order_id = path_parts[-1] if path_parts else None
assert order_id

# wait for items to load after navigation
expect(page.locator("css=.box .beam_item-count").first).to_be_visible()
# find all items in the list
all_item_counts = page.locator("css=.box .beam_item-count")

Expand Down Expand Up @@ -78,11 +82,13 @@ def test_scan_invalid_barcode(page):
), f"Invalid barcode scan should not create any Purchase Receipts, but found: {new_receipts}"


@pytest.mark.order(3)
@pytest.mark.order(2)
def test_receive_without_scanning(page):
"""Test trying to receive without scanning any items"""
# navigate to a Purchase Order
page.get_by_text("Receive").click()
# wait for list to load
expect(page.locator("css=.beam_list-item").first).to_be_visible()
page.locator("css=.beam_list-item").first.click()

# get the selected Purchase Order
Expand All @@ -91,6 +97,8 @@ def test_receive_without_scanning(page):
order_id = path_parts[-1] if path_parts else None
assert order_id

# wait for items to load after navigation
expect(page.locator("css=.box .beam_list-item").first).to_be_visible()
item = page.locator("css=.box .beam_list-item").first
item_code, *others = item.inner_text().split("\n")

Expand Down Expand Up @@ -132,10 +140,12 @@ def test_receive_without_scanning(page):
), f"Expected no new receipts, but count changed from {initial_count} to {final_count}"


@pytest.mark.order(4)
@pytest.mark.order(3)
def test_complete_partial_receipt(page):
# navigate in the following order: Home -> Receive -> Purchase Order
page.get_by_text("Receive").click()

expect(page.locator("css=.beam_list-item").first).to_be_visible()
page.locator("css=.beam_list-item").first.click()

# get the selected Purchase Order
Expand All @@ -148,6 +158,7 @@ def test_complete_partial_receipt(page):

assert order_id

expect(page.locator("css=.box .beam_list-item").first).to_be_visible()
# find the first item in the list
item = page.locator("css=.box .beam_list-item").first
item_code, *others = item.inner_text().split("\n")
Expand Down Expand Up @@ -213,11 +224,13 @@ def test_complete_partial_receipt(page):
assert receipts[0]["received_qty"] == 1


@pytest.mark.order(5)
@pytest.mark.order(4)
def test_rapid_barcode_scanning(page):
"""Test scanning multiple barcodes quickly"""
# navigate to a Purchase Order
page.get_by_text("Receive").click()
# wait for list to load
expect(page.locator("css=.beam_list-item").first).to_be_visible()
page.locator("css=.beam_list-item").first.click()

# get the selected Purchase Order
Expand All @@ -226,6 +239,8 @@ def test_rapid_barcode_scanning(page):
order_id = path_parts[-1] if path_parts else None
assert order_id

# wait for items to load after navigation
expect(page.locator("css=.box .beam_list-item").first).to_be_visible()
# find the first item in the list
item = page.locator("css=.box .beam_list-item").first
item_code, *others = item.inner_text().split("\n")
Expand Down
10 changes: 5 additions & 5 deletions beam/tests/mobile/test_repack.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def disable_handling_unit_for_tests():
frappe.db.commit()


@pytest.mark.order(8)
@pytest.mark.order(1)
def test_repack_items_manually(page):
page.get_by_text("Repack").click()
expect(page).to_have_url(re.compile(r"#/repack"), timeout=15000)
Expand Down Expand Up @@ -124,7 +124,7 @@ def test_repack_items_manually(page):
assert submitted, f"Expected Stock Entry {stock_entry_name} to be submitted"


@pytest.mark.order(9)
@pytest.mark.order(2)
def test_repack_using_bom(page):
page.get_by_text("Repack").click()
page.wait_for_load_state("networkidle")
Expand Down Expand Up @@ -174,7 +174,7 @@ def test_repack_using_bom(page):
assert entries, "Expected a draft Stock Entry to be created from BOM repack"


@pytest.mark.order(10)
@pytest.mark.order(3)
def test_scan_item_for_repack(page):
page.get_by_text("Repack").click()
page.wait_for_load_state("networkidle")
Expand Down Expand Up @@ -214,7 +214,7 @@ def test_scan_item_for_repack(page):
expect(qty_input).to_have_value("2")


@pytest.mark.order(11)
@pytest.mark.order(4)
def test_clear_repack_form(page):
page.get_by_text("Repack").click()
page.wait_for_load_state("networkidle")
Expand Down Expand Up @@ -260,7 +260,7 @@ def test_clear_repack_form(page):
expect(page.get_by_role("button", name="CLEAN", exact=True)).to_be_hidden()


@pytest.mark.order(12)
@pytest.mark.order(5)
def test_repack_validation_single_warehouse_direction(page):
page.get_by_text("Repack").click()
page.wait_for_load_state("networkidle")
Expand Down
Loading
Loading