|
| 1 | +context ('Hide TextBox', function () { |
| 2 | + |
| 3 | + beforeEach (() => { |
| 4 | + cy.open (); |
| 5 | + cy.loadTestAssets (); |
| 6 | + }); |
| 7 | + |
| 8 | + it ('Hides the textbox correctly', function () { |
| 9 | + this.monogatari.debug.level (0); |
| 10 | + this.monogatari.setting ('TypeAnimation', false); |
| 11 | + this.monogatari.script ({ |
| 12 | + 'Start': [ |
| 13 | + 'One', |
| 14 | + 'hide textbox', |
| 15 | + 'show image polaroid', |
| 16 | + 'Two', |
| 17 | + 'show textbox', |
| 18 | + 'Three' |
| 19 | + ] |
| 20 | + }); |
| 21 | + |
| 22 | + cy.start (); |
| 23 | + cy.get ('text-box').should ('be.visible'); |
| 24 | + cy.get ('text-box').contains ('One'); |
| 25 | + cy.proceed (); |
| 26 | + |
| 27 | + cy.get ('text-box').should ('not.be.visible'); |
| 28 | + cy.get ('text-box').contains ('Two'); |
| 29 | + cy.get ('[data-image="polaroid"]').should ('be.visible'); |
| 30 | + |
| 31 | + cy.proceed (); |
| 32 | + |
| 33 | + cy.get ('text-box').should ('be.visible'); |
| 34 | + cy.get ('text-box').contains ('Three'); |
| 35 | + cy.wrap (this.monogatari).invoke ('state', 'textboxHidden').should ('equal', false); |
| 36 | + }); |
| 37 | + |
| 38 | + it ('Updates state correctly when hidden', function () { |
| 39 | + this.monogatari.debug.level (0); |
| 40 | + this.monogatari.setting ('TypeAnimation', false); |
| 41 | + this.monogatari.script ({ |
| 42 | + 'Start': [ |
| 43 | + 'One', |
| 44 | + 'hide textbox', |
| 45 | + 'Two' |
| 46 | + ] |
| 47 | + }); |
| 48 | + |
| 49 | + cy.start (); |
| 50 | + cy.wrap (this.monogatari).invoke ('state', 'textboxHidden').should ('equal', false); |
| 51 | + cy.get ('text-box').should ('be.visible'); |
| 52 | + cy.get ('text-box').contains ('One'); |
| 53 | + |
| 54 | + cy.proceed (); |
| 55 | + |
| 56 | + cy.wrap (this.monogatari).invoke ('state', 'textboxHidden').should ('equal', true); |
| 57 | + cy.get ('text-box').should ('not.be.visible'); |
| 58 | + }); |
| 59 | + |
| 60 | + it ('Restores textbox on rollback of hide', function () { |
| 61 | + this.monogatari.setting ('TypeAnimation', false); |
| 62 | + this.monogatari.script ({ |
| 63 | + 'Start': [ |
| 64 | + 'One', |
| 65 | + 'hide textbox', |
| 66 | + 'show image polaroid', |
| 67 | + 'show textbox', |
| 68 | + 'Two' |
| 69 | + ] |
| 70 | + }); |
| 71 | + |
| 72 | + cy.start (); |
| 73 | + cy.get ('text-box').contains ('One'); |
| 74 | + cy.proceed (); |
| 75 | + |
| 76 | + cy.get ('text-box').should ('be.visible'); |
| 77 | + cy.get ('text-box').contains ('Two'); |
| 78 | + |
| 79 | + cy.rollback (); |
| 80 | + cy.get ('text-box').should ('be.visible'); |
| 81 | + cy.get ('text-box').contains ('One'); |
| 82 | + cy.wrap (this.monogatari).invoke ('state', 'textboxHidden').should ('equal', false); |
| 83 | + }); |
| 84 | + |
| 85 | + it ('Keeps textbox hidden through non-dialog actions', function () { |
| 86 | + this.monogatari.setting ('TypeAnimation', false); |
| 87 | + this.monogatari.script ({ |
| 88 | + 'Start': [ |
| 89 | + 'hide textbox', |
| 90 | + 'show image polaroid', |
| 91 | + 'show image christmas', |
| 92 | + 'show textbox', |
| 93 | + 'One' |
| 94 | + ] |
| 95 | + }); |
| 96 | + |
| 97 | + cy.start (); |
| 98 | + |
| 99 | + cy.get ('text-box').should ('be.visible'); |
| 100 | + cy.get ('text-box').contains ('One'); |
| 101 | + cy.get ('[data-image="polaroid"]').should ('be.visible'); |
| 102 | + cy.get ('[data-image="christmas"]').should ('be.visible'); |
| 103 | + cy.wrap (this.monogatari).invoke ('state', 'textboxHidden').should ('equal', false); |
| 104 | + }); |
| 105 | + |
| 106 | + it ('Preserves hidden state after save and load', function () { |
| 107 | + this.monogatari.debug.level (0); |
| 108 | + this.monogatari.setting ('TypeAnimation', false); |
| 109 | + this.monogatari.script ({ |
| 110 | + 'Start': [ |
| 111 | + 'One', |
| 112 | + 'hide textbox', |
| 113 | + 'Two', |
| 114 | + 'show textbox', |
| 115 | + 'Three' |
| 116 | + ] |
| 117 | + }); |
| 118 | + |
| 119 | + cy.start (); |
| 120 | + cy.get ('text-box').contains ('One'); |
| 121 | + cy.proceed (); |
| 122 | + |
| 123 | + // Textbox should be hidden, save at this point |
| 124 | + cy.wrap (this.monogatari).invoke ('state', 'textboxHidden').should ('equal', true); |
| 125 | + cy.get ('text-box').should ('not.be.visible'); |
| 126 | + cy.save (1); |
| 127 | + |
| 128 | + |
| 129 | + cy.proceed (); |
| 130 | + cy.get ('text-box').should ('be.visible'); |
| 131 | + cy.get ('text-box').contains ('Three'); |
| 132 | + |
| 133 | + |
| 134 | + cy.proceed (); |
| 135 | + cy.get ('[data-component="main-menu"] [data-action="open-screen"][data-open="load"]').click (); |
| 136 | + cy.get ('[data-component="load-screen"] [data-component="save-slot"]').first ().click (); |
| 137 | + cy.get ('[data-component="game-screen"]').should ('be.visible'); |
| 138 | + |
| 139 | + cy.wrap (this.monogatari).invoke ('state', 'textboxHidden').should ('equal', true); |
| 140 | + cy.get ('text-box').should ('not.be.visible'); |
| 141 | + }); |
| 142 | + |
| 143 | + it ('Preserves visible state after save and load when textbox was shown', function () { |
| 144 | + this.monogatari.setting ('TypeAnimation', false); |
| 145 | + this.monogatari.script ({ |
| 146 | + 'Start': [ |
| 147 | + 'One', |
| 148 | + 'hide textbox', |
| 149 | + 'show textbox', |
| 150 | + 'Two', |
| 151 | + 'Three' |
| 152 | + ] |
| 153 | + }); |
| 154 | + |
| 155 | + cy.start (); |
| 156 | + cy.get ('text-box').contains ('One'); |
| 157 | + cy.proceed (); |
| 158 | + |
| 159 | + cy.get ('text-box').should ('be.visible'); |
| 160 | + cy.get ('text-box').contains ('Two'); |
| 161 | + cy.wrap (this.monogatari).invoke ('state', 'textboxHidden').should ('equal', false); |
| 162 | + cy.save (1); |
| 163 | + |
| 164 | + cy.proceed (); |
| 165 | + cy.get ('text-box').contains ('Three'); |
| 166 | + |
| 167 | + cy.proceed (); |
| 168 | + cy.get ('[data-component="main-menu"] [data-action="open-screen"][data-open="load"]').click (); |
| 169 | + cy.get ('[data-component="load-screen"] [data-component="save-slot"]').first ().click (); |
| 170 | + cy.get ('[data-component="game-screen"]').should ('be.visible'); |
| 171 | + |
| 172 | + cy.wrap (this.monogatari).invoke ('state', 'textboxHidden').should ('equal', false); |
| 173 | + cy.get ('text-box').should ('be.visible'); |
| 174 | + }); |
| 175 | + |
| 176 | + it ('Shows FancyError when dialog is shown while textbox is hidden and debug is active', function () { |
| 177 | + this.monogatari.setting ('TypeAnimation', false); |
| 178 | + this.monogatari.script ({ |
| 179 | + 'Start': [ |
| 180 | + 'One', |
| 181 | + 'hide textbox', |
| 182 | + 'Two' |
| 183 | + ] |
| 184 | + }); |
| 185 | + |
| 186 | + cy.start (); |
| 187 | + cy.get ('text-box').contains ('One'); |
| 188 | + cy.proceed (); |
| 189 | + |
| 190 | + cy.get ('.fancy-error').should ('be.visible'); |
| 191 | + }); |
| 192 | + |
| 193 | + it ('Does not show FancyError when debug level is NONE', function () { |
| 194 | + this.monogatari.debug.level (0); |
| 195 | + this.monogatari.setting ('TypeAnimation', false); |
| 196 | + this.monogatari.script ({ |
| 197 | + 'Start': [ |
| 198 | + 'One', |
| 199 | + 'hide textbox', |
| 200 | + 'Two' |
| 201 | + ] |
| 202 | + }); |
| 203 | + |
| 204 | + cy.start (); |
| 205 | + cy.get ('text-box').contains ('One'); |
| 206 | + cy.proceed (); |
| 207 | + |
| 208 | + // No FancyError should appear |
| 209 | + cy.get ('.fancy-error').should ('not.exist'); |
| 210 | + cy.wrap (this.monogatari).invoke ('state', 'textboxHidden').should ('equal', true); |
| 211 | + }); |
| 212 | + |
| 213 | + it ('Hides the textbox correctly in NVL mode', function () { |
| 214 | + cy.loadTestAssets ({ nvl: true }); |
| 215 | + this.monogatari.setting ('TypeAnimation', false); |
| 216 | + this.monogatari.script ({ |
| 217 | + 'Start': [ |
| 218 | + 'y Hello!', |
| 219 | + 'y More text', |
| 220 | + 'hide textbox', |
| 221 | + 'show image polaroid', |
| 222 | + 'show textbox', |
| 223 | + 'y Back again' |
| 224 | + ] |
| 225 | + }); |
| 226 | + |
| 227 | + cy.start (); |
| 228 | + cy.get ('text-box').should ('be.visible'); |
| 229 | + cy.wrap (this.monogatari).invoke ('element').invoke ('find', 'text-box').invoke ('get', 0).its ('props.mode').should ('equal', 'nvl'); |
| 230 | + |
| 231 | + cy.proceed (); |
| 232 | + cy.proceed (); |
| 233 | + |
| 234 | + cy.get ('text-box').should ('not.be.visible'); |
| 235 | + cy.wrap (this.monogatari).invoke ('state', 'textboxHidden').should ('equal', true); |
| 236 | + cy.get ('[data-image="polaroid"]').should ('be.visible'); |
| 237 | + |
| 238 | + cy.proceed (); |
| 239 | + |
| 240 | + cy.get ('text-box').should ('be.visible'); |
| 241 | + cy.wrap (this.monogatari).invoke ('state', 'textboxHidden').should ('equal', false); |
| 242 | + }); |
| 243 | + |
| 244 | + it ('Updates state correctly when hidden in NVL mode', function () { |
| 245 | + this.monogatari.debug.level (0); |
| 246 | + cy.loadTestAssets ({ nvl: true }); |
| 247 | + this.monogatari.setting ('TypeAnimation', false); |
| 248 | + this.monogatari.script ({ |
| 249 | + 'Start': [ |
| 250 | + 'y One', |
| 251 | + 'hide textbox', |
| 252 | + 'y Two' |
| 253 | + ] |
| 254 | + }); |
| 255 | + |
| 256 | + cy.start (); |
| 257 | + cy.wrap (this.monogatari).invoke ('state', 'textboxHidden').should ('equal', false); |
| 258 | + cy.get ('text-box').should ('be.visible'); |
| 259 | + |
| 260 | + cy.proceed (); |
| 261 | + |
| 262 | + cy.wrap (this.monogatari).invoke ('state', 'textboxHidden').should ('equal', true); |
| 263 | + cy.get ('text-box').should ('not.be.visible'); |
| 264 | + }); |
| 265 | +}); |
0 commit comments