From d33e8f23a0d64ea56c2005696287ea480a262028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Mon, 16 Oct 2023 10:48:56 +0200 Subject: [PATCH] feat(Storybook): Add storybook targets to Makefile Adds target to run a storybook itself (run-storybook) and also target to run all tests from storybook directory (run-storybook-tests): - unit tests for storybook itself - unit tests for the app using the same stubs mechanism (in offscreen mode) - PagesValidator Tests are run via ctest. Closes: #12448 --- Makefile | 46 +++++++++++++++++++++++++++++++++++++++- storybook/CMakeLists.txt | 8 +++++-- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4806ca66ca..28c27b32e5 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,9 @@ BUILD_SYSTEM_DIR := vendor/nimbus-build-system run-statusq-sanity-checker \ statusq-tests \ run-statusq-tests \ + storybook-build \ + run-storybook \ + run-storybook-tests \ update ifeq ($(NIM_PARAMS),) @@ -322,6 +325,47 @@ run-statusq-tests: statusq-tests echo -e "\033[92mRunning:\033[39m StatusQ Unit Tests" $(STATUSQ_BUILD_PATH)/bin/TestStatusQ + +## +## Storybook +## + +STORYBOOK_SOURCE_PATH := storybook +STORYBOOK_BUILD_PATH := $(STORYBOOK_SOURCE_PATH)/build +STORYBOOK_CMAKE_CACHE := $(STORYBOOK_BUILD_PATH)/CMakeCache.txt + +$(STORYBOOK_CMAKE_CACHE): | deps + echo -e "\033[92mConfiguring:\033[39m Storybook" + cmake \ + -DCMAKE_INSTALL_PREFIX=$(STORYBOOK_INSTALL_PATH) \ + -DCMAKE_BUILD_TYPE=$(COMMON_CMAKE_BUILD_TYPE) \ + -DSTATUSQ_SHADOW_BUILD=OFF \ + $(COMMON_CMAKE_CONFIG_PARAMS) \ + -B $(STORYBOOK_BUILD_PATH) \ + -S $(STORYBOOK_SOURCE_PATH) \ + -Wno-dev \ + $(HANDLE_OUTPUT) + +storybook-configure: | $(STORYBOOK_CMAKE_CACHE) + +storybook-build: | storybook-configure + echo -e "\033[92mBuilding:\033[39m Storybook" + cmake --build $(STORYBOOK_BUILD_PATH) \ + --config $(COMMON_CMAKE_BUILD_TYPE) \ + $(HANDLE_OUTPUT) + +run-storybook: storybook-build + echo -e "\033[92mRunning:\033[39m Storybook" + $(STORYBOOK_BUILD_PATH)/bin/Storybook + +run-storybook-tests: storybook-build + echo -e "\033[92mRunning:\033[39m Storybook Tests" + ctest -V --test-dir $(STORYBOOK_BUILD_PATH) + +storybook-clean: + echo -e "\033[92mCleaning:\033[39m Storybook" + rm -rf $(STORYBOOK_BUILD_PATH) + ## ## DOtherSide ## @@ -792,7 +836,7 @@ pkg-windows: check-pkg-target-windows $(STATUS_CLIENT_EXE) zip-windows: check-pkg-target-windows $(STATUS_CLIENT_7Z) -clean: | clean-common statusq-clean status-go-clean dotherside-clean +clean: | clean-common statusq-clean status-go-clean dotherside-clean storybook-clean rm -rf bin/* node_modules bottles/* pkg/* tmp/* $(STATUSKEYCARDGO) + $(MAKE) -C vendor/QR-Code-generator/c/ --no-print-directory clean diff --git a/storybook/CMakeLists.txt b/storybook/CMakeLists.txt index e5e5928b45..75852e968b 100644 --- a/storybook/CMakeLists.txt +++ b/storybook/CMakeLists.txt @@ -79,6 +79,8 @@ target_link_libraries( add_dependencies(${PROJECT_NAME} StatusQ) +enable_testing() + add_executable( PagesValidator validator_main.cpp @@ -87,12 +89,14 @@ add_executable( target_link_libraries( PagesValidator PUBLIC Qt5::Core Qt5::Gui Qt5::Quick Qt5::QuickControls2) +add_dependencies(PagesValidator StatusQ) + target_compile_definitions(PagesValidator PRIVATE QML_IMPORT_ROOT="${CMAKE_CURRENT_LIST_DIR}" STATUSQ_MODULE_IMPORT_PATH="${STATUSQ_MODULE_IMPORT_PATH}" ) -enable_testing() +add_test(NAME PagesValidator COMMAND PagesValidator) add_executable(SectionsDecoratorModelTest tests/tst_SectionsDecoratorModel.cpp) target_link_libraries(SectionsDecoratorModelTest PRIVATE Qt5::Test ${PROJECT_LIB}) @@ -114,7 +118,7 @@ target_compile_definitions(QmlTests PRIVATE STATUSQ_MODULE_IMPORT_PATH="${STATUSQ_MODULE_IMPORT_PATH}" QUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/qmlTests") target_link_libraries(QmlTests PRIVATE Qt5::QuickTest Qt5::Qml ${PROJECT_LIB} SortFilterProxyModel) -add_test(NAME QmlTests COMMAND QmlTests) +add_test(NAME QmlTests COMMAND QmlTests -platform offscreen) list(APPEND QML_DIRS "${CMAKE_SOURCE_DIR}/../ui/app") list(APPEND QML_DIRS "${CMAKE_SOURCE_DIR}/../ui/imports")