Cloudflare Pages / Build and verify the site (push) Successful in 3m29s
Use the verified dependency lock across native hosts and bundled apps. Preserve saved styles, local app reactivation, and offline packages while integrating the latest practice, Habits, Lumi, and figure preview updates.
635 lines
32 KiB
Ziran
635 lines
32 KiB
Ziran
// Real account storage and feedback pump; only the HTTP transport is synthetic.
|
|
#import, file "../src/apps/lumi_online.zi";
|
|
#import, file "../src/apps/lumi_connection.zi";
|
|
#import, file "../src/apps/feedback_store.zi";
|
|
#import, file "../src/apps/lumi_types.zi";
|
|
#import, file "../src/apps/lumi_store.zi";
|
|
#import, file "../src/apps/package_files.zi";
|
|
#import, file "../src/app/app_types.zi";
|
|
#import, file "../src/app/text_buffers.zi";
|
|
#import, file "../src/storage/account_types.zi";
|
|
#import, file "../src/storage/db.zi";
|
|
#import, file "../src/storage/state.zi";
|
|
#import, file "../src/storage/storage_settings.zi";
|
|
#import, file "../src/storage/bundled_app_records.zi";
|
|
#import, file "../src/storage/sync_async.zi";
|
|
#import, file "../src/apps/app_tools.zi";
|
|
#import, file "../src/storage/storage_elist.zi";
|
|
#import "keys"
|
|
#import "mesh_client/crypto"
|
|
#import, file "../src/storage/sync_account.zi";
|
|
#import, file "storage_test_support.zi";
|
|
#import "async_client"
|
|
#import "net_http"
|
|
#import "text_buffer"
|
|
#import "json_scan"
|
|
#import "wire"
|
|
#import "transaction"
|
|
#import "vec"
|
|
#import "text"
|
|
#import "byte_text_linux"
|
|
|
|
c :: #system_library "c";
|
|
TestNow :: (out: *s64) -> s64 #foreign c "time";
|
|
|
|
owner: AccountKeys;
|
|
feedback_status: s32 = 503;
|
|
feedback_response: string = "{\"error\":\"feedback unavailable\"}";
|
|
submissions: s32;
|
|
start_fails: bool;
|
|
switch_in_poll: bool;
|
|
switch_report: string;
|
|
|
|
FakeStart :: (context: *void, request: HttpRequest, output: []u8) -> bool {
|
|
unused context
|
|
challenge_url := "https://api.waozi.xyz/api/v1/sync/challenge?user_id="
|
|
if request.url.count == challenge_url.count + 64 && request.url[:challenge_url.count] == challenge_url {
|
|
return AppCopyText("{\"nonce\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}", output)
|
|
}
|
|
if request.url == "https://api.waozi.xyz/api/v1/sync/login" {
|
|
writer: Writer = .{output, 0, true}
|
|
writer = WriteText(writer, "{\"auth_token\":\"synthetic-feedback-token\",\"expires_in_seconds\":3600,\"server_time\":")
|
|
writer = WriteDecimal(writer, TestNow(null))
|
|
writer = WriteByte(writer, cast(u8)125)
|
|
return writer.valid
|
|
}
|
|
if request.url == "https://api.waozi.xyz/api/v1/account/devices" {
|
|
return AppCopyText("true", output)
|
|
}
|
|
check_true("only approved feedback reaches HTTP", request.method == "POST" &&
|
|
request.url == "https://api.waozi.xyz/api/v1/feedback")
|
|
submissions += 1
|
|
if start_fails {
|
|
return false
|
|
}
|
|
return AppCopyText(feedback_response, output)
|
|
}
|
|
|
|
FakePoll :: (context: *void, status: *s32) -> s32 {
|
|
unused context
|
|
status.* = ifx lumi_online_operation.request.stage == 3 then feedback_status else 200
|
|
if switch_in_poll && lumi_online_operation.request.stage == 3 {
|
|
switch_in_poll = false
|
|
unused AppCopyText("different-account", g_storage.user_id[:])
|
|
check_true("other account queues its own report", FeedbackEnqueueID(
|
|
"Other account", "A different account's feedback", "", switch_report))
|
|
}
|
|
return 1
|
|
}
|
|
|
|
FakeCancel :: (context: *void) {
|
|
unused context
|
|
}
|
|
|
|
#program_export
|
|
FeedbackTestTransport :: () -> AsyncTransport {
|
|
return AsyncTransport.{null, FakeStart, FakePoll, FakeCancel}
|
|
}
|
|
|
|
Attempt :: (app: *InnerBreeze) {
|
|
lumi_feedback_retry = 0
|
|
lumi_reply_retry = TestNow(null) + 3600
|
|
app_lumi_pump(app)
|
|
for step: cast(s32)0..19 {
|
|
if !lumi_online_operation.active {
|
|
break
|
|
}
|
|
app_lumi_pump(app)
|
|
}
|
|
check_true("feedback attempt completes", !lumi_online_operation.active)
|
|
}
|
|
|
|
Pending :: () -> bool {
|
|
value := FeedbackFirst()
|
|
defer { PackageFree(value) }
|
|
return value.count != 0
|
|
}
|
|
|
|
LegacyReport :: (out: *Vec(u8), id: string, title: string, message: string, context: string) {
|
|
BuilderPrint(out, "{\"id\":")
|
|
LumiJsonString(out, id)
|
|
BuilderPrint(out, ",\"app_id\":\"inbe\",\"title\":")
|
|
LumiJsonString(out, title)
|
|
BuilderPrint(out, ",\"message\":")
|
|
LumiJsonString(out, message)
|
|
BuilderPrint(out, ",\"context\":")
|
|
LumiJsonString(out, context)
|
|
BuilderPrint(out, "}")
|
|
}
|
|
|
|
LegacyOutboxChecks :: (root: string, delivered_id: string) {
|
|
first_id := "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
|
|
second_id := "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
|
|
foreign_id := "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
|
|
message_out: Vec(u8)
|
|
for index: cast(s32)0..4095 {
|
|
BuilderPrint(*message_out, "m")
|
|
}
|
|
message := BuilderFinish(message_out)
|
|
defer { PackageFree(message) }
|
|
context_out: Vec(u8)
|
|
for index: cast(s32)0..2047 {
|
|
BuilderPrint(*context_out, "c")
|
|
}
|
|
context := BuilderFinish(context_out)
|
|
defer { PackageFree(context) }
|
|
out: Vec(u8)
|
|
BuilderPrint(*out, "[")
|
|
LegacyReport(*out, delivered_id, "Already received", "Do not send twice", "")
|
|
BuilderPrint(*out, ",")
|
|
LegacyReport(*out, first_id, "Earlier queued report", message, context)
|
|
BuilderPrint(*out, ",")
|
|
LegacyReport(*out, second_id, "Another queued report", message, context)
|
|
BuilderPrint(*out, "]")
|
|
legacy := BuilderFinish(out)
|
|
defer { PackageFree(legacy) }
|
|
check_true("older outbox exceeds the general getter buffer", legacy.count > 8192)
|
|
storage_set_setting_text("lumi_feedback_pending", legacy)
|
|
check_true("older database fixture saves the complete outbox",
|
|
storage_setting_text_equals("lumi_feedback_pending", legacy) != 0)
|
|
LumiStoreReset()
|
|
storage_close()
|
|
check_true("older database reopens", storage_init(root) != 0)
|
|
check_true("older queued feedback is recovered", Pending())
|
|
check_true("legacy outbox clears only after preserving all rows",
|
|
storage_setting_text_equals("lumi_feedback_pending", "[]") != 0)
|
|
first_key := PackageText("cell.feedback.pending.", first_id)
|
|
second_key := PackageText("cell.feedback.pending.", second_id)
|
|
delivered_key := PackageText("cell.feedback.pending.", delivered_id)
|
|
defer { PackageFree(first_key); PackageFree(second_key); PackageFree(delivered_key) }
|
|
first := BundledAppRecordRead(first_key)
|
|
second := BundledAppRecordRead(second_key)
|
|
delivered := BundledAppRecordRead(delivered_key)
|
|
defer { PackageFree(first); PackageFree(second); PackageFree(delivered) }
|
|
check_true("large reports retain their IDs, message and context",
|
|
contains(first, first_id) && contains(first, message) && contains(first, context) &&
|
|
contains(second, second_id) && contains(second, message) && contains(second, context))
|
|
check_true("upgrade never resurrects received feedback", delivered == "{\"delivered\":true}")
|
|
check_true("recovered report can be marked received", FeedbackDelivered(first_id))
|
|
storage_set_setting_text("lumi_feedback_pending", legacy)
|
|
check_true("replayed legacy data keeps the remaining pending report", Pending())
|
|
tombstone := BundledAppRecordRead(first_key)
|
|
defer { PackageFree(tombstone) }
|
|
check_true("retry and replay preserve delivery tombstones", tombstone == "{\"delivered\":true}")
|
|
check_true("remaining recovered report can complete", FeedbackDelivered(second_id))
|
|
|
|
saved_owner: [64]u8
|
|
unused AppCopyText(AppTextFromCString(storage_user_id_buffer(), 64), saved_owner[:])
|
|
unused AppCopyText("legacy-other-account", g_storage.user_id[:])
|
|
foreign_out: Vec(u8)
|
|
BuilderPrint(*foreign_out, "[")
|
|
LegacyReport(*foreign_out, foreign_id, "Other account's report", "Keep this account scoped", "")
|
|
BuilderPrint(*foreign_out, "]")
|
|
foreign := BuilderFinish(foreign_out)
|
|
defer { PackageFree(foreign) }
|
|
storage_set_setting_text("lumi_feedback_pending", foreign)
|
|
unused AppCopyText(TextUntilNul(saved_owner[:]), g_storage.user_id[:])
|
|
check_true("upgrade does not read another account's legacy queue", !Pending())
|
|
unused AppCopyText("legacy-other-account", g_storage.user_id[:])
|
|
check_true("other account recovers only its own older report", Pending())
|
|
check_true("other account's recovered report completes", FeedbackDelivered(foreign_id))
|
|
unused AppCopyText(TextUntilNul(saved_owner[:]), g_storage.user_id[:])
|
|
check_true("accounts remain isolated after upgrading", !Pending())
|
|
damaged := "[{\"id\":\"incomplete\"}]"
|
|
storage_set_setting_text("lumi_feedback_pending", damaged)
|
|
check_true("invalid older records are not queued", !Pending())
|
|
check_true("invalid older data is retained for recovery",
|
|
storage_setting_text_equals("lumi_feedback_pending", damaged) != 0)
|
|
}
|
|
|
|
// A developer's reply arrives as a reply from the developer, quoting the
|
|
// title of the feedback it answers, and keeps both through a restart.
|
|
DeveloperReplyChecks :: () {
|
|
first := LumiStoreCount()
|
|
replies := "{\"feedback\":[{\"id\":\"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\",\"app_id\":\"inbe\",\"title\":\"Lumi freezes\",\"message\":\"\",\"context\":\"\",\"reply\":\"Fixed in the next update.\\nThank you!\",\"created_at\":\"2026-10-18 20:00:00\"},{\"id\":\"9999999999999999999999999999999999999999999999999999999999999999\",\"app_id\":\"inbe\",\"title\":\"\",\"message\":\"\",\"context\":\"\",\"reply\":\"An older node sends no title.\",\"created_at\":\"2026-10-18 20:01:00\"}]}"
|
|
check_true("replies page fits the response buffer", AppCopyText(replies, lumi_online_response[:]))
|
|
LumiFeedbackReplies()
|
|
check_int("each developer reply adds one message", LumiStoreCount(), first + 2)
|
|
quoted := LumiStoreRow(first)
|
|
check_true("developer reply is attributed to the developer", quoted.developer && !quoted.user)
|
|
check_true("developer reply keeps its words verbatim", quoted.text == "Fixed in the next update.\nThank you!")
|
|
check_true("developer reply quotes the feedback's title", quoted.quote == "Lumi freezes")
|
|
untitled := LumiStoreRow(first + 1)
|
|
check_true("reply without a title shows no quote", untitled.developer && untitled.quote.count == 0 &&
|
|
untitled.text == "An older node sends no title.")
|
|
record := BundledAppRecordRead(lumi_keys[first])
|
|
defer { PackageFree(record) }
|
|
check_true("record names the developer and the quote for other devices",
|
|
contains(record, "\"from\":\"developer\"") && contains(record, "\"quote\":\"Lumi freezes\""))
|
|
LumiFeedbackReplies()
|
|
check_int("shown replies are not repeated", LumiStoreCount(), first + 2)
|
|
check_true("Lumi answers through the server", LumiAiRoute() == LUMI_AI_NODE)
|
|
check_true("a message starts a conversation", LumiOnlineStart("What did the developer say?"))
|
|
check_true("Lumi reads the reply as the developer's",
|
|
contains(lumi_online_messages, "Developer reply:\\nFixed in the next update."))
|
|
LumiOnlineCancel()
|
|
LumiStoreReset()
|
|
check_int("developer replies survive reopening", LumiStoreCount(), first + 2)
|
|
reloaded := LumiStoreRow(first)
|
|
check_true("reopened reply keeps its author and quote", reloaded.developer &&
|
|
reloaded.quote == "Lumi freezes" && reloaded.text == "Fixed in the next update.\nThank you!")
|
|
check_true("a reply is saved under a record named after it",
|
|
lumi_keys[first] == "cell.lumi.message.reply-ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
|
// Another device fetching the same reply finds it already saved.
|
|
storage_set_setting_text("lumi_feedback_replies_seen", "")
|
|
check_true("replies page fits the response buffer again", AppCopyText(replies, lumi_online_response[:]))
|
|
LumiFeedbackReplies()
|
|
check_int("a reply another device saved is not saved again", LumiStoreCount(), first + 2)
|
|
// Copies that older versions saved: one repeats the quoted reply, two
|
|
// are the same reply nobody saved the newer way.
|
|
check_true("older copy of a shown reply saved",
|
|
BundledAppRecordWrite("cell.lumi.message.legacy-copy-1", "{\"time\":4102444800000000,\"user\":0,\"kind\":0,\"text\":\"Developer reply:\\n\\nFixed in the next update.\\nThank you!\",\"payload\":\"\"}"))
|
|
check_true("older reply saved",
|
|
BundledAppRecordWrite("cell.lumi.message.legacy-copy-2", "{\"time\":4102444800000001,\"user\":0,\"kind\":0,\"text\":\"Antwort vom Entwickler:\\n\\nDanke!\",\"payload\":\"\"}"))
|
|
check_true("second device's copy of the older reply saved",
|
|
BundledAppRecordWrite("cell.lumi.message.legacy-copy-3", "{\"time\":4102444800000002,\"user\":0,\"kind\":0,\"text\":\"Antwort vom Entwickler:\\n\\nDanke!\",\"payload\":\"\"}"))
|
|
check_true("Lumi's own message with a heading saved",
|
|
BundledAppRecordWrite("cell.lumi.message.legacy-copy-4", "{\"time\":4102444800000003,\"user\":0,\"kind\":0,\"text\":\"Your plan:\\n\\nBreathe.\",\"payload\":\"\"}"))
|
|
LumiStoreReset()
|
|
check_int("each reply shows once and Lumi's message stays", LumiStoreCount(), first + 4)
|
|
older := LumiStoreRow(first + 2)
|
|
check_true("an older reply becomes the developer's, without its heading",
|
|
older.developer && older.text == "Danke!" && older.quote.count == 0)
|
|
own := LumiStoreRow(first + 3)
|
|
check_true("Lumi's message with a heading stays Lumi's", !own.developer && own.text == "Your plan:\n\nBreathe.")
|
|
duplicate := BundledAppRecordRead("cell.lumi.message.legacy-copy-1")
|
|
defer { PackageFree(duplicate) }
|
|
check_true("a repeated copy is deleted for the other devices", contains(duplicate, "\"deleted\":true"))
|
|
}
|
|
|
|
ListReportChecks :: (app: *InnerBreeze) {
|
|
app.enabled_apps = 31
|
|
storage_set_setting_int("elist_initialized", 1)
|
|
unrelated: [37]u8
|
|
list_id: [37]u8
|
|
check_true("other list created", storage_elist_create_list("Scores", *unrelated[0]) != 0)
|
|
for number: cast(s32)0..9 {
|
|
check_true("unrelated items created", storage_elist_create_item(TextUntilNul(unrelated[:]),
|
|
"Leaderboard score is stale", "", null) != 0)
|
|
}
|
|
check_true("Apps list created", storage_elist_create_list("Apps", *list_id[0]) != 0)
|
|
originals: [6]string = .["Wurm dying after all apples changed level fix that",
|
|
"Bug in Textarea. When correcting it jumps back to the end",
|
|
"In arcade I have issues exciting profile. Profil Icon using shovey icon not correct",
|
|
"Increase word length in lists like why limit so hard I have long todos somtimes",
|
|
"In arcade I noticed it asking to backup password but I already did thst",
|
|
"Click t complete task is wrong moved in lists it's meant to be sweio to complete, swipe a bit is complete, swipe alot is edit"]
|
|
expansions: [6]string = .["Wurm: after all apples are collected and the level changes, the player dies. Please fix the level transition so collecting the last apple does not cause death.",
|
|
"Text editing: correcting text in the middle moves the caret to the end. Please keep the caret at the correction so editing can continue there.",
|
|
"Arcade profile: the profile interaction has problems, and the profile icon incorrectly uses the Shovey icon. Please investigate the profile flow and show the correct Arcade profile icon.",
|
|
"Lists: the entry length limit prevents saving long todos. Please allow longer entries and preserve the complete text while editing and saving.",
|
|
"Arcade backup: the app asks for a password backup even though it has already been completed. Please retain the completed backup state and avoid repeated reminders.",
|
|
"Lists gestures: tapping an item should not complete it. A short swipe should complete or reopen it; a longer swipe should edit it. Please restore these distinct gestures."]
|
|
ids: [6][37]u8
|
|
for index: cast(s32)0..5 {
|
|
check_true("screenshot item saved", storage_elist_create_item(TextUntilNul(list_id[:]),
|
|
originals[index], "", *ids[index][0]) != 0)
|
|
}
|
|
LumiStoreAppend("The leaderboard score is wrong", false)
|
|
AppToolBeginTurn("Based on my lists apps can you send a full report t developer for ever point mentioned clear and expanded")
|
|
AppToolListScope(app)
|
|
check_true("context resolves named list beyond eight unrelated tasks",
|
|
TextUntilNul(feedback_list_id[:]) == TextUntilNul(list_id[:]))
|
|
args: Vec(u8)
|
|
BuilderPrint(*args, "{\"list_id\":")
|
|
LumiJsonString(*args, TextUntilNul(list_id[:]))
|
|
BuilderPrint(*args, "}")
|
|
read_args := BuilderFinish(args)
|
|
read := AppToolReadList(app, read_args)
|
|
defer { PackageFree(read_args); PackageFree(read) }
|
|
for original: originals {
|
|
check_true("read returns actual screenshot item", contains(read, original))
|
|
}
|
|
before := LumiStoreCount()
|
|
wrong := AppToolReportFeedback(app, "{\"title\":\"Scores\",\"message\":\"Please fix leaderboard scores\"}")
|
|
defer { PackageFree(wrong) }
|
|
check_true("stale unrelated report rejected", contains(wrong, "\"ok\":false") && LumiStoreCount() == before)
|
|
args = .{}
|
|
BuilderPrint(*args, "{\"title\":\"Apps feedback\",\"source_list_id\":")
|
|
LumiJsonString(*args, TextUntilNul(list_id[:]))
|
|
BuilderPrint(*args, ",\"points\":[")
|
|
for index: cast(s32)0..5 {
|
|
BuilderPrint(*args, "%{\"item_id\":", ifx index == 0 then "" else ",")
|
|
LumiJsonString(*args, TextUntilNul(ids[index][:]))
|
|
BuilderPrint(*args, ",\"message\":")
|
|
LumiJsonString(*args, expansions[index])
|
|
BuilderPrint(*args, "}")
|
|
}
|
|
BuilderPrint(*args, "]}")
|
|
report_args := BuilderFinish(args)
|
|
defer { PackageFree(report_args) }
|
|
result := AppToolReportFeedback(app, report_args)
|
|
defer { PackageFree(result) }
|
|
check_true("source-backed proposal saved", contains(result, "\"ok\":true"))
|
|
shown: Vec(u8)
|
|
cards: s32 = 0
|
|
id: string
|
|
for index: before..LumiStoreCount() - 1 {
|
|
row := LumiStoreRow(index)
|
|
if row.kind == LUMI_CHAT_FEEDBACK {
|
|
cards += 1
|
|
id = PackageText(row.payload, "")
|
|
check_int("confirmation follows full report", index, LumiStoreCount() - 1)
|
|
} else {
|
|
BuilderPrint(*shown, "%", row.text)
|
|
}
|
|
}
|
|
defer { PackageFree(id) }
|
|
preview := BuilderFinish(shown)
|
|
defer { PackageFree(preview) }
|
|
for index: cast(s32)0..5 {
|
|
check_true("preview preserves every original and expansion", contains(preview, originals[index]) &&
|
|
contains(preview, expansions[index]))
|
|
}
|
|
check_true("preview excludes unrelated leaderboard context", !contains(preview, "Leaderboard"))
|
|
check_int("one confirmation", cards, 1)
|
|
changed := FeedbackDraft("Changed retry", "Unrelated retry body", "", feedback_turn_id)
|
|
defer { PackageFree(changed) }
|
|
check_true("changed retry cannot replace previewed consent", changed.count == 0 && FeedbackChoice(id, 0))
|
|
snapshot := PackageText(feedback_list_snapshot, "")
|
|
defer { PackageFree(snapshot) }
|
|
PackageFree(feedback_list_snapshot)
|
|
feedback_list_snapshot = ""
|
|
unread := AppToolListReport(app, report_args)
|
|
defer { PackageFree(unread) }
|
|
check_true("source must be read in this turn before reporting", unread.count == 0)
|
|
feedback_list_snapshot = PackageText(snapshot, "")
|
|
check_true("source changed after read", storage_elist_update_item(TextUntilNul(ids[0][:]),
|
|
"Changed while the proposal was being prepared", "", 0, 0) != 0)
|
|
stale := AppToolListReport(app, report_args)
|
|
defer { PackageFree(stale) }
|
|
check_true("stale list expansion cannot replace preview", stale.count == 0 && FeedbackChoice(id, 0))
|
|
check_true("fixture restores source text", storage_elist_update_item(TextUntilNul(ids[0][:]),
|
|
originals[0], "", 0, 0) != 0)
|
|
app.enabled_apps &= ~cast(s32)1
|
|
hidden := AppToolReadList(app, read_args)
|
|
hidden_report := AppToolListReport(app, report_args)
|
|
defer { PackageFree(hidden); PackageFree(hidden_report) }
|
|
check_true("disabled Lists exposes no saved content", contains(hidden, "\"ok\":false") && hidden_report.count == 0)
|
|
app.enabled_apps |= cast(s32)1
|
|
after := LumiStoreCount()
|
|
retry := AppToolReportFeedback(app, report_args)
|
|
defer { PackageFree(retry) }
|
|
check_true("retry reuses exact proposal", retry == result && LumiStoreCount() == after)
|
|
LumiStoreReset()
|
|
reopened := AppToolReportFeedback(app, report_args)
|
|
defer { PackageFree(reopened) }
|
|
check_true("reopen keeps one proposal", LumiStoreCount() <= after && reopened == result)
|
|
check_true("no list report sent without consent", FeedbackChoice(id, 0) && !Pending())
|
|
check_true("cancel binds to that proposal", FeedbackChoice(id, 2) && !FeedbackChoice(id, 0))
|
|
resolved_count := LumiStoreCount()
|
|
canceled_retry := AppToolReportFeedback(app, report_args)
|
|
defer { PackageFree(canceled_retry) }
|
|
check_true("delayed list retry after Cancel cannot prompt again", contains(canceled_retry,
|
|
"confirmation already handled") && LumiStoreCount() == resolved_count && !Pending())
|
|
AppToolBeginTurn("")
|
|
}
|
|
|
|
ResolvedProposalChecks :: (app: *InnerBreeze) {
|
|
wording := "Please report this feedback to the developer"
|
|
arguments := "{\"title\":\"Text correction\",\"message\":\"Keep the caret at the correction\"}"
|
|
changed_arguments := "{\"title\":\"Changed retry\",\"message\":\"Unrelated leaderboard scores\"}"
|
|
for action: cast(s32)1..2 {
|
|
LumiStoreAppend(wording, true)
|
|
turn := PackageText(LumiStoreLatestUserKey(), "")
|
|
defer { PackageFree(turn) }
|
|
AppToolBeginTurn(wording, turn)
|
|
proposal := AppToolReportFeedback(app, arguments)
|
|
defer { PackageFree(proposal) }
|
|
card := LumiStoreRow(LumiStoreCount() - 1)
|
|
id := PackageText(card.payload, "")
|
|
defer { PackageFree(id) }
|
|
check_true("new turn proposes once", contains(proposal, "\"ok\":true") && FeedbackChoice(id, 0))
|
|
check_true("fixture resolves exact report", FeedbackChoice(id, action))
|
|
if action == 1 {
|
|
report_id := PackageText(id, id)
|
|
check_true("fixture clears approved synthetic report without HTTP", FeedbackDelivered(report_id))
|
|
PackageFree(report_id)
|
|
}
|
|
before := LumiStoreCount()
|
|
LumiStoreReset()
|
|
AppToolBeginTurn(wording, turn)
|
|
retry := AppToolReportFeedback(app, arguments)
|
|
changed := AppToolReportFeedback(app, changed_arguments)
|
|
defer { PackageFree(retry); PackageFree(changed) }
|
|
check_true("resolved turn never prompts again after reopen", contains(retry,
|
|
"confirmation already handled") && LumiStoreCount() == before)
|
|
check_true("changed report cannot replace resolved consent", contains(changed,
|
|
"\"ok\":false") && !FeedbackChoice(id, 0) && !FeedbackChoice(id, 1) && !Pending())
|
|
|
|
LumiStoreAppend(wording, true)
|
|
next_turn := PackageText(LumiStoreLatestUserKey(), "")
|
|
defer { PackageFree(next_turn) }
|
|
check_true("identical wording has a distinct durable turn", next_turn != turn)
|
|
AppToolBeginTurn(wording, next_turn)
|
|
fresh := AppToolReportFeedback(app, arguments)
|
|
defer { PackageFree(fresh) }
|
|
fresh_id := PackageText(LumiStoreRow(LumiStoreCount() - 1).payload, "")
|
|
defer { PackageFree(fresh_id) }
|
|
check_true("new identical user message may propose once", contains(fresh,
|
|
"\"ok\":true") && fresh_id != id && FeedbackChoice(fresh_id, 0))
|
|
after := LumiStoreCount()
|
|
AppToolBeginTurn(wording, turn)
|
|
late := AppToolReportFeedback(app, arguments)
|
|
defer { PackageFree(late) }
|
|
check_true("old-turn retry cannot reactivate after later proposal", contains(late,
|
|
"confirmation already handled") && LumiStoreCount() == after && FeedbackChoice(fresh_id, 0))
|
|
check_true("new proposal remains cancelable without sending", FeedbackChoice(fresh_id, 2) && !Pending())
|
|
}
|
|
AppToolBeginTurn("")
|
|
}
|
|
|
|
ProposalChecks :: () {
|
|
out: Vec(u8)
|
|
for index: cast(s32)0..3999 {
|
|
BuilderPrint(*out, "茶")
|
|
}
|
|
report := BuilderFinish(out)
|
|
defer { PackageFree(report) }
|
|
id := FeedbackDraft("Text correction", report, "view=lumi")
|
|
defer { PackageFree(id) }
|
|
before := LumiStoreCount()
|
|
prompt := "Send this feedback to the developer?"
|
|
check_true("long report has a reviewable proposal", LumiStoreFeedbackProposal(report, prompt, id))
|
|
restored: Vec(u8)
|
|
for index: before..LumiStoreCount() - 2 {
|
|
row := LumiStoreRow(index)
|
|
check_true("long report parts remain plain messages", row.kind == LUMI_CHAT_TEXT)
|
|
BuilderPrint(*restored, "%", row.text)
|
|
}
|
|
text := BuilderFinish(restored)
|
|
defer { PackageFree(text) }
|
|
check_true("proposal preserves the entire UTF-8 report", text == report)
|
|
card := LumiStoreRow(LumiStoreCount() - 1)
|
|
check_true("long report retains its actionable card", card.kind == LUMI_CHAT_FEEDBACK &&
|
|
card.text == prompt && card.payload == id && FeedbackChoice(id, 0))
|
|
check_true("review never queues a report", !Pending())
|
|
check_true("long preview only queues after consent", FeedbackChoice(id, 1))
|
|
queued := FeedbackFirst()
|
|
decoded := ReadStringValue(queued, FieldAt(queued, 0, "message"), FeedbackMessageMax)
|
|
delivered_text := BuilderFinish(decoded.value)
|
|
defer { PackageFree(queued); PackageFree(delivered_text) }
|
|
check_true("full queued message equals preview without truncation", decoded.valid && delivered_text == report)
|
|
report_id := PackageText(id, id)
|
|
defer { PackageFree(report_id) }
|
|
check_true("fixture clears synthetic queued report without sending", FeedbackDelivered(report_id))
|
|
}
|
|
|
|
OlderProposalChecks :: () {
|
|
first := "11111111111111111111111111111111"
|
|
second := "22222222222222222222222222222222"
|
|
check_true("legacy draft one saved", BundledAppRecordWrite("cell.feedback.draft.11111111111111111111111111111111",
|
|
"{\"title\":\"Old one\",\"message\":\"Old one\",\"context\":\"\"}"))
|
|
check_true("legacy draft two saved", BundledAppRecordWrite("cell.feedback.draft.22222222222222222222222222222222",
|
|
"{\"title\":\"Old two\",\"message\":\"Old two\",\"context\":\"\"}"))
|
|
storage_set_setting_text("cell.feedback.active", "")
|
|
check_true("older cards retain only one actionable consent", !FeedbackChoice(first, 0) && FeedbackChoice(second, 0))
|
|
check_true("dismissing latest never reactivates older card", FeedbackChoice(second, 2) && !FeedbackChoice(first, 0))
|
|
check_true("old draft migration never sends", !Pending())
|
|
}
|
|
|
|
EscapedBoundaryChecks :: () {
|
|
title := "Escaped feedback"
|
|
empty := FeedbackPendingDocument(title, "", "",
|
|
"0000000000000000000000000000000000000000000000000000000000000000")
|
|
maximum := (65535 - empty.count) / 2
|
|
PackageFree(empty)
|
|
out: Vec(u8)
|
|
for index: cast(s64)0..maximum {
|
|
BuilderPrint(*out, "\"")
|
|
}
|
|
quotes := BuilderFinish(out)
|
|
defer { PackageFree(quotes) }
|
|
report := quotes[:maximum]
|
|
id := FeedbackDraft(title, report, "", "boundary")
|
|
defer { PackageFree(id) }
|
|
check_true("near-cell-limit escaped draft admitted before any queue write", id.count == 32 && !Pending())
|
|
oversized := FeedbackDraft(title, quotes, "", "boundary-overflow")
|
|
defer { PackageFree(oversized) }
|
|
check_true("encoded outbox overflow rejected before consent", oversized.count == 0 && FeedbackChoice(id, 0) && !Pending())
|
|
check_true("every admitted escaped draft can enqueue", FeedbackChoice(id, 1) && !FeedbackChoice(id, 0))
|
|
queued := FeedbackFirst()
|
|
decoded := ReadStringValue(queued, FieldAt(queued, 0, "message"), FeedbackMessageMax)
|
|
exact := BuilderFinish(decoded.value)
|
|
defer { PackageFree(queued); PackageFree(exact) }
|
|
check_true("near-cell-limit outbox preserves exact report", queued.count >= 65534 && queued.count < 65536 &&
|
|
decoded.valid && exact == report)
|
|
report_id := PackageText(id, id)
|
|
defer { PackageFree(report_id) }
|
|
check_true("boundary fixture clears approved report without HTTP", FeedbackDelivered(report_id))
|
|
}
|
|
|
|
// Use the same static storage lifetime as the app host for its large state.
|
|
feedback_app: InnerBreeze;
|
|
|
|
#program_export
|
|
Check :: () -> s32 {
|
|
transport := FeedbackTestTransport()
|
|
check_true("fixture transport available", transport.start != null)
|
|
guard := support_begin("/tmp/inbe-lumi-feedback-test/")
|
|
if guard != 0 {
|
|
return guard
|
|
}
|
|
english_catalog = "[lumi_feedback_delivered]\nThe developer inbox received your feedback.\n---\n[lumi_feedback_unavailable]\nDelivery to the developer inbox is not confirmed. Your feedback is saved on this device and will retry.\n---\n[lumi_developer_reply]\nDeveloper reply:\n---\n"
|
|
install_english_catalog()
|
|
root := "/tmp/inbe-lumi-feedback-test/data"
|
|
check_true("fixture database initialized", storage_init(root) != 0)
|
|
check_true("owner created", CreateAccountKeys(*owner) != 0)
|
|
check_true("owner saved", sync_account_save(*owner,
|
|
cast(SyncAccountLocalDataChoice)SyncAccountLocalDataChoice.SYNC_ACCOUNT_LOCAL_DATA_MERGE) ==
|
|
cast(SyncAccountSaveResult)SyncAccountSaveResult.SYNC_ACCOUNT_SAVE_OK)
|
|
// Lumi reaches the server only after the person agrees to its terms.
|
|
check_true("Lumi's online terms agreed", LumiAgree())
|
|
draft := FeedbackDraft("Lumi freezes", "Please fix Lumi freezing", "view=lumi")
|
|
defer { PackageFree(draft) }
|
|
app := *feedback_app
|
|
Attempt(app)
|
|
check_int("draft never submits before approval", submissions, 0)
|
|
check_true("draft is not in approved outbox", !Pending())
|
|
check_true("Yes queues report", FeedbackChoice(draft, 1))
|
|
check_true("duplicate Yes stays rejected", !FeedbackChoice(draft, 1))
|
|
report_id := PackageText(draft, draft)
|
|
defer { PackageFree(report_id) }
|
|
|
|
Attempt(app)
|
|
check_true("HTTP failure retains report", Pending())
|
|
check_true("HTTP failure is visible", LumiStoreCount() == 1 &&
|
|
contains(LumiStoreRow(0).text, "is not confirmed"))
|
|
Attempt(app)
|
|
check_int("repeat failure does not flood history", LumiStoreCount(), 1)
|
|
|
|
LumiOnlineCancel()
|
|
LumiStoreReset()
|
|
storage_close()
|
|
check_true("database reopens", storage_init(root) != 0)
|
|
check_true("approved report survives restart", Pending())
|
|
Attempt(app)
|
|
check_int("failure notice survives restart without duplication", LumiStoreCount(), 1)
|
|
|
|
feedback_status = 200
|
|
feedback_response = "true"
|
|
Attempt(app)
|
|
check_true("unrelated HTTP success never loses report", Pending())
|
|
feedback_response = "\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\""
|
|
Attempt(app)
|
|
check_true("another report's receipt never loses report", Pending())
|
|
receipt: Vec(u8)
|
|
LumiJsonString(*receipt, report_id)
|
|
correct := BuilderFinish(receipt)
|
|
defer { PackageFree(correct) }
|
|
feedback_response = PackageText(correct, "garbage")
|
|
Attempt(app)
|
|
check_true("trailing receipt data never loses report", Pending())
|
|
PackageFree(feedback_response)
|
|
feedback_response = correct
|
|
start_fails = true
|
|
Attempt(app)
|
|
check_true("transport start failure retains report", Pending())
|
|
check_int("transport errors do not flood history", LumiStoreCount(), 1)
|
|
start_fails = false
|
|
feedback_response = PackageText(correct, " \r\n\t")
|
|
Attempt(app)
|
|
check_true("matching receipt completes delivery", !Pending())
|
|
// The confirmation card is the whole exchange: delivery adds no message.
|
|
check_int("matching receipt adds no message", LumiStoreCount(), 1)
|
|
PackageFree(feedback_response)
|
|
Attempt(app)
|
|
check_int("completed delivery stays quiet", LumiStoreCount(), 1)
|
|
LumiOnlineCancel()
|
|
LumiStoreReset()
|
|
storage_close()
|
|
check_true("confirmed database reopens", storage_init(root) != 0)
|
|
check_true("completion survives restart", !Pending())
|
|
check_int("delivery history persists", LumiStoreCount(), 1)
|
|
switch_report = FeedbackEnqueue("Account switch", "Keep each account's report private", "")
|
|
defer { PackageFree(switch_report) }
|
|
receipt = .{}
|
|
LumiJsonString(*receipt, switch_report)
|
|
feedback_response = BuilderFinish(receipt)
|
|
defer { PackageFree(feedback_response) }
|
|
saved_owner: [64]u8
|
|
unused AppCopyText(AppTextFromCString(storage_user_id_buffer(), 64), saved_owner[:])
|
|
switch_in_poll = true
|
|
Attempt(app)
|
|
check_true("new account's pending report is preserved", Pending())
|
|
check_int("old account's notice never enters new history", LumiStoreCount(), 0)
|
|
unused AppCopyText(TextUntilNul(saved_owner[:]), g_storage.user_id[:])
|
|
check_true("original account's report is preserved", Pending())
|
|
check_int("canceled receipt adds no false notice", LumiStoreCount(), 1)
|
|
Attempt(app)
|
|
check_true("original account can still confirm its report", !Pending())
|
|
check_int("separate report adds no message", LumiStoreCount(), 1)
|
|
LumiOnlineCancel()
|
|
DeveloperReplyChecks()
|
|
LegacyOutboxChecks(root, report_id)
|
|
ListReportChecks(app)
|
|
ResolvedProposalChecks(app)
|
|
ProposalChecks()
|
|
EscapedBoundaryChecks()
|
|
OlderProposalChecks()
|
|
SecureWipe(*owner.private_key_hex[0], ACCOUNT_PRIVATE_KEY_HEX_SIZE)
|
|
storage_close()
|
|
remove_tree("/tmp/inbe-lumi-feedback-test/")
|
|
return failures
|
|
}
|