Add Create Test Shipment (Email SKU) for testing the return-label flow, plus test-mode/store_id investigation notes
Adds synthetic source="test" tickets (create_test_shipment_order/delete_test_shipments) carrying a company's real emailed-return-label SKU, so Step 1/Step 2 can be exercised against the sandbox without a real JIRA ticket or risking a real customer's. Gated to Test Mode - the same flow against production would create a real paid shipment. CLAUDE.md also captures this session's ShipStation sandbox findings: store_id is schema-optional but empirically required for label visibility, the newer ship15 web UI's URL is NOT the se- store ID (confirmed via direct probe - different failure shape than a wrong-but-well-formed ID), and two separate test stores/carriers are needed per company, mirroring production. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
@@ -27,6 +27,7 @@ from PyQt6.QtWidgets import (
|
||||
QTabWidget,
|
||||
QFileDialog,
|
||||
QDialog,
|
||||
QInputDialog,
|
||||
)
|
||||
|
||||
from app import config
|
||||
@@ -53,6 +54,8 @@ from app.workers import (
|
||||
save_dummy_outbound_label_id,
|
||||
save_pack_data,
|
||||
reset_local_database,
|
||||
create_test_shipment_order,
|
||||
delete_test_shipments,
|
||||
)
|
||||
|
||||
|
||||
@@ -184,6 +187,24 @@ class MainWindow(QMainWindow):
|
||||
create_test_warehouses_action.triggered.connect(self._on_create_test_warehouses_clicked)
|
||||
data_menu.addAction(create_test_warehouses_action)
|
||||
|
||||
data_menu.addSeparator()
|
||||
|
||||
create_test_shipment_action = QAction("Create Test Shipment (Email SKU)...", self)
|
||||
create_test_shipment_action.setStatusTip(
|
||||
"Test Mode only - creates a synthetic ticket carrying that company's emailed-"
|
||||
"return-label SKU, so Create Return Label can be run against it in the sandbox"
|
||||
)
|
||||
create_test_shipment_action.triggered.connect(self._on_create_test_shipment_clicked)
|
||||
data_menu.addAction(create_test_shipment_action)
|
||||
|
||||
delete_test_shipments_action = QAction("Delete Test Shipments...", self)
|
||||
delete_test_shipments_action.setStatusTip(
|
||||
"Removes every synthetic ticket created by Create Test Shipment - real JIRA "
|
||||
"tickets are not affected"
|
||||
)
|
||||
delete_test_shipments_action.triggered.connect(self._on_delete_test_shipments_clicked)
|
||||
data_menu.addAction(delete_test_shipments_action)
|
||||
|
||||
orders_menu = menu_bar.addMenu("&Orders")
|
||||
|
||||
self._pack_ticket_action = QAction("Pack Ticket", self)
|
||||
@@ -386,6 +407,63 @@ class MainWindow(QMainWindow):
|
||||
|
||||
QMessageBox.information(self, "Create Test Warehouse(s)", "\n".join(lines))
|
||||
|
||||
def _on_create_test_shipment_clicked(self) -> None:
|
||||
if not config.is_shipstation_test_mode():
|
||||
QMessageBox.information(
|
||||
self,
|
||||
"Test Mode is off",
|
||||
"Turn on ShipStation Test Mode first (Data menu). This ticket is meant "
|
||||
"to be run through Create Return Label against the sandbox account, not "
|
||||
"production - a real store_id/carrier under production settings would "
|
||||
"create an actual, paid shipment to a fake address.",
|
||||
)
|
||||
return
|
||||
|
||||
company, ok = QInputDialog.getItem(
|
||||
self,
|
||||
"Create Test Shipment",
|
||||
"Company (picks that company's configured emailed-return-label SKU):",
|
||||
["Signify Health", "Oak Street Health"],
|
||||
editable=False,
|
||||
)
|
||||
if not ok:
|
||||
return
|
||||
|
||||
try:
|
||||
order = create_test_shipment_order(company)
|
||||
except ValueError as exc:
|
||||
QMessageBox.critical(self, "Could not create test shipment", str(exc))
|
||||
return
|
||||
|
||||
self._refresh_everything()
|
||||
QMessageBox.information(
|
||||
self,
|
||||
"Test Shipment Created",
|
||||
f"Created {order.ticket_number} ({company}, SKU {order.skus[0]}) on the "
|
||||
"Active tab.\n\n"
|
||||
"Select it there and use Create Return Label to run Step 1 (dummy "
|
||||
"shipment) and Step 2 (return label) against the sandbox account, the "
|
||||
"same code path a real ticket would use.\n\n"
|
||||
"Use Delete Test Shipments (Data menu) to clean it up afterward.",
|
||||
)
|
||||
|
||||
def _on_delete_test_shipments_clicked(self) -> None:
|
||||
confirm = QMessageBox.question(
|
||||
self,
|
||||
"Delete Test Shipments",
|
||||
"Removes every synthetic ticket created by Create Test Shipment "
|
||||
"(ticket numbers starting with TEST-EMAIL-). Real JIRA tickets are not "
|
||||
"affected.\n\nContinue?",
|
||||
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
|
||||
QMessageBox.StandardButton.No,
|
||||
)
|
||||
if confirm != QMessageBox.StandardButton.Yes:
|
||||
return
|
||||
|
||||
count = delete_test_shipments()
|
||||
self._refresh_everything()
|
||||
QMessageBox.information(self, "Delete Test Shipments", f"Deleted {count} test shipment(s).")
|
||||
|
||||
def _on_order_double_clicked(self, order) -> None:
|
||||
dialog = OrderDetailDialog(order, self)
|
||||
dialog.exec()
|
||||
|
||||
Reference in New Issue
Block a user