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
This commit is contained in:
Michał Cieślak 2023-10-16 10:48:56 +02:00 committed by Michał
parent 22ce35cf9c
commit d33e8f23a0
2 changed files with 51 additions and 3 deletions

View File

@ -42,6 +42,9 @@ BUILD_SYSTEM_DIR := vendor/nimbus-build-system
run-statusq-sanity-checker \ run-statusq-sanity-checker \
statusq-tests \ statusq-tests \
run-statusq-tests \ run-statusq-tests \
storybook-build \
run-storybook \
run-storybook-tests \
update update
ifeq ($(NIM_PARAMS),) ifeq ($(NIM_PARAMS),)
@ -322,6 +325,47 @@ run-statusq-tests: statusq-tests
echo -e "\033[92mRunning:\033[39m StatusQ Unit Tests" echo -e "\033[92mRunning:\033[39m StatusQ Unit Tests"
$(STATUSQ_BUILD_PATH)/bin/TestStatusQ $(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 ## DOtherSide
## ##
@ -792,7 +836,7 @@ pkg-windows: check-pkg-target-windows $(STATUS_CLIENT_EXE)
zip-windows: check-pkg-target-windows $(STATUS_CLIENT_7Z) 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) rm -rf bin/* node_modules bottles/* pkg/* tmp/* $(STATUSKEYCARDGO)
+ $(MAKE) -C vendor/QR-Code-generator/c/ --no-print-directory clean + $(MAKE) -C vendor/QR-Code-generator/c/ --no-print-directory clean

View File

@ -79,6 +79,8 @@ target_link_libraries(
add_dependencies(${PROJECT_NAME} StatusQ) add_dependencies(${PROJECT_NAME} StatusQ)
enable_testing()
add_executable( add_executable(
PagesValidator PagesValidator
validator_main.cpp validator_main.cpp
@ -87,12 +89,14 @@ add_executable(
target_link_libraries( target_link_libraries(
PagesValidator PUBLIC Qt5::Core Qt5::Gui Qt5::Quick Qt5::QuickControls2) PagesValidator PUBLIC Qt5::Core Qt5::Gui Qt5::Quick Qt5::QuickControls2)
add_dependencies(PagesValidator StatusQ)
target_compile_definitions(PagesValidator PRIVATE target_compile_definitions(PagesValidator PRIVATE
QML_IMPORT_ROOT="${CMAKE_CURRENT_LIST_DIR}" QML_IMPORT_ROOT="${CMAKE_CURRENT_LIST_DIR}"
STATUSQ_MODULE_IMPORT_PATH="${STATUSQ_MODULE_IMPORT_PATH}" STATUSQ_MODULE_IMPORT_PATH="${STATUSQ_MODULE_IMPORT_PATH}"
) )
enable_testing() add_test(NAME PagesValidator COMMAND PagesValidator)
add_executable(SectionsDecoratorModelTest tests/tst_SectionsDecoratorModel.cpp) add_executable(SectionsDecoratorModelTest tests/tst_SectionsDecoratorModel.cpp)
target_link_libraries(SectionsDecoratorModelTest PRIVATE Qt5::Test ${PROJECT_LIB}) 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}" STATUSQ_MODULE_IMPORT_PATH="${STATUSQ_MODULE_IMPORT_PATH}"
QUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/qmlTests") QUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/qmlTests")
target_link_libraries(QmlTests PRIVATE Qt5::QuickTest Qt5::Qml ${PROJECT_LIB} SortFilterProxyModel) 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/app")
list(APPEND QML_DIRS "${CMAKE_SOURCE_DIR}/../ui/imports") list(APPEND QML_DIRS "${CMAKE_SOURCE_DIR}/../ui/imports")