feat: unify backtest table controls and add refresh action
Deploy production / deploy (push) Successful in 53s

This commit is contained in:
yuxuanhui
2026-09-12 13:29:00 +08:00
parent ed349693db
commit 8206b36cd2
8 changed files with 453 additions and 142 deletions
+40
View File
@@ -0,0 +1,40 @@
"""List filtering and ordering happen before pagination, without platform execution."""
from tests.test_backtests import PREFIX, candidate, setup, start
async def test_list_sorting(app, logged_in):
await setup(app)
for name in ["sort-C", "sort-A", "sort-B", "unrelated"]:
body = {"name": name, "source": {"kind": "test"}, "candidates": [candidate()]}
assert (await logged_in.post(f"{PREFIX}/drafts", json=body)).status_code == 201
preview = await logged_in.post(f"{PREFIX}/previews", json={"inline": body})
assert preview.status_code == 201
await start(logged_in, preview.json(), key=name)
for path in ["runs", "drafts"]:
for direction, expected in [
("asc", ["sort-A", "sort-B", "sort-C"]),
("desc", ["sort-C", "sort-B", "sort-A"]),
]:
names = []
for offset in range(3):
r = await logged_in.get(
f"{PREFIX}/{path}",
params={
"q": "sort-",
"sort": "name",
"direction": direction,
"limit": 1,
"offset": offset,
},
)
assert r.status_code == 200
assert r.json()["total"] == 3
names.append(r.json()["items"][0]["name"])
assert names == expected
for params in [{"sort": "unknown"}, {"direction": "unknown"}]:
assert (await logged_in.get(f"{PREFIX}/{path}", params=params)).status_code == 422
assert (await logged_in.get(f"{PREFIX}/{path}", params={"q": "%"})).json()["total"] == 0
assert (await logged_in.get(f"{PREFIX}/runs", params={"q": "sort-", "source": "missing"})).json()[
"total"
] == 0