@@ -93,6 +93,14 @@ test('"Default Stage Direction Style" section is visible', async () => {
9393 await expect ( page . locator ( '.card:has-text("Default Stage Direction Style")' ) ) . toBeVisible ( ) ;
9494} ) ;
9595
96+ test ( 'default preview uses darkslateblue before any override' , async ( ) => {
97+ // The card's example element should reflect the built-in fallback colour
98+ const preview = page
99+ . locator ( '.card:has-text("Default Stage Direction Style")' )
100+ . locator ( '.example-stage-direction' ) ;
101+ await expect ( preview ) . toHaveCSS ( 'background-color' , 'rgb(72, 61, 139)' ) ; // darkslateblue
102+ } ) ;
103+
96104test ( '"Customise" button opens the default style modal' , async ( ) => {
97105 await page
98106 . locator ( '.card:has-text("Default Stage Direction Style") button:has-text("Customise")' )
@@ -101,26 +109,73 @@ test('"Customise" button opens the default style modal', async () => {
101109 await expect ( page . locator ( '#default-bg-colour-input' ) ) . toBeVisible ( ) ;
102110} ) ;
103111
104- test ( 'setting a custom background colour saves and shows Reset button ' , async ( ) => {
112+ test ( 'setting a custom background colour saves and updates the card preview ' , async ( ) => {
105113 await page . locator ( '#default-bg-colour-input' ) . fill ( '#FF0000' ) ;
106114 await confirmModal ( page ) ;
107115 await waitForModalClosed ( page ) ;
116+ // Reset button appears (verifies PATCH /api/v1/user/settings was persisted)
117+ await expect (
118+ page . locator (
119+ '.card:has-text("Default Stage Direction Style") button:has-text("Reset to Default")'
120+ )
121+ ) . toBeVisible ( { timeout : 5_000 } ) ;
122+ // Card preview reflects saved colour (verifies WS GET_USER_SETTINGS sync updated the store)
123+ const preview = page
124+ . locator ( '.card:has-text("Default Stage Direction Style")' )
125+ . locator ( '.example-stage-direction' ) ;
126+ await expect ( preview ) . toHaveCSS ( 'background-color' , 'rgb(255, 0, 0)' ) ;
127+ } ) ;
128+
129+ test ( 'custom colour persists after page reload' , async ( ) => {
130+ await page . reload ( ) ;
131+ await waitForAppReady ( page ) ;
132+ await page . click ( '.nav-link:has-text("Stage Direction")' ) ;
133+ await expect ( page . locator ( '#stage-directions-table' ) ) . toBeVisible ( { timeout : 5_000 } ) ;
134+ // Reset button should still be present (colour was persisted to DB via GET /api/v1/user/settings)
108135 await expect (
109136 page . locator (
110137 '.card:has-text("Default Stage Direction Style") button:has-text("Reset to Default")'
111138 )
112139 ) . toBeVisible ( { timeout : 5_000 } ) ;
140+ const preview = page
141+ . locator ( '.card:has-text("Default Stage Direction Style")' )
142+ . locator ( '.example-stage-direction' ) ;
143+ await expect ( preview ) . toHaveCSS ( 'background-color' , 'rgb(255, 0, 0)' ) ;
144+ } ) ;
145+
146+ test ( 'text colour override can be enabled and saved' , async ( ) => {
147+ await page
148+ . locator ( '.card:has-text("Default Stage Direction Style") button:has-text("Customise")' )
149+ . click ( ) ;
150+ await waitForModal ( page , 'Customise Default Stage Direction Style' ) ;
151+ // Enable text colour override
152+ await page . locator ( '.modal.show' ) . getByText ( 'Override text colour' ) . click ( ) ;
153+ await expect ( page . locator ( '#default-text-colour-input' ) ) . toBeVisible ( ) ;
154+ await page . locator ( '#default-text-colour-input' ) . fill ( '#FFFFFF' ) ;
155+ await confirmModal ( page ) ;
156+ await waitForModalClosed ( page ) ;
157+ // Preview text colour should update (white text on red background)
158+ const preview = page
159+ . locator ( '.card:has-text("Default Stage Direction Style")' )
160+ . locator ( '.example-stage-direction' ) ;
161+ await expect ( preview ) . toHaveCSS ( 'color' , 'rgb(255, 255, 255)' , { timeout : 5_000 } ) ;
113162} ) ;
114163
115- test ( '"Reset to Default" removes the custom style ' , async ( ) => {
164+ test ( '"Reset to Default" removes both colour overrides ' , async ( ) => {
116165 await page
117166 . locator ( '.card:has-text("Default Stage Direction Style") button:has-text("Reset to Default")' )
118167 . click ( ) ;
168+ // Reset button disappears once both overrides are cleared
119169 await expect (
120170 page . locator (
121171 '.card:has-text("Default Stage Direction Style") button:has-text("Reset to Default")'
122172 )
123173 ) . not . toBeVisible ( { timeout : 5_000 } ) ;
174+ // Preview reverts to darkslateblue
175+ const preview = page
176+ . locator ( '.card:has-text("Default Stage Direction Style")' )
177+ . locator ( '.example-stage-direction' ) ;
178+ await expect ( preview ) . toHaveCSS ( 'background-color' , 'rgb(72, 61, 139)' , { timeout : 5_000 } ) ;
124179} ) ;
125180
126181test ( '"New Override" button is enabled when stage direction styles exist' , async ( ) => {
0 commit comments