@@ -137,15 +137,16 @@ Cypress.Commands.add('getLastPost', () => {
137
137
} ) ;
138
138
139
139
Cypress . Commands . add ( 'getLastPostId' , ( opts = { force : false } ) => {
140
- cy . get ( '#postListContent #postContent' , { timeout : 30000 } ) . last ( ) . parent ( ) . as ( '_lastPost' ) ;
140
+ cy . get ( '#postListContent #postContent' , { timeout : 30000 } ) .
141
+ last ( ) .
142
+ parent ( ) . as ( 'parent' ) ;
141
143
142
- if ( ! opts . force ) {
143
- cy . get ( '@_lastPost' ) . should ( 'have.attr' , 'id' ) . and ( 'not.include' , ':' ) ;
144
+ if ( opts . force ) {
145
+ cy . get ( '@parent' ) . should ( 'have.attr' , 'id' ) . invoke ( 'replace' , 'post_' , '' ) ;
146
+ } else {
147
+ cy . get ( '@parent' ) . should ( 'have.attr' , 'id' ) . and ( 'not.include' , ':' ) .
148
+ invoke ( 'replace' , 'post_' , '' ) ;
144
149
}
145
-
146
- return cy . get ( '@_lastPost' ) . invoke ( 'attr' , 'id' ) . then ( ( divPostId ) => {
147
- return divPostId . replace ( 'post_' , '' ) ;
148
- } ) ;
149
150
} ) ;
150
151
151
152
/**
@@ -182,9 +183,7 @@ Cypress.Commands.add('compareLastPostHTMLContentFromFile', (file) => {
182
183
const postMessageTextId = `#postMessageText_${ postId } ` ;
183
184
184
185
cy . fixture ( file , 'utf-8' ) . then ( ( expectedHtml ) => {
185
- cy . get ( postMessageTextId ) . then ( ( content ) => {
186
- assert . equal ( content [ 0 ] . innerHTML , expectedHtml . replace ( / \n $ / , '' ) ) ;
187
- } ) ;
186
+ cy . get ( postMessageTextId , { timeout : 150000 } ) . should ( 'have.html' , expectedHtml . replace ( / \n $ / , '' ) ) ;
188
187
} ) ;
189
188
} ) ;
190
189
} ) ;
0 commit comments