@@ -173,34 +173,6 @@ describe('HTTP cache tests', () => {
173173 } )
174174 } )
175175
176- const getIframeDocument = ( ) => {
177- return (
178- cy
179- . get ( 'iframe.panel-html' )
180- // Cypress yields jQuery element, which has the real
181- // DOM element under property "0".
182- // From the real DOM iframe element we can get
183- // the "document" element, it is stored in "contentDocument" property
184- // Cypress "its" command can access deep properties using dot notation
185- // https://on.cypress.io/its
186- . its ( '0.contentDocument' )
187- . should ( 'exist' )
188- )
189- }
190-
191- const getIframeBody = ( ) => {
192- // get the document
193- return (
194- getIframeDocument ( )
195- // automatically retries until body is loaded
196- . its ( 'body' )
197- . should ( 'not.be.undefined' )
198- // wraps "body" DOM element to allow
199- // chaining more Cypress commands, like ".find(...)"
200- . then ( cy . wrap )
201- )
202- }
203-
204176 it ( 'invalidates cached data when user leaves a camp' , ( ) => {
205177 Cypress . session . clearAllSavedSessions ( )
206178 const uri = '/api/camps/3c79b99ab424/categories'
@@ -231,11 +203,10 @@ describe('HTTP cache tests', () => {
231203 } )
232204
233205 // delete old emails
234- cy . visit ( 'localhost:3000/mail' )
235- cy . get ( 'a[title="Delete all emails"]' ) . click ( )
236- /* eslint-disable cypress/no-unnecessary-waiting */
237- cy . wait ( 50 )
238- cy . get ( 'a[title="Delete all emails"]' ) . click ( )
206+ cy . request ( {
207+ url : 'localhost:3000/mail/email/all' ,
208+ method : 'DELETE' ,
209+ } )
239210
240211 // invite Castor
241212 cy . login ( 'test@example.com' )
@@ -246,22 +217,22 @@ describe('HTTP cache tests', () => {
246217
247218 // accept invitation as Castor
248219 cy . login ( 'castor@example.com' )
249- cy . visit ( 'localhost:3000/mail' )
250- cy . get ( 'a' )
251- . contains ( '[eCamp v3] Du wurdest ins Lager "Pfila 2023" eingeladen' )
252- . click ( )
253- /* eslint-disable cypress/no-unnecessary-waiting */
254- cy . wait ( 200 )
255- getIframeBody ( )
256- . find ( 'a' )
257- . then ( ( $a ) => {
258- const href = $a . prop ( 'href' )
259- cy . visit ( href )
260- cy . get ( 'button' ) . contains ( 'Einladung mit aktuellem Account akzeptieren' ) . click ( )
261- cy . wait ( '@invitations' )
262- cy . visit ( '/camps' )
263- cy . contains ( 'GRGR' )
220+
221+ cy . request ( {
222+ url : 'localhost:3000/mail/email' ,
223+ } ) . then ( ( response ) => {
224+ const emailHtmlContent = response . body [ 0 ] . html
225+ cy . document ( ) . then ( ( document ) => {
226+ document . documentElement . innerHTML = emailHtmlContent
264227 } )
228+
229+ cy . get ( 'a:contains("Einladung beantworten")' ) . invoke ( 'removeAttr' , 'target' ) . click ( )
230+
231+ cy . get ( 'button:contains("Einladung mit aktuellem Account akzeptieren")' ) . click ( )
232+ cy . wait ( '@invitations' )
233+ cy . visit ( '/camps' )
234+ cy . contains ( 'GRGR' )
235+ } )
265236 } )
266237
267238 it ( "doesn't cache /camps" , ( ) => {
0 commit comments