Modern UI contract: stadium read and ticket.commit
The stadium read lists the periphery (the traffic access with its stage), the eight facilities with their level, the eight stand blocks and the ticket price, with the original names. ticket.commit sets the admission price. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4372e6b78a
commit
6386c891b5
4 files changed
+77
-2
No files matched your search
@@ -286,6 +286,25 @@ int main(int argc, char** argv) {
|
||||
"unknown_offer" && modern::save_stream(session.state()) == kept, "unknown offer refused");
|
||||
std::printf("(advertising offer %s)\n", offer.empty() ? "none" : offer.c_str());
|
||||
}
|
||||
// stadium: periphery, facilities, blocks; the ticket price
|
||||
{
|
||||
const J stadium = session.ui_read(O{{"kind", "stadium"}}, rev);
|
||||
const J& d = at(stadium, "data");
|
||||
if (s(at(stadium, "messageType")) != "snapshot") std::fprintf(stderr, "stadium: %s\n", cli::dump_json(stadium).c_str());
|
||||
check(at(d, "periphery").array() && at(d, "periphery").array()->size() == 14 && at(d, "blocks").array() &&
|
||||
at(d, "blocks").array()->size() == 8 && at(d, "facilities").array() && at(d, "facilities").array()->size() == 8,
|
||||
"stadium read");
|
||||
if (const auto* p = at(d, "periphery").array(); p && !p->empty())
|
||||
check(!s(at((*p)[0], "name")).empty() && at((*p)[0], "stage").integer(), "traffic access with its stage");
|
||||
const uint64_t before = rev;
|
||||
const J done = session.ui_command(cmd("request:e1", "ticket.commit", O{{"price", O{{"minor", "1200"}, {"currency", "EUR"}, {"minorUnits", 2}}}}), rev);
|
||||
if (s(at(done, "messageType")) != "command_result") std::fprintf(stderr, "ticket: %s\n", cli::dump_json(done).c_str());
|
||||
const J after = session.ui_read(O{{"kind", "stadium"}}, rev);
|
||||
check(s(at(done, "messageType")) == "command_result" && s(at(at(at(after, "data"), "ticketPrice"), "minor")) == "1200" &&
|
||||
rev <= before + 1, "ticket price set");
|
||||
check(s(at(session.ui_command(cmd("request:e2", "ticket.commit", O{{"price", O{{"minor", "3000"}, {"currency", "EUR"}, {"minorUnits", 2}}}}), rev),
|
||||
"code")) == "invalid_amount", "ticket price above 25 refused");
|
||||
}
|
||||
// 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"));
|
||||
|
||||
Reference in new issue
Block a user