Merge current Engine changes before the post-match UI milestone (by Codex)
This commit is contained in:
commit
b843cbd636
7 files changed
+556
-2
No files matched your search
@@ -747,6 +747,14 @@ int main(int argc, char** argv) {
|
||||
const auto request = cli::Json::Object{{"kind", kind}, {"requestId", std::string("request:sim-") + kind}};
|
||||
std::printf("ui_read %s\n -> %s\n", kind, cli::dump_json(session.ui_read(request, revision)).c_str());
|
||||
}
|
||||
for (const auto& filter : {cli::Json::Object{{"section", 3}}, cli::Json::Object{{"section", 4}, {"country", 0}},
|
||||
cli::Json::Object{{"section", 4}, {"country", 2}}, cli::Json::Object{{"section", 6}},
|
||||
cli::Json::Object{{"section", 7}}, cli::Json::Object{{"section", 7}, {"category", 1}},
|
||||
cli::Json::Object{{"section", 8}}, cli::Json::Object{{"section", 1}}, cli::Json::Object{{"section", 2}}}) {
|
||||
std::string answer = cli::dump_json(session.read_statistics_screen(filter));
|
||||
if (answer.size() > 1500) answer = answer.substr(0, 1500) + " ...";
|
||||
std::printf("statistics screen %s\n -> %s\n", cli::dump_json(filter).c_str(), answer.c_str());
|
||||
}
|
||||
std::printf("ui_read wrong manager\n -> %s\n",
|
||||
cli::dump_json(session.ui_read(cli::Json::Object{{"kind", "desktop"}, {"managerId", "manager:99"}}, revision)).c_str());
|
||||
}
|
||||
|
||||
@@ -235,6 +235,31 @@ int main(int argc, char** argv) {
|
||||
check(s(at(refused, "messageType")) == "error" && modern::save_stream(session.state()) == kept && rev == before_bank + 2,
|
||||
"withdrawal above the deposit refused without change");
|
||||
}
|
||||
// contracts: demands as a quote, an offer against it, a stale quote refused
|
||||
{
|
||||
const J contracts = session.ui_read(O{{"kind", "contracts"}}, rev);
|
||||
const auto* players = at(at(contracts, "data"), "players").array();
|
||||
check(players && !players->empty(), "contracts read");
|
||||
const std::string player = players && !players->empty() ? s(at((*players)[0], "playerId")) : "";
|
||||
const uint64_t before = rev;
|
||||
const J quoted = session.ui_command(cmd("request:k1", "quote.request", O{{"kind", "contract"}, {"playerId", player}}), rev);
|
||||
check(s(at(quoted, "outcome")) == "offer_pending" && rev == before + 1, "demands quoted");
|
||||
const J with_quote = session.ui_read(O{{"kind", "contracts"}}, rev);
|
||||
const J& quote = at(at(with_quote, "data"), "quote");
|
||||
const auto* demands = at(quote, "demands").array();
|
||||
check(s(at(quote, "playerId")) == player && demands && demands->size() == 4, "quote with four terms");
|
||||
if (demands && demands->size() == 4) {
|
||||
const std::string id = s(at(quote, "id"));
|
||||
const J offer = session.ui_command(cmd("request:k2", "contract.offer",
|
||||
O{{"quoteId", id}, {"years", 2}, {"monthlySalary", O{{"minor", "100"}, {"currency", "EUR"}, {"minorUnits", 2}}}}), rev);
|
||||
const std::string outcome = s(at(offer, "outcome"));
|
||||
check(s(at(offer, "messageType")) == "command_result" && (outcome == "applied" || outcome == "offer_rejected") &&
|
||||
rev == before + 2, "offer answered");
|
||||
check(s(at(session.ui_command(cmd("request:k3", "contract.offer",
|
||||
O{{"quoteId", id}, {"years", 2}, {"monthlySalary", O{{"minor", "100"}, {"currency", "EUR"}, {"minorUnits", 2}}}}), rev),
|
||||
"code")) == "stale_quote" && rev == before + 2, "a used quote is gone");
|
||||
}
|
||||
}
|
||||
// session.advance: three kickoffs, each one revision, the date moves on
|
||||
{
|
||||
const std::string date_before = s(at(at(session.ui_read(O{{"kind", "desktop"}}, rev), "meta"), "date"));
|
||||
@@ -269,6 +294,16 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
check(s(at(session.read_almanac(O{{"kind", "match"}, {"id", "match:0-0"}}), "error")) == "almanac_match_not_found",
|
||||
"unknown match");
|
||||
// the statistics screen: real data (fictional false), unrecorded views say so
|
||||
const J minutes = session.read_statistics_screen(O{{"section", 8}});
|
||||
check(truth(at(minutes, "ok")) && !truth(at(minutes, "fictional")) && at(minutes, "rows").array() &&
|
||||
at(minutes, "rows").array()->size() == 4, "minute statistics");
|
||||
const J transfers = session.read_statistics_screen(O{{"section", 1}});
|
||||
check(truth(at(transfers, "ok")) && !truth(at(transfers, "available")) && s(at(transfers, "reason")) == "not_recorded",
|
||||
"transfer history not recorded");
|
||||
check(s(at(session.read_statistics_screen(O{{"section", 9}}), "error")) == "invalid_statistics_filter", "bad section");
|
||||
const J curves = session.read_statistics_screen(O{{"section", 2}});
|
||||
check(at(curves, "series").array() && at(curves, "series").array()->size() == 6, "the six curves of the original");
|
||||
}
|
||||
} catch (const std::exception& ex) {
|
||||
std::fprintf(stderr, "FAIL: %s\n", ex.what());
|
||||
|
||||
Reference in new issue
Block a user