kokopu-react 3.2.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/lib/chessboard/Chessboard.d.ts +27 -2
- package/dist/lib/chessboard/Chessboard.js +38 -18
- package/dist/lib/chessboard/Chessboard.js.map +1 -1
- package/dist/lib/chessboard/ChessboardImpl.js +1 -1
- package/dist/lib/chessboard/ChessboardImpl.js.map +1 -1
- package/dist/lib/chessboard/Motion.js +1 -1
- package/dist/lib/chessboard/Motion.js.map +1 -1
- package/dist/lib/i18n.js +2 -2
- package/dist/lib/i18n.js.map +1 -1
- package/dist/lib/icons/ArrowMarkerIcon.js.map +1 -1
- package/dist/lib/icons/ChessPieceIcon.d.ts +1 -4
- package/dist/lib/icons/ChessPieceIcon.js +1 -5
- package/dist/lib/icons/ChessPieceIcon.js.map +1 -1
- package/dist/lib/icons/SquareMarkerIcon.d.ts +1 -4
- package/dist/lib/icons/SquareMarkerIcon.js +1 -5
- package/dist/lib/icons/SquareMarkerIcon.js.map +1 -1
- package/dist/lib/icons/TextMarkerIcon.d.ts +1 -4
- package/dist/lib/icons/TextMarkerIcon.js +1 -5
- package/dist/lib/icons/TextMarkerIcon.js.map +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/movetext/Movetext.js.map +1 -1
- package/dist/lib/movetext/MovetextImpl.js +4 -3
- package/dist/lib/movetext/MovetextImpl.js.map +1 -1
- package/dist/lib/movetext/htmlFilter.js +1 -1
- package/dist/lib/movetext/htmlFilter.js.map +1 -1
- package/dist/lib/navigationboard/NavigationBoard.d.ts +37 -8
- package/dist/lib/navigationboard/NavigationBoard.js +67 -22
- package/dist/lib/navigationboard/NavigationBoard.js.map +1 -1
- package/dist/lib/navigationboard/NavigationButton.d.ts +13 -1
- package/dist/lib/navigationboard/NavigationButton.js +32 -0
- package/dist/lib/navigationboard/NavigationButton.js.map +1 -1
- package/dist/lib/navigationboard/NavigationField.js +1 -1
- package/dist/lib/navigationboard/NavigationField.js.map +1 -1
- package/dist/lib/navigationboard/NavigationToolbar.d.ts +9 -2
- package/dist/lib/navigationboard/NavigationToolbar.js +34 -1
- package/dist/lib/navigationboard/NavigationToolbar.js.map +1 -1
- package/dist/lib/util.js +2 -2
- package/dist/lib/util.js.map +1 -1
- package/doc_src/demo/PageChessboardBase.tsx +57 -51
- package/doc_src/demo/PageChessboardInteraction.tsx +78 -63
- package/doc_src/demo/PageChessboardMove.tsx +35 -30
- package/doc_src/demo/PageChessboardSmallScreens.tsx +3 -3
- package/doc_src/demo/PageMovetextBase.tsx +91 -81
- package/doc_src/demo/PageMovetextInteraction.tsx +23 -21
- package/doc_src/demo/PageNavigationBoardBase.tsx +62 -54
- package/doc_src/demo/PageNavigationBoardUncontrolledVsControlled.tsx +24 -18
- package/doc_src/theming/LogoRenderer.js +8 -9
- package/package.json +30 -28
- package/scripts/docker-compose.yml +1 -3
- package/src/chessboard/BoardProperties.ts +13 -13
- package/src/chessboard/Chessboard.tsx +106 -46
- package/src/chessboard/ChessboardImpl.tsx +58 -41
- package/src/chessboard/Draggable.tsx +15 -15
- package/src/chessboard/Motion.tsx +4 -4
- package/src/errorbox/ErrorBox.tsx +5 -5
- package/src/errorbox/parsing.tsx +6 -6
- package/src/i18n.ts +2 -2
- package/src/icons/AnnotationSymbolShape.tsx +5 -5
- package/src/icons/ArrowMarkerIcon.tsx +8 -4
- package/src/icons/ArrowTip.tsx +2 -2
- package/src/icons/ChessPieceIcon.tsx +4 -11
- package/src/icons/SquareMarkerIcon.tsx +3 -10
- package/src/icons/TextMarkerIcon.tsx +4 -11
- package/src/index.ts +1 -1
- package/src/movetext/Movetext.tsx +11 -10
- package/src/movetext/MovetextImpl.tsx +34 -28
- package/src/movetext/htmlFilter.tsx +4 -4
- package/src/navigationboard/NavigationBoard.tsx +150 -58
- package/src/navigationboard/NavigationButton.ts +47 -5
- package/src/navigationboard/NavigationField.tsx +6 -6
- package/src/navigationboard/NavigationToolbar.tsx +62 -15
- package/src/types.ts +26 -26
- package/src/util.ts +2 -2
- package/test/01_types.js +83 -61
- package/test/02_chessboard_util.js +79 -1
- package/test/03_error_box_graphic.js +1 -1
- package/test/07_chessboard_interaction.js +1 -2
- package/test/13_navigation_board_graphic.js +3 -3
- package/test/common/graphic.js +11 -11
- package/test/graphic_references/03_error_box_graphic/base/cut_beginning_of_text.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/cut_end_of_text.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/cut_on_line_breaks.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/error_index_not_integer.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/full.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/minimal.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/missing_error_index.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/missing_error_text.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/negative_error_index.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/single_character_text.png +0 -0
- package/test/graphic_references/03_error_box_graphic/base/too_large_error_index.png +0 -0
- package/test/graphic_references/03_error_box_graphic/localization/default.png +0 -0
- package/test/graphic_references/04_icons_graphic/chess_piece/customized_pieceset.png +0 -0
- package/test/graphic_references/04_icons_graphic/chess_piece/invalid_multiple_pieces.png +0 -0
- package/test/graphic_references/04_icons_graphic/chess_piece/invalid_pieceset.png +0 -0
- package/test/graphic_references/04_icons_graphic/chess_piece/invalid_single_piece.png +0 -0
- package/test/graphic_references/04_icons_graphic/chess_piece/invalid_size.png +0 -0
- package/test/graphic_references/04_icons_graphic/chess_piece/multiple_pieces.png +0 -0
- package/test/graphic_references/04_icons_graphic/chess_piece/single_piece.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/colorized_arrow.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/colorized_square.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/colorized_symbol.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/colorized_text.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/default_arrow.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/default_square.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/default_text.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/invalid_arrow_size.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/invalid_square_size.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/invalid_symbol.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/invalid_text_size.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/wrapped_arrow.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/wrapped_square.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/wrapped_symbol.png +0 -0
- package/test/graphic_references/04_icons_graphic/marker/wrapped_text.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/annotations/overlap.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/annotations/overlap_and_flip.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/annotations/with_coordinates.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/annotations/with_coordinates_and_flip.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/annotations/without_coordinates.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/annotations/without_coordinates_and_flip.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/base/default.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/base/empty.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/base/from_fen.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/base/from_kokopu_object.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/base/parsing_error.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/base/wrong_position_type.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/chess960.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/chess960_with_move.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/invalid_variant.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/invalid_variant_with_fen.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/special_code.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/variant_with_std_initial_position.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/chess_variants/variant_without_std_initial_position.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/flipped/default.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/flipped/empty.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/flipped/from_fen.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/flipped/from_kokopu_object.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/flipped/parsing_error.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/capture.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/castling_move.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/default.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/en-passant.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/illegal_null-move.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/no_move_arrow.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/null-move.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/parsing_error.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/promotion.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/with_forced_move_arrow_and_flip.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/wrong_move_arrow_color_type.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/move/wrong_move_type.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/custom_1.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/custom_2.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/custom_3.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/custom_4.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/custom_5.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/custom_6.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/default.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/large.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/small.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/wrong_colorset.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/wrong_pieceset.png +0 -0
- package/test/graphic_references/05_chessboard_graphic/theme/wrong_square_size_type.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_1/capture.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_1/castling_move.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_1/en-passant.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_1/move_1.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_1/move_2.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_1/promotion.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_2/capture.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_2/castling_move.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_2/en-passant.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_2/move_1.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_2/move_2.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_2/promotion.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_3/capture.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_3/castling_move.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_3/en-passant.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_3/move_1.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_3/move_2.png +0 -0
- package/test/graphic_references/06_chessboard_animation/base_3/promotion.png +0 -0
- package/test/graphic_references/06_chessboard_animation/on_redraw/final_state.png +0 -0
- package/test/graphic_references/06_chessboard_animation/on_redraw/initial_state.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/edit_arrows/base_1.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/edit_arrows/base_2.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/edit_arrows/from_==_to.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/edit_arrows/out_of_board.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/edit_arrows/over_arrow_marker.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/edit_arrows/over_square_marker.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/error/edit_color_not_set.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/error/wrong_interaction_mode.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/after_move.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/from_==_to.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/move_empty_square.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/out_of_board.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/over_arrow_marker.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/over_empty.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/over_non-empty_1.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/over_non-empty_2.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/over_square_marker.png +0 -0
- package/test/graphic_references/07_chessboard_interaction/move_pieces/over_text_marker.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/castling_move.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/chess960_ambiguous_king_move.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/chess960_castling_move_1.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/chess960_castling_move_2.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/chess960_non-kxr_castling.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/from_==_to.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/illegal_move.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/illegal_position.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/out_of_board.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/regular_move_1.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/regular_move_2.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/base/wrong_color_moved.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/promotions/antichess_promotion.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/promotions/cancel_promotion.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/promotions/regular_promotion_1.png +0 -0
- package/test/graphic_references/08_chessboard_play_moves/promotions/regular_promotion_2.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/default.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/invalid_limits.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/width_690.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/width_700.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/width_710.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/width_720.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/width_730.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/width_740.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/base/width_750.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/default_bottom_component.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/default_top_component.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/reduced_bottom_component.png +0 -0
- package/test/graphic_references/09_chessboard_small_screens/top_bottom_components/reduced_top_component.png +0 -0
- package/test/graphic_references/10_movetext_graphic/base/game_1.png +0 -0
- package/test/graphic_references/10_movetext_graphic/base/game_2.png +0 -0
- package/test/graphic_references/10_movetext_graphic/base/game_3.png +0 -0
- package/test/graphic_references/10_movetext_graphic/base/game_4.png +0 -0
- package/test/graphic_references/10_movetext_graphic/error/pgn_parsing_error_1.png +0 -0
- package/test/graphic_references/10_movetext_graphic/error/pgn_parsing_error_2.png +0 -0
- package/test/graphic_references/10_movetext_graphic/error/wrong_game_index_1.png +0 -0
- package/test/graphic_references/10_movetext_graphic/error/wrong_game_index_2.png +0 -0
- package/test/graphic_references/10_movetext_graphic/error/wrong_game_index_type.png +0 -0
- package/test/graphic_references/10_movetext_graphic/error/wrong_game_type.png +0 -0
- package/test/graphic_references/10_movetext_graphic/format_move/format_text.png +0 -0
- package/test/graphic_references/10_movetext_graphic/html/filtered_tags_and_attributes.png +0 -0
- package/test/graphic_references/10_movetext_graphic/html/html_in_comments.png +0 -0
- package/test/graphic_references/10_movetext_graphic/html/html_in_headers.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/custom_piece_symbols.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/figurine_piece_symbols_and_diagram_options.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/hidden_diagrams.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/localized_piece_symbols.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/other_diagram_options.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/wrong_diagram_options_1.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/wrong_diagram_options_2.png +0 -0
- package/test/graphic_references/10_movetext_graphic/options/wrong_piece_symbol_value.png +0 -0
- package/test/graphic_references/11_movetext_interaction/error/wrong_interaction_mode.png +0 -0
- package/test/graphic_references/11_movetext_interaction/select_moves/click_on_disabled.png +0 -0
- package/test/graphic_references/11_movetext_interaction/select_moves/click_on_unselected.png +0 -0
- package/test/graphic_references/11_movetext_interaction/select_moves/click_on_unselected_without_callback.png +0 -0
- package/test/graphic_references/11_movetext_interaction/select_moves/click_on_with_variations.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/default.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/forbidden_navigation_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/forbidden_navigation_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/invalid_node_id.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/no_callback_defined_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/no_callback_defined_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/overriding_initial_node_id.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/controlled/regular_navigation_3.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_beginning_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/forbidden_navigation_at_end_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_at_end.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_at_specific_id.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_default.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_default_with_game_index.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/initial_state_on_null-move.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_3.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/navigation_with_keys_4.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_flipping_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_flipping_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_0.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_1.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_2.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_3.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_4.png +0 -0
- package/test/graphic_references/12_navigation_board_base/uncontrolled/regular_navigation_5.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/error_1.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/error_2.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/multiple_buttons.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/additional_buttons/single_button.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/error/pgn_parsing_error.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/error/wrong_game_type.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/theme/custom_1.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/theme/custom_2.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/theme/large.png +0 -0
- package/test/graphic_references/13_navigation_board_graphic/theme/small.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_1_move_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_1_move_not_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_2_moves_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_2_moves_not_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/after_reaching_the_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/already_at_the_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_at_the_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_close_to_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_not_acknowledging_is-playing_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/controlled/initial_state_not_acknowledging_node_changes.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_2_moves_from_beginning_after_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_2_moves_from_beginning_before_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_reaching_the_end_after_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/after_reaching_the_end_before_stop.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/initial_state_close_to_end.png +0 -0
- package/test/graphic_references/14_navigation_board_autoplay/uncontrolled/initial_state_default.png +0 -0
- package/test/graphic_test_app/03_error_box_graphic/base.tsx +18 -6
- package/test/graphic_test_app/04_icons_graphic/chess_piece.tsx +12 -3
- package/test/graphic_test_app/04_icons_graphic/marker.tsx +14 -4
- package/test/graphic_test_app/05_chessboard_graphic/annotations.tsx +7 -3
- package/test/graphic_test_app/05_chessboard_graphic/base.tsx +1 -1
- package/test/graphic_test_app/05_chessboard_graphic/move.tsx +9 -2
- package/test/graphic_test_app/05_chessboard_graphic/theme.tsx +1 -1
- package/test/graphic_test_app/06_chessboard_animation/on_redraw.tsx +8 -6
- package/test/graphic_test_app/07_chessboard_interaction/click_squares.tsx +4 -2
- package/test/graphic_test_app/07_chessboard_interaction/edit_arrows.tsx +4 -2
- package/test/graphic_test_app/07_chessboard_interaction/error.tsx +3 -1
- package/test/graphic_test_app/07_chessboard_interaction/move_pieces.tsx +4 -2
- package/test/graphic_test_app/08_chessboard_play_moves/base.tsx +12 -6
- package/test/graphic_test_app/08_chessboard_play_moves/promotions.tsx +12 -3
- package/test/graphic_test_app/09_chessboard_small_screens/base.tsx +3 -1
- package/test/graphic_test_app/09_chessboard_small_screens/top_bottom_components.tsx +8 -6
- package/test/graphic_test_app/10_movetext_graphic/error.tsx +1 -1
- package/test/graphic_test_app/10_movetext_graphic/options.tsx +16 -6
- package/test/graphic_test_app/11_movetext_interaction/error.tsx +4 -1
- package/test/graphic_test_app/13_navigation_board_graphic/additional_buttons.tsx +24 -17
- package/test/graphic_test_app/13_navigation_board_graphic/error.tsx +1 -1
- package/test/graphic_test_app/14_navigation_board_autoplay/controlled.tsx +34 -18
- package/test/graphic_test_app/common/test_app.tsx +4 -4
- package/.eslintrc.yml +0 -83
- package/test/.eslintrc.yml +0 -8
- package/test/graphic_test_app/.eslintrc.yml +0 -3
package/src/util.ts
CHANGED
|
@@ -26,8 +26,8 @@ export function generateRandomId() {
|
|
|
26
26
|
const buffer = new Uint32Array(8);
|
|
27
27
|
crypto.getRandomValues(buffer);
|
|
28
28
|
let result = '';
|
|
29
|
-
for (
|
|
30
|
-
result +=
|
|
29
|
+
for (const c of buffer) {
|
|
30
|
+
result += c.toString(16);
|
|
31
31
|
}
|
|
32
32
|
return result;
|
|
33
33
|
}
|
package/test/01_types.js
CHANGED
|
@@ -35,7 +35,7 @@ describe('Is piece symbol mapping', () => {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
itIsPieceSymbolMapping('French localization', { K: 'R', Q: 'D', R: 'T', B: 'F', N: 'C', P: 'P' }
|
|
38
|
+
itIsPieceSymbolMapping('French localization', { K: 'R', Q: 'D', R: 'T', B: 'F', N: 'C', P: 'P' }, true);
|
|
39
39
|
itIsPieceSymbolMapping('Additional fields', { K: 'Ki_', Q: 'Qu_', R: 'Rk_', B: 'Bi_', N: 'Kn_', P: 'Pw_', Z: 'whatever', val: 42 }, true);
|
|
40
40
|
itIsPieceSymbolMapping('Missing fields', { K: 'Ki_', Q: 'Qu_', R: 'Rk_', B: 'Bi_', N: 'Kn_' }, false);
|
|
41
41
|
itIsPieceSymbolMapping('Non-string valued fields', { K: 42, Q: 'Qu_', R: 'Rk_', B: 'Bi_', N: 'Kn_', P: 'Pw_' }, false);
|
|
@@ -125,46 +125,60 @@ describe('Parse square markers', () => {
|
|
|
125
125
|
describe('Flatten text markers', () => {
|
|
126
126
|
|
|
127
127
|
it('RAe4', () => { test.value(flattenTextMarkers({ e4: { symbol: 'A', color: 'r' } })).is('RAe4'); });
|
|
128
|
-
it('Gzd3,Y1h8', () => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
128
|
+
it('Gzd3,Y1h8', () => {
|
|
129
|
+
test.value(flattenTextMarkers({
|
|
130
|
+
h8: { symbol: '1', color: 'y' },
|
|
131
|
+
d3: { symbol: 'z', color: 'g' },
|
|
132
|
+
})).is('Gzd3,Y1h8');
|
|
133
|
+
});
|
|
134
|
+
it('G2a1,YMc5,RLd2,Rxh7,Bwh8', () => {
|
|
135
|
+
test.value(flattenTextMarkers({
|
|
136
|
+
c5: { symbol: 'M', color: 'y' },
|
|
137
|
+
h8: { symbol: 'w', color: 'b' },
|
|
138
|
+
a1: { symbol: '2', color: 'g' },
|
|
139
|
+
h7: { symbol: 'x', color: 'r' },
|
|
140
|
+
d2: { symbol: 'L', color: 'r' },
|
|
141
|
+
})).is('G2a1,YMc5,RLd2,Rxh7,Bwh8');
|
|
142
|
+
});
|
|
143
|
+
it('Multi-character symbols', () => {
|
|
144
|
+
test.value(flattenTextMarkers({
|
|
145
|
+
a1: { symbol: 'A', color: 'y' },
|
|
146
|
+
a7: { symbol: 'plus', color: 'g' },
|
|
147
|
+
b3: { symbol: 'times', color: 'r' },
|
|
148
|
+
g5: { symbol: 'dot', color: 'y' },
|
|
149
|
+
h3: { symbol: 'circle', color: 'g' },
|
|
150
|
+
})).is('YAa1,G(plus)a7,R(times)b3,Y(dot)g5,G(circle)h3');
|
|
151
|
+
});
|
|
146
152
|
it('<empty>', () => { test.value(flattenTextMarkers({})).is(''); });
|
|
147
153
|
|
|
148
|
-
it('Wrong square', () => {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
154
|
+
it('Wrong square', () => {
|
|
155
|
+
test.value(flattenTextMarkers({
|
|
156
|
+
e1: { symbol: 'H', color: 'r' },
|
|
157
|
+
j5: { symbol: 'A', color: 'g' },
|
|
158
|
+
})).is('RHe1');
|
|
159
|
+
});
|
|
160
|
+
it('Wrong color', () => {
|
|
161
|
+
test.value(flattenTextMarkers({
|
|
162
|
+
a2: { symbol: '0', color: 'g' },
|
|
163
|
+
b5: { symbol: 'A', color: 'R' },
|
|
164
|
+
h8: { symbol: 'A' },
|
|
165
|
+
})).is('G0a2');
|
|
166
|
+
});
|
|
167
|
+
it('Wrong symbol', () => {
|
|
168
|
+
test.value(flattenTextMarkers({
|
|
169
|
+
a2: { symbol: '0', color: 'g' },
|
|
170
|
+
b5: { symbol: '', color: 'r' },
|
|
171
|
+
h8: { color: 'g' },
|
|
172
|
+
d8: { symbol: '-', color: 'r' },
|
|
173
|
+
c1: { symbol: 'abcd', color: 'r' },
|
|
174
|
+
})).is('G0a2');
|
|
175
|
+
});
|
|
176
|
+
it('Wrong multi-character symbol', () => {
|
|
177
|
+
test.value(flattenTextMarkers({
|
|
178
|
+
a2: { symbol: '0', color: 'g' },
|
|
179
|
+
b5: { symbol: 'whatever', color: 'r' },
|
|
180
|
+
})).is('G0a2');
|
|
181
|
+
});
|
|
168
182
|
|
|
169
183
|
it('Wrong type (not an object)', () => { test.exception(() => flattenTextMarkers('whatever')).isInstanceOf(exception.IllegalArgument); });
|
|
170
184
|
it('Wrong type (null)', () => { test.exception(() => flattenTextMarkers(null)).isInstanceOf(exception.IllegalArgument); });
|
|
@@ -175,24 +189,30 @@ describe('Flatten text markers', () => {
|
|
|
175
189
|
describe('Parse text markers', () => {
|
|
176
190
|
|
|
177
191
|
it('RAe4', () => { test.value(parseTextMarkers('RAe4')).is({ e4: { symbol: 'A', color: 'r' } }); });
|
|
178
|
-
it('Gzd3,Y1h8', () => {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
it('Gzd3,Y1h8', () => {
|
|
193
|
+
test.value(parseTextMarkers('Gzd3,Y1h8')).is({
|
|
194
|
+
h8: { symbol: '1', color: 'y' },
|
|
195
|
+
d3: { symbol: 'z', color: 'g' },
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
it('G2a1,YMc5,RLd2,Rxh7,Bwh8', () => {
|
|
199
|
+
test.value(parseTextMarkers(' G2a1, Rxh7 ,YMc5 ,RLd2,Bwh8 ')).is({
|
|
200
|
+
c5: { symbol: 'M', color: 'y' },
|
|
201
|
+
h8: { symbol: 'w', color: 'b' },
|
|
202
|
+
a1: { symbol: '2', color: 'g' },
|
|
203
|
+
h7: { symbol: 'x', color: 'r' },
|
|
204
|
+
d2: { symbol: 'L', color: 'r' },
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
it('Multi-character symbols', () => {
|
|
208
|
+
test.value(parseTextMarkers('YAa1,G(plus)a7, R(times)b3 ,Y(dot)g5,G(circle)h3')).is({
|
|
209
|
+
a1: { symbol: 'A', color: 'y' },
|
|
210
|
+
a7: { symbol: 'plus', color: 'g' },
|
|
211
|
+
b3: { symbol: 'times', color: 'r' },
|
|
212
|
+
g5: { symbol: 'dot', color: 'y' },
|
|
213
|
+
h3: { symbol: 'circle', color: 'g' },
|
|
214
|
+
});
|
|
215
|
+
});
|
|
196
216
|
it('<empty>', () => { test.value(parseTextMarkers('')).is({}); });
|
|
197
217
|
it('<blank>', () => { test.value(parseTextMarkers(' ')).is({}); });
|
|
198
218
|
|
|
@@ -213,8 +233,9 @@ describe('Flatten arrow markers', () => {
|
|
|
213
233
|
|
|
214
234
|
it('Re4d6', () => { test.value(flattenArrowMarkers({ e4d6: 'r' })).is('Re4d6'); });
|
|
215
235
|
it('Gd3b4,Yh8h7', () => { test.value(flattenArrowMarkers({ h8h7: 'y', d3b4: 'g' })).is('Gd3b4,Yh8h7'); });
|
|
216
|
-
it('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5', () => {
|
|
217
|
-
.is('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5');
|
|
236
|
+
it('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5', () => {
|
|
237
|
+
test.value(flattenArrowMarkers({ c5a1: 'y', h8c5: 'b', a1h8: 'g', h7h8: 'r', d2d2: 'r' })).is('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5');
|
|
238
|
+
});
|
|
218
239
|
it('<empty>', () => { test.value(flattenArrowMarkers({})).is(''); });
|
|
219
240
|
|
|
220
241
|
it('Wrong vector', () => { test.value(flattenArrowMarkers({ e1c2: 'r', a1b9: 'g', c0d2: 'r', i3d4: 'r', f2k3: 'g', whatever: 'y' })).is('Re1c2'); });
|
|
@@ -230,8 +251,9 @@ describe('Parse arrow markers', () => {
|
|
|
230
251
|
|
|
231
252
|
it('Re4d6', () => { test.value(parseArrowMarkers('Re4d6')).is({ e4d6: 'r' }); });
|
|
232
253
|
it('Gd3b4,Yh8h7', () => { test.value(parseArrowMarkers('Gd3b4,Yh8h7')).is({ h8h7: 'y', d3b4: 'g' }); });
|
|
233
|
-
it('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5', () => {
|
|
234
|
-
.is({ c5a1: 'y', h8c5: 'b', a1h8: 'g', h7h8: 'r', d2d2: 'r' });
|
|
254
|
+
it('Ga1h8,Yc5a1,Rd2d2,Rh7h8,Bh8c5', () => {
|
|
255
|
+
test.value(parseArrowMarkers(' Bh8c5,Ga1h8 , Yc5a1 , Rd2d2,Rh7h8 ')).is({ c5a1: 'y', h8c5: 'b', a1h8: 'g', h7h8: 'r', d2d2: 'r' });
|
|
256
|
+
});
|
|
235
257
|
it('<empty>', () => { test.value(parseArrowMarkers('')).is({}); });
|
|
236
258
|
it('<blank>', () => { test.value(parseArrowMarkers(' ')).is({}); });
|
|
237
259
|
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* -------------------------------------------------------------------------- */
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
const { exception, Chessboard } = require('../build/test_headless/index');
|
|
25
|
+
const { exception, Chessboard, NavigationBoard } = require('../build/test_headless/index');
|
|
26
26
|
const test = require('unit.js');
|
|
27
27
|
|
|
28
28
|
|
|
@@ -45,6 +45,22 @@ describe('Chessboard.size()', () => {
|
|
|
45
45
|
itChessboardSize('Default without turn', 330, 333, { turnVisible: false });
|
|
46
46
|
itChessboardSize('Default board only', 320, 320, { coordinateVisible: false, turnVisible: false });
|
|
47
47
|
|
|
48
|
+
function topComponent({ squareSize, coordinateVisible, turnVisible }) {
|
|
49
|
+
const width = squareSize * 20;
|
|
50
|
+
const height = (coordinateVisible ? 11 : 0) + (turnVisible ? 107 : 0);
|
|
51
|
+
return { width: width, height: height };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function bottomComponent({ squareSize, coordinateVisible, turnVisible }) {
|
|
55
|
+
const width = squareSize * 19;
|
|
56
|
+
const height = (coordinateVisible ? 3 : 0) + (turnVisible ? 157 : 0);
|
|
57
|
+
return { width: width, height: height };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
itChessboardSize('With top component', 800, 451, { topComponent: topComponent });
|
|
61
|
+
itChessboardSize('With bottom component', 760, 493, { bottomComponent: bottomComponent });
|
|
62
|
+
itChessboardSize('With top & bottom components', 800, 611, { topComponent: topComponent, bottomComponent: bottomComponent });
|
|
63
|
+
|
|
48
64
|
itInvalidArgument('Attribute not an object', () => Chessboard.size('not-an-object'));
|
|
49
65
|
itInvalidArgument('Square size not an integer', () => Chessboard.size({ squareSize: 'not-an-integer' }));
|
|
50
66
|
itInvalidArgument('Small-screen limits not an array', () => Chessboard.size({ smallScreenLimits: 'not-an-array' }));
|
|
@@ -54,6 +70,38 @@ describe('Chessboard.size()', () => {
|
|
|
54
70
|
});
|
|
55
71
|
|
|
56
72
|
|
|
73
|
+
describe('NavigationBoard.size()', () => {
|
|
74
|
+
|
|
75
|
+
function itNavigationBoardSize(label, expectedWidth, expectedHeight, attr) {
|
|
76
|
+
it(label, () => {
|
|
77
|
+
test.value(NavigationBoard.size(attr)).is({ width: expectedWidth, height: expectedHeight });
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
itNavigationBoardSize('Default', 374, 368);
|
|
82
|
+
itNavigationBoardSize('Minimal square size with all default buttons', 130, 121, {
|
|
83
|
+
squareSize: 12,
|
|
84
|
+
coordinateVisible: false,
|
|
85
|
+
turnVisible: false,
|
|
86
|
+
playButtonVisible: true,
|
|
87
|
+
flipButtonVisible: true,
|
|
88
|
+
});
|
|
89
|
+
itNavigationBoardSize('With additional buttons', 198, 188, {
|
|
90
|
+
squareSize: 20,
|
|
91
|
+
coordinateVisible: false,
|
|
92
|
+
turnVisible: false,
|
|
93
|
+
playButtonVisible: true,
|
|
94
|
+
flipButtonVisible: false,
|
|
95
|
+
additionalButtons: [ 'button', 'button', 'spacer', 'spacer', 'button' ],
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
itInvalidArgument('Attribute not an object', () => NavigationBoard.size('not-an-object'));
|
|
99
|
+
itInvalidArgument('Square size not an integer', () => NavigationBoard.size({ squareSize: 'not-an-integer' }));
|
|
100
|
+
itInvalidArgument('Additional buttons not an array', () => NavigationBoard.size({ additionalButtons: 'not-an-array' }));
|
|
101
|
+
itInvalidArgument('Additional buttons with invalid items', () => NavigationBoard.size({ additionalButtons: [ 'not-a-button-nor-a-spacer' ] }));
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
|
|
57
105
|
function testAdaptSquareSize(expectedSquareSize, width, height, coordinateVisible, turnVisible, smallScreenLimits) {
|
|
58
106
|
|
|
59
107
|
test.value(Chessboard.adaptSquareSize(width, height, {
|
|
@@ -119,6 +167,34 @@ describe('Adapt square-size', () => {
|
|
|
119
167
|
});
|
|
120
168
|
|
|
121
169
|
|
|
170
|
+
describe('Adapt square-size (NavigationBoard)', () => {
|
|
171
|
+
|
|
172
|
+
function itAdaptSquareSize(label, width, height, attributes, expectedSquareSize) {
|
|
173
|
+
it(label, () => {
|
|
174
|
+
test.value(NavigationBoard.adaptSquareSize(width, height, attributes)).is(expectedSquareSize);
|
|
175
|
+
|
|
176
|
+
const actualSizeIncremented = NavigationBoard.size({
|
|
177
|
+
...attributes,
|
|
178
|
+
squareSize: expectedSquareSize + 1,
|
|
179
|
+
});
|
|
180
|
+
test.value(actualSizeIncremented.width > width || actualSizeIncremented.height > height).isTrue();
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
itAdaptSquareSize('Size 300x300 (default)', 300, 300, {}, 32);
|
|
185
|
+
itAdaptSquareSize('Size 136x200 (with play button)', 136, 200, { coordinateVisible: false, turnVisible: false, playButtonVisible: true }, 15);
|
|
186
|
+
itAdaptSquareSize('Size 136x200 (with minimal buttons)', 136, 200, { coordinateVisible: false, turnVisible: false, flipButtonVisible: false }, 17);
|
|
187
|
+
|
|
188
|
+
itInvalidArgument('Width <null>', () => NavigationBoard.adaptSquareSize(null, 400));
|
|
189
|
+
itInvalidArgument('Width not-a-number', () => NavigationBoard.adaptSquareSize('500', 400));
|
|
190
|
+
itInvalidArgument('Height <undefined>', () => NavigationBoard.adaptSquareSize(500, undefined));
|
|
191
|
+
itInvalidArgument('Height object', () => NavigationBoard.adaptSquareSize(500, {}));
|
|
192
|
+
itInvalidArgument('Attribute not-an-object', () => NavigationBoard.adaptSquareSize(500, 400, 'not-an-object'));
|
|
193
|
+
itInvalidArgument('Additional buttons not an array', () => NavigationBoard.adaptSquareSize(500, 400, { additionalButtons: 'not-an-array' }));
|
|
194
|
+
itInvalidArgument('Small-screen limits not-an-array', () => NavigationBoard.adaptSquareSize(500, 400, { smallScreenLimits: 'not-an-array' }));
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
|
|
122
198
|
describe('Adapt square-size with small-screen limits', () => {
|
|
123
199
|
|
|
124
200
|
const limits = [
|
|
@@ -135,6 +211,8 @@ describe('Adapt square-size with small-screen limits', () => {
|
|
|
135
211
|
delete global.window;
|
|
136
212
|
});
|
|
137
213
|
|
|
214
|
+
/* global window */
|
|
215
|
+
|
|
138
216
|
it('Window-limited', () => {
|
|
139
217
|
window.innerWidth = 640;
|
|
140
218
|
testAdaptSquareSize(32, 9999, 9999, true, true, limits);
|
|
@@ -31,8 +31,7 @@ describeWithBrowser('Chessboard interaction', browserContext => {
|
|
|
31
31
|
itCustom(browserContext, '07_chessboard_interaction/click_squares', itemIndex, label, async element => {
|
|
32
32
|
const actions = browserContext.driver.actions({ async: true });
|
|
33
33
|
const area = await element.getRect();
|
|
34
|
-
for (
|
|
35
|
-
const target = targets[i];
|
|
34
|
+
for (const target of targets) {
|
|
36
35
|
await actions.move({ x: area.x + target.x, y: area.y + target.y }).click().perform();
|
|
37
36
|
await compareSandbox(browserContext, target.expectedText);
|
|
38
37
|
}
|
|
@@ -50,10 +50,10 @@ describeWithBrowser('Navigation board graphic', browserContext => {
|
|
|
50
50
|
function itCheckClickButton(itemIndex, label, buttons) {
|
|
51
51
|
itCustom(browserContext, '13_navigation_board_graphic/additional_buttons', itemIndex, label, async element => {
|
|
52
52
|
await setSandbox(browserContext, '');
|
|
53
|
-
for (
|
|
54
|
-
const buttonElement = await element.findElement(By.xpath(`.//div[@title='${
|
|
53
|
+
for (const button of buttons) {
|
|
54
|
+
const buttonElement = await element.findElement(By.xpath(`.//div[@title='${button.title}']`));
|
|
55
55
|
await buttonElement.click();
|
|
56
|
-
await compareSandbox(browserContext,
|
|
56
|
+
await compareSandbox(browserContext, button.expectedSandbox ?? '');
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
}
|
package/test/common/graphic.js
CHANGED
|
@@ -47,8 +47,8 @@ const AUTOPLAY_DELAY = 1000;
|
|
|
47
47
|
/**
|
|
48
48
|
* Create a Mocha test-suite that runs graphic tests in Dockerized Selenium webbrowser.
|
|
49
49
|
*/
|
|
50
|
-
exports.describeWithBrowser = function(suiteLabel, testFactory) {
|
|
51
|
-
describe(suiteLabel, function() {
|
|
50
|
+
exports.describeWithBrowser = function (suiteLabel, testFactory) {
|
|
51
|
+
describe(suiteLabel, function () {
|
|
52
52
|
|
|
53
53
|
// Fetching a new page in the browser may take a while, thus increase the timeout threshold.
|
|
54
54
|
this.timeout(10000);
|
|
@@ -147,7 +147,7 @@ async function fetchTestCase(browserContext, testCaseName) {
|
|
|
147
147
|
/**
|
|
148
148
|
* Wait until the end of the chessboard animations.
|
|
149
149
|
*/
|
|
150
|
-
const waitForAnimation = exports.waitForAnimation = async function() {
|
|
150
|
+
const waitForAnimation = exports.waitForAnimation = async function () {
|
|
151
151
|
await new Promise(resolve => setTimeout(resolve, ANIMATION_DELAY));
|
|
152
152
|
};
|
|
153
153
|
|
|
@@ -155,7 +155,7 @@ const waitForAnimation = exports.waitForAnimation = async function() {
|
|
|
155
155
|
/**
|
|
156
156
|
* Wait until the given number of moves have been auto-played.
|
|
157
157
|
*/
|
|
158
|
-
exports.waitForAutoplay = async function(nbMoves) {
|
|
158
|
+
exports.waitForAutoplay = async function (nbMoves) {
|
|
159
159
|
await new Promise(resolve => setTimeout(resolve, (nbMoves + 0.5) * AUTOPLAY_DELAY));
|
|
160
160
|
};
|
|
161
161
|
|
|
@@ -163,7 +163,7 @@ exports.waitForAutoplay = async function(nbMoves) {
|
|
|
163
163
|
/**
|
|
164
164
|
* Take a screenshot of the element identified by the given CSS target.
|
|
165
165
|
*/
|
|
166
|
-
const takeScreenshot = exports.takeScreenshot = async function(browserContext, imageBaseName, element) {
|
|
166
|
+
const takeScreenshot = exports.takeScreenshot = async function (browserContext, imageBaseName, element) {
|
|
167
167
|
|
|
168
168
|
imageBaseName = imageBaseName.replaceAll(' ', '_').toLowerCase();
|
|
169
169
|
const actualFilename = `${outputDir}/${browserContext.latestTestCase}/${imageBaseName}.png`;
|
|
@@ -178,7 +178,7 @@ const takeScreenshot = exports.takeScreenshot = async function(browserContext, i
|
|
|
178
178
|
/**
|
|
179
179
|
* Compare a screenshot to its reference.
|
|
180
180
|
*/
|
|
181
|
-
const compareScreenshot = exports.compareScreenshot = async function(browserContext, imageBaseName) {
|
|
181
|
+
const compareScreenshot = exports.compareScreenshot = async function (browserContext, imageBaseName) {
|
|
182
182
|
|
|
183
183
|
imageBaseName = imageBaseName.replaceAll(' ', '_').toLowerCase();
|
|
184
184
|
const actualFilename = `${outputDir}/${browserContext.latestTestCase}/${imageBaseName}.png`;
|
|
@@ -198,7 +198,7 @@ const compareScreenshot = exports.compareScreenshot = async function(browserCont
|
|
|
198
198
|
/**
|
|
199
199
|
* Compare content of the sandbox to the expected text.
|
|
200
200
|
*/
|
|
201
|
-
exports.compareSandbox = async function(browserContext, expectedText) {
|
|
201
|
+
exports.compareSandbox = async function (browserContext, expectedText) {
|
|
202
202
|
const actualText = await browserContext.driver.findElement(By.id('sandbox')).getText();
|
|
203
203
|
test.value(actualText).is(expectedText);
|
|
204
204
|
};
|
|
@@ -207,7 +207,7 @@ exports.compareSandbox = async function(browserContext, expectedText) {
|
|
|
207
207
|
/**
|
|
208
208
|
* Set the content of the sandbox to the given value.
|
|
209
209
|
*/
|
|
210
|
-
exports.setSandbox = async function(browserContext, value) {
|
|
210
|
+
exports.setSandbox = async function (browserContext, value) {
|
|
211
211
|
if (/[^\w \-=]/.test(value)) {
|
|
212
212
|
throw new Error('Invalid characters found in the sandox message.');
|
|
213
213
|
}
|
|
@@ -218,7 +218,7 @@ exports.setSandbox = async function(browserContext, value) {
|
|
|
218
218
|
/**
|
|
219
219
|
* Set the width of the browser.
|
|
220
220
|
*/
|
|
221
|
-
exports.setWindowWidth = async function(browserContext, width) {
|
|
221
|
+
exports.setWindowWidth = async function (browserContext, width) {
|
|
222
222
|
const { height } = await await browserContext.driver.manage().window().getRect();
|
|
223
223
|
await browserContext.driver.manage().window().setRect({ width: width, height: height });
|
|
224
224
|
};
|
|
@@ -227,7 +227,7 @@ exports.setWindowWidth = async function(browserContext, width) {
|
|
|
227
227
|
/**
|
|
228
228
|
* Open the page corresponding to the given test-case, and execute the given scenario.
|
|
229
229
|
*/
|
|
230
|
-
const itCustom = exports.itCustom = function(browserContext, testCaseName, itemIndex, itemName, scenario) {
|
|
230
|
+
const itCustom = exports.itCustom = function (browserContext, testCaseName, itemIndex, itemName, scenario) {
|
|
231
231
|
it(`${testCaseName} - ${itemName}`, async () => {
|
|
232
232
|
await fetchTestCase(browserContext, testCaseName);
|
|
233
233
|
const element = await browserContext.driver.findElement(By.id('test-item-' + itemIndex));
|
|
@@ -239,7 +239,7 @@ const itCustom = exports.itCustom = function(browserContext, testCaseName, itemI
|
|
|
239
239
|
/**
|
|
240
240
|
* Open the page corresponding to the given test-case, take a screenshot for each item, and compare them to the reference.
|
|
241
241
|
*/
|
|
242
|
-
exports.itChecksScreenshots = function(browserContext, testCaseName, itemNames) {
|
|
242
|
+
exports.itChecksScreenshots = function (browserContext, testCaseName, itemNames) {
|
|
243
243
|
for (let i = 0; i < itemNames.length; ++i) {
|
|
244
244
|
const itemName = itemNames[i];
|
|
245
245
|
itCustom(browserContext, testCaseName, i, itemName, async element => {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/test/graphic_references/05_chessboard_graphic/annotations/with_coordinates_and_flip.png
CHANGED
|
Binary file
|
|
Binary file
|
package/test/graphic_references/05_chessboard_graphic/annotations/without_coordinates_and_flip.png
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/test/graphic_references/05_chessboard_graphic/chess_variants/invalid_variant_with_fen.png
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|