Files
DarkflameServer/tests/dWebTests/CMakeLists.txt
Aaron Kimbrell f58255ab8a feat(dashboard): change pages without reloading the dashboard
nav.js (loaded on every signed-in page) follows links and GET forms to
other dashboard pages by fetching the page and swapping in its <main>,
title, page styles and page scripts; the sidebar, top bar and live
WebSocket stay. History entries, back/forward (with scroll positions,
also kept for a reload), deep links, #hash filters and breadcrumbs keep
working. What the old page set up is taken down first: its
document/window listeners, setInterval timers, Live watchers and
topics, DataTables, dialogs and what it appended to <body>. Page
scripts run again in order; DOMContentLoaded/load handlers they add run
once they have all run. A thin bar shows while loading; a failed fetch
shows an inline error with Try again / Open it normally.

Falls back to a normal load for anything that isn't a signed-in
dashboard page, when the account or permissions changed, and for pages
with module scripts or an import map (World 3D, property view and 3D,
UGC server) or data-nav="reload", and when leaving those. Unsaved-change
prompts (beforeunload) are asked before swapping.

Check: click around the sidebar and into accounts/characters: no white
flash, the footer's live indicator stays "live", back/forward return to
the same scroll position, breadcrumbs follow the path (Accounts > an
account > a character). Activity Log links with #search= still filter.
System Log's server picker works. Leaving Settings with a change asks
first. World 3D and a property's 3D view still load (normally). Pages
that poll (Server Health, Instance Load) stop polling once left
(browser network tab). Test: NavRulesJs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 02:12:13 -05:00

101 lines
3.8 KiB
CMake

set(DWEBTESTS_SOURCES
"MiddlewareTests.cpp"
"RouteIntegrationTests.cpp"
"ServerStateTests.cpp"
"AccountActionTests.cpp"
"RouteUtilsTests.cpp"
"JWTTests.cpp"
"RequireAuthMiddlewareTests.cpp"
"WebTestDependencies.cpp"
"PlayerActionTests.cpp"
"SmtpTests.cpp"
"OAuth2Tests.cpp"
"EconomyReportTests.cpp"
"ItemTraceTests.cpp"
"CronTests.cpp"
"PermissionsTests.cpp"
"PermissionGrantsTests.cpp"
"ApiKeyTests.cpp"
"SettingsCatalogTests.cpp"
"BehaviorXmlTests.cpp"
"CharacterXmlTests.cpp"
"CharacterXmlCheckTests.cpp"
"CharacterRestoreTests.cpp"
"ZonePathsTests.cpp"
"RawTerrainTests.cpp"
"LevelObjectsTests.cpp"
"GameLabelsTests.cpp"
"VanityJsonTests.cpp"
"OpenApiTests.cpp"
"MessageInspectorTests.cpp"
"CDClientSchemaTests.cpp"
"ServerOperationsTests.cpp"
"PublicPagesTests.cpp"
"ModerationToolsTests.cpp"
"LocaleTextTests.cpp"
"ModeratorHelperTests.cpp"
"${PROJECT_SOURCE_DIR}/dDashboardServer/ai/ClaudeClient.cpp"
"${PROJECT_SOURCE_DIR}/dDashboardServer/ai/ModeratorPrompt.cpp"
"WorldViewTests.cpp"
"NifFileTests.cpp"
"DeferredReplyTests.cpp"
"WorkerPoolTests.cpp"
"OnceCacheTests.cpp"
"UgcLookupTests.cpp"
"${PROJECT_SOURCE_DIR}/dDashboardServer/routes/WorkerPool.cpp"
"BackupFilesTests.cpp"
"LogBundleTests.cpp"
"${PROJECT_SOURCE_DIR}/dDashboardServer/routes/LogBundle.cpp"
"SecurityFixesTests.cpp"
"${PROJECT_SOURCE_DIR}/dDashboardServer/routes/BackupFiles.cpp"
"MetricsFormatTests.cpp"
"TrafficHistoryTests.cpp"
"${PROJECT_SOURCE_DIR}/dDashboardServer/routes/TrafficHistory.cpp"
"${PROJECT_SOURCE_DIR}/dDashboardServer/routes/SettingsCatalog.cpp"
"AlertsAndTwoFactorTests.cpp"
"${PROJECT_SOURCE_DIR}/dDashboardServer/auth/Totp.cpp"
"${PROJECT_SOURCE_DIR}/dDashboardServer/notify/WebhookFormat.cpp"
"${PROJECT_SOURCE_DIR}/dDashboardServer/email/OAuth2.cpp"
"${PROJECT_SOURCE_DIR}/dDashboardServer/email/SmtpClient.cpp"
"${PROJECT_SOURCE_DIR}/dDashboardServer/auth/JWTUtils.cpp"
"${PROJECT_SOURCE_DIR}/dDashboardServer/auth/RequireAuthMiddleware.cpp"
)
add_executable(dWebTests ${DWEBTESTS_SOURCES})
target_include_directories(dWebTests PRIVATE
"${PROJECT_SOURCE_DIR}/dCommon"
"${PROJECT_SOURCE_DIR}/dCommon/dClient"
"${PROJECT_SOURCE_DIR}/dWeb"
"${PROJECT_SOURCE_DIR}/dDashboardServer"
"${PROJECT_SOURCE_DIR}/dDashboardServer/auth"
"${PROJECT_SOURCE_DIR}/dDashboardServer/routes"
"${PROJECT_SOURCE_DIR}/dChatFilter"
"${PROJECT_SOURCE_DIR}/dDashboardServer/email"
"${PROJECT_SOURCE_DIR}/dDashboardServer/notify"
"${PROJECT_SOURCE_DIR}/dDashboardServer/ai"
"${PROJECT_SOURCE_DIR}/dDatabase/GameDatabase/ITables"
"${PROJECT_SOURCE_DIR}/dNet"
"${PROJECT_SOURCE_DIR}/thirdparty/nlohmann"
)
target_link_libraries(dWebTests ${COMMON_LIBRARIES} dWeb dUgc sqlite3 OpenSSL::Crypto CURL::libcurl GTest::gtest_main)
gtest_discover_tests(dWebTests)
target_compile_definitions(dWebTests PRIVATE DLU_SOURCE_DIR="${PROJECT_SOURCE_DIR}")
# The 3D views' shader lookups (static/js/scenery-core.js) against the server's bits (NifFile.h), when node is there
find_program(NODE_EXECUTABLE node)
if(NODE_EXECUTABLE)
add_test(NAME SceneryCoreJs COMMAND ${NODE_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/scenery-core.test.mjs"
"${PROJECT_SOURCE_DIR}/dDashboardServer/static/js/scenery-core.js" "${PROJECT_SOURCE_DIR}/dCommon/NifFile.h"
"${PROJECT_SOURCE_DIR}/dDashboardServer/routes/Scenery.cpp")
# The sidebar's saved group state (the script at the end of templates/header.jinja2)
add_test(NAME SidebarStateJs COMMAND ${NODE_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/sidebar-state.test.mjs"
"${PROJECT_SOURCE_DIR}/dDashboardServer/templates/header.jinja2")
# Which links the dashboard follows without a reload (static/js/nav.js)
add_test(NAME NavRulesJs COMMAND ${NODE_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/nav.test.mjs"
"${PROJECT_SOURCE_DIR}/dDashboardServer/static/js/nav.js")
endif()