1
1
/// <reference types="cypress" />
2
2
3
- const DAY_MS = 86400000 ;
4
- // March 23 2022 - initial release date
5
- const FIRST_DAY_MS = 1647993600000 ;
3
+ import { GamePersistentState } from "../../../src/game" ;
6
4
7
- describe ( "dialogs" , ( ) => {
5
+ // TODO: Implement these tests
6
+ describe . skip ( "dialogs" , ( ) => {
8
7
beforeEach ( ( ) => {
9
- // only mock the "Date" object, otherwise events that use setTimeout like dialog messages won't work
10
- // https://github.com/cypress-io/cypress/issues/7455#issuecomment-635278631
11
- cy . clock ( FIRST_DAY_MS + DAY_MS * 1 + ( DAY_MS * 1 ) / 2 , [ "Date" ] ) ;
12
- cy . intercept ( "/words.txt" , {
13
- fixture : "words.txt" ,
14
- } ) ;
15
8
cy . clearBrowserCache ( ) ;
16
9
cy . visit ( "/" , {
17
10
onBeforeLoad : ( ) => {
18
- window . localStorage . setItem ( "played_before" , true ) ;
11
+ const persistentState : GamePersistentState = {
12
+ highscore : 0 ,
13
+ unlockables : { } ,
14
+ hasPlayedBefore : true ,
15
+ } ;
16
+ window . localStorage . setItem ( "persistent-state" , JSON . stringify ( persistentState ) ) ;
19
17
} ,
20
18
} ) ;
21
- cy . waitForGameReady ( ) ;
22
19
23
- // The How to Play dialog is an example of a closable dialog that can be triggered in normal usage
24
- cy . get ( ".help-link " ) . click ( ) ;
20
+ // The Debug dialog is an example of a closable dialog that can be triggered in normal usage (during debug mode)
21
+ cy . get ( "button#debug " ) . click ( ) ;
25
22
} ) ;
26
23
27
24
describe ( "general dialog behaviour" , ( ) => {
@@ -30,53 +27,17 @@ describe("dialogs", () => {
30
27
cy . get ( ".overlay-back" ) . should ( "be.visible" ) ;
31
28
} ) ;
32
29
33
- [
34
- {
35
- name : "backspace" ,
36
- input : "backspace" ,
37
- } ,
38
- {
39
- name : "f key" ,
40
- input : "f" ,
41
- } ,
42
- {
43
- name : "enter key" ,
44
- input : "enter" ,
45
- } ,
46
- ] . forEach ( ( def ) => {
47
- it ( `prevents inputs from being made on touch keyboard - case '${ def . name } '` , ( done ) => {
48
- cy . keyboardItem ( def . input ) . shouldNotBeActionable ( done ) ;
49
- } ) ;
50
- } ) ;
51
-
52
30
it ( "prevents player from making any more inputs with physical keyboard" , ( ) => {
53
- for ( let i = 1 ; i <= 6 ; i ++ ) {
54
- cy . inputRowShouldBeEmpty ( i ) ;
55
- }
56
-
57
- cy . get ( "body" ) . type ( "{backspace}" ) ;
58
-
59
- for ( let i = 1 ; i <= 6 ; i ++ ) {
60
- cy . inputRowShouldBeEmpty ( i ) ;
61
- }
31
+ // TODO: Verify the game board at this point
62
32
63
- cy . get ( "body" ) . type ( "f" ) ;
33
+ cy . get ( "body" ) . type ( "{rightArrow}" ) ;
34
+ cy . get ( "body" ) . type ( "{downArrow}" ) ;
35
+ cy . get ( "body" ) . type ( "{leftArrow}" ) ;
36
+ cy . get ( "body" ) . type ( "{upArrow}" ) ;
64
37
65
- for ( let i = 1 ; i <= 6 ; i ++ ) {
66
- cy . inputRowShouldBeEmpty ( i ) ;
67
- }
38
+ // TODO: Verify the game board did not change
68
39
69
- cy . inputRow ( 1 ) . should ( "have.id" , "current-input" ) ;
70
- cy . inputRow ( 2 ) . should ( "not.have.id" , "current-input" ) ;
71
-
72
- cy . get ( "body" ) . type ( "{enter}" ) ;
73
-
74
- for ( let i = 1 ; i <= 6 ; i ++ ) {
75
- cy . inputRowShouldBeEmpty ( i ) ;
76
- }
77
-
78
- cy . inputRow ( 1 ) . should ( "have.id" , "current-input" ) ;
79
- cy . inputRow ( 2 ) . should ( "not.have.id" , "current-input" ) ;
40
+ throw new Error ( "TODO: Verify the game board did not change after doing some inputs" ) ;
80
41
} ) ;
81
42
82
43
// NTS: If dialog does not appear on the screen for some reason, which should never happen anyway under normal operation, then player can make physical key inputs.
@@ -98,32 +59,34 @@ describe("dialogs", () => {
98
59
cy . get ( ".dialog" ) . should ( "be.visible" ) ;
99
60
cy . get ( ".overlay-back" ) . should ( "be.visible" ) ;
100
61
101
- cy . get ( "body" ) . click ( {
102
- position : "left" ,
103
- } ) ;
62
+ cy . get ( "body" ) . click ( "left" ) ;
104
63
105
64
cy . get ( ".dialog" ) . should ( "not.exist" ) ;
106
65
cy . get ( ".overlay-back" ) . should ( "not.be.visible" ) ;
107
66
} ) ;
108
67
109
68
it ( "allows inputs to be made again after closing" , ( ) => {
110
- cy . get ( "body" ) . type ( "b" ) ;
69
+ // TODO: Verify the game board at this point
111
70
112
- for ( let i = 1 ; i <= 6 ; i ++ ) {
113
- cy . inputRowShouldBeEmpty ( i ) ;
114
- }
71
+ cy . get ( "body" ) . type ( "{rightArrow}" ) ;
72
+ cy . get ( "body" ) . type ( "{downArrow}" ) ;
73
+ cy . get ( "body" ) . type ( "{leftArrow}" ) ;
74
+ cy . get ( "body" ) . type ( "{upArrow}" ) ;
75
+
76
+ // TODO: Verify the game board did not change
115
77
116
78
cy . get ( ".dialog > .close" ) . click ( ) ;
117
79
118
- cy . get ( "body" ) . type ( "b" ) ;
80
+ // TODO: Verify the game board at this point
81
+
82
+ cy . get ( "body" ) . type ( "{rightArrow}" ) ;
83
+ cy . get ( "body" ) . type ( "{downArrow}" ) ;
84
+ cy . get ( "body" ) . type ( "{leftArrow}" ) ;
85
+ cy . get ( "body" ) . type ( "{upArrow}" ) ;
119
86
120
- cy . inputRow ( 1 ) . inputCell ( 1 ) . inputLetter ( ) . should ( "have.text" , "b" ) ;
121
- for ( let i = 2 ; i <= 5 ; i ++ ) {
122
- cy . inputRow ( 1 ) . inputCell ( i ) . inputLetter ( ) . should ( "be.empty" ) ;
123
- }
124
- for ( let i = 2 ; i <= 6 ; i ++ ) {
125
- cy . inputRowShouldBeEmpty ( i ) ;
126
- }
87
+ // TODO: Verify the game board did change
88
+
89
+ throw new Error ( "TODO: Verify the game board did change after closing" ) ;
127
90
} ) ;
128
91
129
92
it ( "can be closed by pressing enter key" , ( ) => {
@@ -171,9 +134,7 @@ describe("dialogs", () => {
171
134
it ( "can not be closed by clicking elsewhere besides the dialog" , ( ) => {
172
135
cy . get ( ".dialog" ) . should ( "be.visible" ) ;
173
136
174
- cy . get ( "body" ) . click ( {
175
- position : "left" ,
176
- } ) ;
137
+ cy . get ( "body" ) . click ( "left" ) ;
177
138
178
139
cy . get ( ".dialog" ) . should ( "be.visible" ) ;
179
140
} ) ;
0 commit comments