@@ -75,23 +75,23 @@ describe('Words Management', () => {
7575 } ) ;
7676
7777 describe ( 'Single Word Edit' , ( ) => {
78- // Note: Word editing from the list uses /words/edit?chg=X
78+ // Note: Word editing from the list uses /words/X/edit RESTful route
7979 // The /word/edit endpoint is for editing from within reading context
8080 // These tests verify editing works when a word exists in the database
8181
8282 it ( 'should load word edit page when word exists' , ( ) => {
8383 cy . visit ( '/words/edit' ) ;
8484 cy . get ( 'body' ) . then ( ( $body ) => {
85- if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="chg= "]' ) . length > 0 ) {
86- cy . get ( 'a[href*="chg= "]' )
85+ if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="/edit "]' ) . length > 0 ) {
86+ cy . get ( 'a[href*="/edit "]' )
8787 . first ( )
8888 . then ( ( $link ) => {
8989 const href = $link . attr ( 'href' ) ;
9090 if ( href ) {
91- const match = href . match ( / c h g = ( \d + ) / ) ;
91+ const match = href . match ( / \/ w o r d s \/ ( \d + ) \/ e d i t / ) ;
9292 if ( match ) {
9393 const wordId = match [ 1 ] ;
94- cy . visit ( `/words/edit?chg= ${ wordId } ` ) ;
94+ cy . visit ( `/words/${ wordId } /edit ` ) ;
9595 cy . get ( 'form' ) . should ( 'exist' ) ;
9696 }
9797 }
@@ -105,15 +105,15 @@ describe('Words Management', () => {
105105 it ( 'should have word text field when editing' , ( ) => {
106106 cy . visit ( '/words/edit' ) ;
107107 cy . get ( 'body' ) . then ( ( $body ) => {
108- if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="chg= "]' ) . length > 0 ) {
109- cy . get ( 'a[href*="chg= "]' )
108+ if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="/edit "]' ) . length > 0 ) {
109+ cy . get ( 'a[href*="/edit "]' )
110110 . first ( )
111111 . then ( ( $link ) => {
112112 const href = $link . attr ( 'href' ) ;
113113 if ( href ) {
114- const match = href . match ( / c h g = ( \d + ) / ) ;
114+ const match = href . match ( / \/ w o r d s \/ ( \d + ) \/ e d i t / ) ;
115115 if ( match ) {
116- cy . visit ( `/words/edit?chg= ${ match [ 1 ] } ` ) ;
116+ cy . visit ( `/words/${ match [ 1 ] } /edit ` ) ;
117117 cy . get ( 'input[name="WoText"]' ) . should ( 'exist' ) ;
118118 }
119119 }
@@ -127,15 +127,15 @@ describe('Words Management', () => {
127127 it ( 'should have translation field when editing' , ( ) => {
128128 cy . visit ( '/words/edit' ) ;
129129 cy . get ( 'body' ) . then ( ( $body ) => {
130- if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="chg= "]' ) . length > 0 ) {
131- cy . get ( 'a[href*="chg= "]' )
130+ if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="/edit "]' ) . length > 0 ) {
131+ cy . get ( 'a[href*="/edit "]' )
132132 . first ( )
133133 . then ( ( $link ) => {
134134 const href = $link . attr ( 'href' ) ;
135135 if ( href ) {
136- const match = href . match ( / c h g = ( \d + ) / ) ;
136+ const match = href . match ( / \/ w o r d s \/ ( \d + ) \/ e d i t / ) ;
137137 if ( match ) {
138- cy . visit ( `/words/edit?chg= ${ match [ 1 ] } ` ) ;
138+ cy . visit ( `/words/${ match [ 1 ] } /edit ` ) ;
139139 cy . get ( 'textarea[name="WoTranslation"]' ) . should ( 'exist' ) ;
140140 }
141141 }
@@ -149,15 +149,15 @@ describe('Words Management', () => {
149149 it ( 'should have status selector when editing' , ( ) => {
150150 cy . visit ( '/words/edit' ) ;
151151 cy . get ( 'body' ) . then ( ( $body ) => {
152- if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="chg= "]' ) . length > 0 ) {
153- cy . get ( 'a[href*="chg= "]' )
152+ if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="/edit "]' ) . length > 0 ) {
153+ cy . get ( 'a[href*="/edit "]' )
154154 . first ( )
155155 . then ( ( $link ) => {
156156 const href = $link . attr ( 'href' ) ;
157157 if ( href ) {
158- const match = href . match ( / c h g = ( \d + ) / ) ;
158+ const match = href . match ( / \/ w o r d s \/ ( \d + ) \/ e d i t / ) ;
159159 if ( match ) {
160- cy . visit ( `/words/edit?chg= ${ match [ 1 ] } ` ) ;
160+ cy . visit ( `/words/${ match [ 1 ] } /edit ` ) ;
161161 cy . get ( 'input[type="radio"][name="WoStatus"]' ) . should ( 'exist' ) ;
162162 }
163163 }
@@ -171,15 +171,15 @@ describe('Words Management', () => {
171171 it ( 'should have submit button when editing' , ( ) => {
172172 cy . visit ( '/words/edit' ) ;
173173 cy . get ( 'body' ) . then ( ( $body ) => {
174- if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="chg= "]' ) . length > 0 ) {
175- cy . get ( 'a[href*="chg= "]' )
174+ if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="/edit "]' ) . length > 0 ) {
175+ cy . get ( 'a[href*="/edit "]' )
176176 . first ( )
177177 . then ( ( $link ) => {
178178 const href = $link . attr ( 'href' ) ;
179179 if ( href ) {
180- const match = href . match ( / c h g = ( \d + ) / ) ;
180+ const match = href . match ( / \/ w o r d s \/ ( \d + ) \/ e d i t / ) ;
181181 if ( match ) {
182- cy . visit ( `/words/edit?chg= ${ match [ 1 ] } ` ) ;
182+ cy . visit ( `/words/${ match [ 1 ] } /edit ` ) ;
183183 cy . get ( 'input[type="submit"][value="Change"]' ) . should ( 'exist' ) ;
184184 }
185185 }
@@ -195,15 +195,15 @@ describe('Words Management', () => {
195195 it ( 'should be able to change word status when words exist' , ( ) => {
196196 cy . visit ( '/words/edit' ) ;
197197 cy . get ( 'body' ) . then ( ( $body ) => {
198- if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="chg= "]' ) . length > 0 ) {
199- cy . get ( 'a[href*="chg= "]' )
198+ if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="/edit "]' ) . length > 0 ) {
199+ cy . get ( 'a[href*="/edit "]' )
200200 . first ( )
201201 . then ( ( $link ) => {
202202 const href = $link . attr ( 'href' ) ;
203203 if ( href ) {
204- const match = href . match ( / c h g = ( \d + ) / ) ;
204+ const match = href . match ( / \/ w o r d s \/ ( \d + ) \/ e d i t / ) ;
205205 if ( match ) {
206- cy . visit ( `/words/edit?chg= ${ match [ 1 ] } ` ) ;
206+ cy . visit ( `/words/${ match [ 1 ] } /edit ` ) ;
207207 cy . get ( 'input[type="radio"][name="WoStatus"]' ) . should (
208208 'have.length.greaterThan' ,
209209 0
@@ -222,15 +222,15 @@ describe('Words Management', () => {
222222 it ( 'should have lemma field when editing a word' , ( ) => {
223223 cy . visit ( '/words/edit' ) ;
224224 cy . get ( 'body' ) . then ( ( $body ) => {
225- if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="chg= "]' ) . length > 0 ) {
226- cy . get ( 'a[href*="chg= "]' )
225+ if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="/edit "]' ) . length > 0 ) {
226+ cy . get ( 'a[href*="/edit "]' )
227227 . first ( )
228228 . then ( ( $link ) => {
229229 const href = $link . attr ( 'href' ) ;
230230 if ( href ) {
231- const match = href . match ( / c h g = ( \d + ) / ) ;
231+ const match = href . match ( / \/ w o r d s \/ ( \d + ) \/ e d i t / ) ;
232232 if ( match ) {
233- cy . visit ( `/words/edit?chg= ${ match [ 1 ] } ` ) ;
233+ cy . visit ( `/words/${ match [ 1 ] } /edit ` ) ;
234234 cy . get ( 'input[name="WoLemma"]' ) . should ( 'exist' ) ;
235235 }
236236 }
@@ -244,15 +244,15 @@ describe('Words Management', () => {
244244 it ( 'should have placeholder text for lemma field' , ( ) => {
245245 cy . visit ( '/words/edit' ) ;
246246 cy . get ( 'body' ) . then ( ( $body ) => {
247- if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="chg= "]' ) . length > 0 ) {
248- cy . get ( 'a[href*="chg= "]' )
247+ if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="/edit "]' ) . length > 0 ) {
248+ cy . get ( 'a[href*="/edit "]' )
249249 . first ( )
250250 . then ( ( $link ) => {
251251 const href = $link . attr ( 'href' ) ;
252252 if ( href ) {
253- const match = href . match ( / c h g = ( \d + ) / ) ;
253+ const match = href . match ( / \/ w o r d s \/ ( \d + ) \/ e d i t / ) ;
254254 if ( match ) {
255- cy . visit ( `/words/edit?chg= ${ match [ 1 ] } ` ) ;
255+ cy . visit ( `/words/${ match [ 1 ] } /edit ` ) ;
256256 cy . get ( 'input[name="WoLemma"]' )
257257 . should ( 'have.attr' , 'placeholder' )
258258 . and ( 'include' , 'Base form' ) ;
@@ -268,15 +268,15 @@ describe('Words Management', () => {
268268 it ( 'should allow entering a lemma value' , ( ) => {
269269 cy . visit ( '/words/edit' ) ;
270270 cy . get ( 'body' ) . then ( ( $body ) => {
271- if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="chg= "]' ) . length > 0 ) {
272- cy . get ( 'a[href*="chg= "]' )
271+ if ( ! $body . text ( ) . includes ( 'No terms found' ) && $body . find ( 'a[href*="/edit "]' ) . length > 0 ) {
272+ cy . get ( 'a[href*="/edit "]' )
273273 . first ( )
274274 . then ( ( $link ) => {
275275 const href = $link . attr ( 'href' ) ;
276276 if ( href ) {
277- const match = href . match ( / c h g = ( \d + ) / ) ;
277+ const match = href . match ( / \/ w o r d s \/ ( \d + ) \/ e d i t / ) ;
278278 if ( match ) {
279- cy . visit ( `/words/edit?chg= ${ match [ 1 ] } ` ) ;
279+ cy . visit ( `/words/${ match [ 1 ] } /edit ` ) ;
280280 cy . get ( 'input[name="WoLemma"]' )
281281 . clear ( )
282282 . type ( 'testlemma' )
0 commit comments