concept TestScript { S scriptName, comments; bool active; S botLinePattern1, userLine1; S botLinePattern2, userLine2; S botLinePattern3, userLine3; S botLinePattern4, userLine4; S botLinePattern5, userLine5; int highestIndex() { ret 5; } S botLinePattern(int i) { ret trim(getString(this, "botLinePattern" + i)); } S userLine(int i) { ret trim(getString(this, "userLine" + i)); } } sclass TestScripting { sO html(S uri, SS params, AuthedDialogID auth) null { S uri2 = appendSlash(uri); bool requestAuthed = auth != null; if (startsWith(uri2, "/testscripts/")) { if (!requestAuthed) ret serveAuthForm(params.get('uri)); ret serveTestScriptingAdmin(uri, params); } } sS serveTestScriptingAdmin(S uri, SS params) { S nav = p(ahref(rawBotLink(dbBotID), "Main admin") + " | " + ahref(baseLink + "/testscripts", "Test scripts admin")); HCRUD_Concepts data = new HCRUD_Concepts<>(TestScript); HCRUD crud = new(rawLink("testscripts"), data) { S frame(S title, S contents) { ret hhtml(hhead_title_htmldecode(title) + hbody( hsansserif() + hcss_responstable() + nav + h1(title) + contents)); } }; crud.cmdsLeft = true; crud.tableClass = "responstable"; ret crud.renderPage(params); } void runTestScript(TestScript script) { temp WebBotTester tester = new(programID()); tester.params.put("testMode", "1"); tester.start(); int i = 0; for (int idx = 1; idx <= script.highestIndex(); idx++) { S pat = script.botLinePattern(idx); if (nempty(pat)) { tester.waitForMessages(i+1); WebChatBotMsg msg = get(tester.msgs, i); assertTrue("fromBot", !msg.fromUser); assertTrueVerbose(pat + "/" + msg.msgText, mmo2_match(pat, msg.msgText)); ++i; } S userLine = script.userLine(idx); if (nempty(userLine)) tester.sendMsg(userLine); } print("Script OK: " + script.scriptName); } }