mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
feat: refine portal flow and examples
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
namespace {
|
||||
const char kTitle[] PROGMEM = "Set up Compile Fixture";
|
||||
const char kIdentity[] PROGMEM = "WiFiManager";
|
||||
const char kIntro[] PROGMEM = "A branded portal compile check.";
|
||||
const char kTagline[] PROGMEM = "A branded portal compile check.";
|
||||
const char kLogoAlt[] PROGMEM = "WiFiManager";
|
||||
const char kLogo[] PROGMEM = "<svg viewBox='0 0 24 24'></svg>";
|
||||
const char kPage[] PROGMEM = "#f4f7f3";
|
||||
@@ -19,7 +19,7 @@ const char kAccentText[] PROGMEM = "#ffffff";
|
||||
const WiFiManagerPortalConfig kPortalConfig = {
|
||||
WiFiManagerPortalText::progmem(kTitle),
|
||||
WiFiManagerPortalText::progmem(kIdentity),
|
||||
WiFiManagerPortalText::progmem(kIntro),
|
||||
WiFiManagerPortalText::progmem(kTagline),
|
||||
WiFiManagerPortalAsset::svgFromProgmem(kLogo),
|
||||
WiFiManagerPortalText::progmem(kLogoAlt),
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@ TestCase tests[] = {
|
||||
TEST_ENTRY(test_api_wifi_meta_json_shape),
|
||||
TEST_ENTRY(test_api_wifi_meta_password_field_type),
|
||||
TEST_ENTRY(test_api_wifi_connect_status_success_redirect),
|
||||
TEST_ENTRY(test_profile_portal_success_keeps_handoff_alive),
|
||||
TEST_ENTRY(test_api_info_json_shape),
|
||||
TEST_ENTRY(test_api_params_json_shape),
|
||||
TEST_ENTRY(test_api_status_json_shape),
|
||||
@@ -37,7 +38,7 @@ TestCase tests[] = {
|
||||
TEST_ENTRY(test_get_config_portal_ssid),
|
||||
TEST_ENTRY(test_bootstrap_json_portal_feature_flags),
|
||||
TEST_ENTRY(test_portal_default_presentation),
|
||||
TEST_ENTRY(test_bootstrap_json_contract_v2),
|
||||
TEST_ENTRY(test_bootstrap_json_contract_v3),
|
||||
TEST_ENTRY(test_bootstrap_json_snapshot_consistency),
|
||||
TEST_ENTRY(test_root_render_interleaved_context_isolation),
|
||||
TEST_ENTRY(test_portal_presentation_configuration),
|
||||
|
||||
@@ -39,7 +39,7 @@ void test_config_portal_already_active();
|
||||
void test_get_config_portal_ssid();
|
||||
void test_bootstrap_json_portal_feature_flags();
|
||||
void test_portal_default_presentation();
|
||||
void test_bootstrap_json_contract_v2();
|
||||
void test_bootstrap_json_contract_v3();
|
||||
void test_bootstrap_json_snapshot_consistency();
|
||||
void test_root_render_interleaved_context_isolation();
|
||||
void test_portal_presentation_configuration();
|
||||
@@ -117,6 +117,7 @@ void test_captive_redirect_host_rule();
|
||||
void test_api_wifi_meta_json_shape();
|
||||
void test_api_wifi_meta_password_field_type();
|
||||
void test_api_wifi_connect_status_success_redirect();
|
||||
void test_profile_portal_success_keeps_handoff_alive();
|
||||
void test_api_info_json_shape();
|
||||
void test_api_params_json_shape();
|
||||
void test_api_status_json_shape();
|
||||
|
||||
@@ -78,6 +78,24 @@ void test_api_wifi_connect_status_success_redirect() {
|
||||
Serial.println("[TEST] WiFi connect-status success redirect payload test completed successfully");
|
||||
}
|
||||
|
||||
void test_profile_portal_success_keeps_handoff_alive() {
|
||||
Serial.println("[TEST] Testing profile portal success hand-off delay...");
|
||||
|
||||
WiFiManager wm;
|
||||
#ifdef UNIT_TEST
|
||||
wm.wmTestCompleteProfilePortalConnectionSuccess();
|
||||
TEST_ASSERT_EQUAL(WiFiManager::WM_CP_CONNECT_SUCCESS, wm.getConfigPortalConnectState());
|
||||
TEST_ASSERT_TRUE_MESSAGE(
|
||||
wm.isConfigPortalConnectPending(),
|
||||
"Profile-backed portal success must remain pending while the client reads the redirect response"
|
||||
);
|
||||
#else
|
||||
TEST_IGNORE_MESSAGE("UNIT_TEST helpers unavailable");
|
||||
#endif
|
||||
|
||||
Serial.println("[TEST] Profile portal success hand-off delay test completed successfully");
|
||||
}
|
||||
|
||||
void test_api_info_json_shape() {
|
||||
Serial.println("[TEST] Testing /api/info JSON shape...");
|
||||
|
||||
|
||||
@@ -82,13 +82,13 @@ void test_portal_default_presentation() {
|
||||
|
||||
const String bootstrap = handlers.buildPortalBootstrapJson();
|
||||
TEST_ASSERT_NOT_EQUAL(-1, bootstrap.indexOf(F("\"title\":\"WiFiManager\"")));
|
||||
TEST_ASSERT_NOT_EQUAL(-1, bootstrap.indexOf(F("\"homeIntro\":\"\"")));
|
||||
TEST_ASSERT_NOT_EQUAL(-1, bootstrap.indexOf(F("\"tagline\":\"\"")));
|
||||
TEST_ASSERT_NOT_EQUAL(-1, bootstrap.indexOf(F("\"logoSvg\":\"\"")));
|
||||
TEST_ASSERT_NOT_EQUAL(-1, bootstrap.indexOf(F("\"logoAltText\":\"\"")));
|
||||
}
|
||||
|
||||
void test_bootstrap_json_contract_v2() {
|
||||
Serial.println("[TEST] Testing bootstrap JSON v2 contract...");
|
||||
void test_bootstrap_json_contract_v3() {
|
||||
Serial.println("[TEST] Testing bootstrap JSON v3 contract...");
|
||||
|
||||
WiFiManager wm;
|
||||
WiFiManagerHandlers handlers(&wm);
|
||||
@@ -96,7 +96,7 @@ void test_bootstrap_json_contract_v2() {
|
||||
WiFiManagerPortalConfig portal;
|
||||
portal.title = WiFiManagerPortalText::ram("Solar Battery Monitor Setup");
|
||||
portal.identityText = WiFiManagerPortalText::ram("Solar Battery Monitor");
|
||||
portal.homeIntro = WiFiManagerPortalText::ram("Connect this device to WiFi and finish setup.");
|
||||
portal.tagline = WiFiManagerPortalText::ram("Connect this device to WiFi and finish setup.");
|
||||
portal.logo = WiFiManagerPortalAsset::svgFromRam("<svg viewBox='0 0 24 24'></svg>");
|
||||
TEST_ASSERT_TRUE(wm.setPortalConfig(portal));
|
||||
wm.portalSetPageInfoVisible(true);
|
||||
@@ -115,10 +115,10 @@ void test_bootstrap_json_contract_v2() {
|
||||
wm.portalAddHomeCard(card);
|
||||
|
||||
String j = handlers.buildPortalBootstrapJson();
|
||||
TEST_ASSERT_NOT_EQUAL(-1, j.indexOf(F("\"contractVersion\":2")));
|
||||
TEST_ASSERT_NOT_EQUAL(-1, j.indexOf(F("\"contractVersion\":3")));
|
||||
TEST_ASSERT_NOT_EQUAL(-1, j.indexOf(F("\"brand\":{")));
|
||||
TEST_ASSERT_NOT_EQUAL(-1, j.indexOf(F("\"title\":\"Solar Battery Monitor Setup\"")));
|
||||
TEST_ASSERT_NOT_EQUAL(-1, j.indexOf(F("\"homeIntro\":\"Connect this device to WiFi and finish setup.\"")));
|
||||
TEST_ASSERT_NOT_EQUAL(-1, j.indexOf(F("\"tagline\":\"Connect this device to WiFi and finish setup.\"")));
|
||||
TEST_ASSERT_NOT_EQUAL(-1, j.indexOf(F("\"logoSvg\":\"<svg viewBox='0 0 24 24'></svg>\"")));
|
||||
TEST_ASSERT_NOT_EQUAL(-1, j.indexOf(F("\"context\":{")));
|
||||
TEST_ASSERT_NOT_EQUAL(-1, j.indexOf(F("\"identityText\":\"Solar Battery Monitor\"")));
|
||||
@@ -239,7 +239,7 @@ void test_portal_presentation_configuration() {
|
||||
WiFiManagerPortalConfig config;
|
||||
config.title = WiFiManagerPortalText::ram("Set up Temperature Monitor");
|
||||
config.identityText = WiFiManagerPortalText::ram("Example Devices");
|
||||
config.homeIntro = WiFiManagerPortalText::ram("Connect this device to WiFi.");
|
||||
config.tagline = WiFiManagerPortalText::ram("Connect this device to WiFi.");
|
||||
config.logo = WiFiManagerPortalAsset::svgFromRam("<svg viewBox='0 0 24 24'></svg>");
|
||||
config.logoAltText = WiFiManagerPortalText::ram("Example Devices logo");
|
||||
config.theme.pageBackground = WiFiManagerPortalText::ram("#f4f7f3");
|
||||
|
||||
Reference in New Issue
Block a user