11import WritingAssistant from "../../src/WritingAssistant.js" ;
22
3+ import {
4+ WRITING_ASSISTANT_BUTTON_TOOLTIP ,
5+ WRITING_ASSISTANT_BUTTON_ACCESSIBLE_NAME ,
6+ WRITING_ASSISTANT_TOOLBAR_ACCESSIBLE_NAME ,
7+ WRITING_ASSISTANT_STOP_TOOLTIP ,
8+ } from "../../src/generated/i18n/i18n-defaults.js" ;
9+
310describe ( "WritingAssistant Component" , ( ) => {
411 describe ( "Initialization" , ( ) => {
512 it ( "should render with default properties" , ( ) => {
@@ -848,7 +855,7 @@ describe("WritingAssistant Component", () => {
848855 cy . get ( "[ui5-ai-writing-assistant]" )
849856 . shadow ( )
850857 . find ( "ui5-toolbar" )
851- . should ( "have.attr" , "accessible-name" , "Writing Assistant Toolbar" ) ;
858+ . should ( "have.attr" , "accessible-name" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_TOOLBAR_ACCESSIBLE_NAME ) ) ;
852859 } ) ;
853860
854861 it ( "should have translatable button accessible name" , ( ) => {
@@ -857,7 +864,7 @@ describe("WritingAssistant Component", () => {
857864 cy . get ( "[ui5-ai-writing-assistant]" )
858865 . shadow ( )
859866 . find ( "#ai-menu-btn" )
860- . should ( "have.attr" , "accessible-name" , "Writing Assistant" ) ;
867+ . should ( "have.attr" , "accessible-name" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_BUTTON_ACCESSIBLE_NAME ) ) ;
861868 } ) ;
862869
863870 it ( "should have translatable button tooltip" , ( ) => {
@@ -866,7 +873,7 @@ describe("WritingAssistant Component", () => {
866873 cy . get ( "[ui5-ai-writing-assistant]" )
867874 . shadow ( )
868875 . find ( "#ai-menu-btn" )
869- . should ( "have.attr" , "tooltip" , "Writing Assistant (Shift + F4)" ) ;
876+ . should ( "have.attr" , "tooltip" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_BUTTON_TOOLTIP ) ) ;
870877 } ) ;
871878
872879 it ( "should have stop tooltip when loading" , ( ) => {
@@ -875,7 +882,7 @@ describe("WritingAssistant Component", () => {
875882 cy . get ( "[ui5-ai-writing-assistant]" )
876883 . shadow ( )
877884 . find ( "#ai-menu-btn" )
878- . should ( "have.attr" , "tooltip" , "Stop Generating (Esc)" ) ;
885+ . should ( "have.attr" , "tooltip" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_STOP_TOOLTIP ) ) ;
879886 } ) ;
880887
881888 it ( "should change tooltip based on loading state" , ( ) => {
@@ -888,7 +895,7 @@ describe("WritingAssistant Component", () => {
888895 cy . get ( "@writingAssistant" )
889896 . shadow ( )
890897 . find ( "#ai-menu-btn" )
891- . should ( "have.attr" , "tooltip" , "Writing Assistant (Shift + F4)" ) ;
898+ . should ( "have.attr" , "tooltip" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_BUTTON_TOOLTIP ) ) ;
892899
893900 // Change to loading state
894901 cy . get ( "@writingAssistant" ) . invoke ( "prop" , "loading" , true ) ;
@@ -897,7 +904,7 @@ describe("WritingAssistant Component", () => {
897904 cy . get ( "@writingAssistant" )
898905 . shadow ( )
899906 . find ( "#ai-menu-btn" )
900- . should ( "have.attr" , "tooltip" , "Stop Generating (Esc)" ) ;
907+ . should ( "have.attr" , "tooltip" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_STOP_TOOLTIP ) ) ;
901908
902909 // Change back to non-loading state
903910 cy . get ( "@writingAssistant" ) . invoke ( "prop" , "loading" , false ) ;
@@ -906,7 +913,7 @@ describe("WritingAssistant Component", () => {
906913 cy . get ( "@writingAssistant" )
907914 . shadow ( )
908915 . find ( "#ai-menu-btn" )
909- . should ( "have.attr" , "tooltip" , "Writing Assistant (Shift + F4)" ) ;
916+ . should ( "have.attr" , "tooltip" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_BUTTON_TOOLTIP ) ) ;
910917 } ) ;
911918
912919 it ( "should maintain accessibility attributes when loading state changes" , ( ) => {
@@ -919,13 +926,13 @@ describe("WritingAssistant Component", () => {
919926 cy . get ( "@writingAssistant" )
920927 . shadow ( )
921928 . find ( "ui5-toolbar" )
922- . should ( "have.attr" , "accessible-name" , "Writing Assistant Toolbar" ) ;
929+ . should ( "have.attr" , "accessible-name" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_TOOLBAR_ACCESSIBLE_NAME ) ) ;
923930
924931 cy . get ( "@writingAssistant" )
925932 . shadow ( )
926933 . find ( "#ai-menu-btn" )
927- . should ( "have.attr" , "accessible-name" , "Writing Assistant" )
928- . should ( "have.attr" , "tooltip" , "Writing Assistant (Shift + F4)" ) ;
934+ . should ( "have.attr" , "accessible-name" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_BUTTON_ACCESSIBLE_NAME ) )
935+ . should ( "have.attr" , "tooltip" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_BUTTON_TOOLTIP ) ) ;
929936
930937 // Change to loading state
931938 cy . get ( "@writingAssistant" ) . invoke ( "prop" , "loading" , true ) ;
@@ -934,13 +941,13 @@ describe("WritingAssistant Component", () => {
934941 cy . get ( "@writingAssistant" )
935942 . shadow ( )
936943 . find ( "ui5-toolbar" )
937- . should ( "have.attr" , "accessible-name" , "Writing Assistant Toolbar" ) ;
944+ . should ( "have.attr" , "accessible-name" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_TOOLBAR_ACCESSIBLE_NAME ) ) ;
938945
939946 cy . get ( "@writingAssistant" )
940947 . shadow ( )
941948 . find ( "#ai-menu-btn" )
942- . should ( "have.attr" , "accessible-name" , "Writing Assistant" )
943- . should ( "have.attr" , "tooltip" , "Writing Assistant (Shift + F4)" ) ;
949+ . should ( "have.attr" , "accessible-name" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_BUTTON_ACCESSIBLE_NAME ) )
950+ . should ( "have.attr" , "tooltip" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_BUTTON_TOOLTIP ) ) ;
944951 } ) ;
945952
946953 it ( "should have proper accessibility attributes for different button states" , ( ) => {
@@ -951,8 +958,8 @@ describe("WritingAssistant Component", () => {
951958 . shadow ( )
952959 . find ( "#ai-menu-btn" )
953960 . should ( "have.attr" , "data-state" , "generate" )
954- . should ( "have.attr" , "accessible-name" , "Writing Assistant" )
955- . should ( "have.attr" , "tooltip" , "Writing Assistant (Shift + F4)" )
961+ . should ( "have.attr" , "accessible-name" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_BUTTON_ACCESSIBLE_NAME ) )
962+ . should ( "have.attr" , "tooltip" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_BUTTON_TOOLTIP ) )
956963 . should ( "have.attr" , "icon" , "ai" ) ;
957964
958965 // Generating state
@@ -962,8 +969,8 @@ describe("WritingAssistant Component", () => {
962969 . shadow ( )
963970 . find ( "#ai-menu-btn" )
964971 . should ( "have.attr" , "data-state" , "generating" )
965- . should ( "have.attr" , "accessible-name" , "Writing Assistant" )
966- . should ( "have.attr" , "tooltip" , "Stop Generating (Esc)" )
972+ . should ( "have.attr" , "accessible-name" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_BUTTON_ACCESSIBLE_NAME ) )
973+ . should ( "have.attr" , "tooltip" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_STOP_TOOLTIP ) )
967974 . should ( "have.attr" , "icon" , "stop" ) ;
968975 } ) ;
969976
@@ -1030,7 +1037,7 @@ describe("WritingAssistant Component", () => {
10301037 cy . get ( "[ui5-ai-writing-assistant]" )
10311038 . shadow ( )
10321039 . find ( "ui5-toolbar" )
1033- . should ( "have.attr" , "accessible-name" , "Writing Assistant Toolbar" )
1040+ . should ( "have.attr" , "accessible-name" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_TOOLBAR_ACCESSIBLE_NAME ) )
10341041 . should ( "have.attr" , "aria-roledescription" , "toolbar" ) ;
10351042
10361043 // Action text should be available for screen readers
@@ -1045,7 +1052,7 @@ describe("WritingAssistant Component", () => {
10451052 cy . get ( "[ui5-ai-writing-assistant]" )
10461053 . shadow ( )
10471054 . find ( "#ai-menu-btn" )
1048- . should ( "have.attr" , "accessible-name" , "Writing Assistant" )
1055+ . should ( "have.attr" , "accessible-name" , WritingAssistant . i18nBundleAi . getText ( WRITING_ASSISTANT_BUTTON_ACCESSIBLE_NAME ) )
10491056 . should ( "have.attr" , "data-state" , "generating" )
10501057 . should ( "have.attr" , "icon" , "stop" ) ;
10511058 } ) ;
0 commit comments