from datetime import datetime import pytest from playwright.sync_api import expect from helpers import app_url, login_as_admin, skip_without_admin_credentials def local_flight_row(page, registration): return page.locator("#local-flights-table-body tr").filter(has_text=registration) def confirm_timestamp(page, button_text): expect(page.locator("#timestampModal")).to_be_visible() expect(page.locator("#timestamp-submit-btn")).to_contain_text(button_text) page.locator("#timestamp-submit-btn").click() expect(page.locator("#timestampModal")).to_be_hidden() def test_operator_books_out_local_flight_records_touch_and_go_and_lands(page): skip_without_admin_credentials(pytest) registration = f"GE2E{datetime.utcnow().strftime('%H%M%S')}" page.goto(app_url("/admin")) login_as_admin(page) page.locator("#actionsDropdownBtn").click() page.locator("#actionsDropdownMenu").get_by_role("link", name="🛫 Book Out (L)").click() expect(page.locator("#localFlightModal")).to_be_visible() page.locator("#local_registration").fill(registration) page.locator("#local_type").fill("PA28") page.locator("#local_pob").fill("1") page.locator("#local_flight_type").select_option("LOCAL") page.locator("#local_duration").fill("45") page.locator("#local_notes").fill("E2E local flight lifecycle") page.locator("#local-flight-form").get_by_role("button", name="🛫 Book Out").click() expect(page.locator("#localFlightModal")).to_be_hidden() row = local_flight_row(page, registration) expect(row).to_be_visible() expect(row).to_contain_text("GROUND") row.get_by_role("button", name="TAKE OFF").click() confirm_timestamp(page, "Confirm Takeoff") expect(row).to_contain_text("LOCAL") row.get_by_role("button", name="T&G").click() expect(page.locator("#circuitModal")).to_be_visible() page.locator("#circuit-form").get_by_role("button", name="Record Circuit").click() expect(page.locator("#circuitModal")).to_be_hidden() expect(row.locator("td").nth(7)).to_have_text("1") row.get_by_role("button", name="LAND").click() confirm_timestamp(page, "Confirm Landing") expect(local_flight_row(page, registration)).to_have_count(0)