33from django .contrib .auth .models import User
44from django .test import TestCase
55from django .urls import reverse
6- from unittest import skipIf
76from wagtail .models import Page
87
98from experiments .models import Experiment , ExperimentHistory
@@ -210,27 +209,21 @@ def test_draft_status(self):
210209 self .client .get ('/signup-complete/' )
211210 self .assertEqual (ExperimentHistory .objects .filter (experiment = self .experiment ).count (), 0 )
212211
213- def test_alternative_title_is_used (self ):
214- self .experiment .status = 'completed'
215- self .experiment .winning_variation = self .homepage_alternative_2
216- self .experiment .save ()
217-
212+ def test_original_title_is_preserved (self ):
218213 session = self .client .session
219- session ['experiment_user_id' ] = '33333333-3333-3333-3333-333333333333 '
214+ session ['experiment_user_id' ] = '11111111-1111-1111-1111-111111111111 '
220215 session .save ()
216+ response = self .client .get ('/' )
217+ self .assertContains (response , "<title>Home</title>" )
221218
219+ # User receiving an alternative version should see the title as "Home", not "Homepage alternative 1"
220+ session .clear ()
221+ session ['experiment_user_id' ] = '33333333-3333-3333-3333-333333333333'
222+ session .save ()
222223 response = self .client .get ('/' )
223- self .assertEqual (response .status_code , 200 )
224- self .assertContains (response , 'Homepage alternative 2' )
224+ self .assertContains (response , "<title>Home</title>" )
225225
226- @skipIf (DJANGO_VERSION >= '3.2.0' , 'breadcrumbs not included in request.site' )
227226 def test_original_tree_position_is_preserved (self ):
228- '''
229- This test fails with django4 because the "request.site" no
230- longer reports the depth. Is there another way
231- to verify the original tree position is preserved?
232- '''
233-
234227 # Alternate version should position itself in the tree as if it were the control page
235228 session = self .client .session
236229 session ['experiment_user_id' ] = '33333333-3333-3333-3333-333333333333'
@@ -251,7 +244,7 @@ def test_completed_status(self):
251244 response = self .client .get ('/' )
252245
253246 self .assertEqual (response .status_code , 200 )
254- self .assertContains (response , 'Homepage alternative 2' )
247+ self .assertContains (response , "<title>Home</title>" )
255248 self .assertContains (response , "What do you want?" )
256249
257250
@@ -496,4 +489,4 @@ def test_preview(self):
496489 f'/{ self .admin_home } /experiments/experiment/report/preview/{ self .experiment .pk } /{ self .homepage_alternative_2 .pk } /'
497490 )
498491 self .assertEqual (response .status_code , 200 )
499- self .assertContains (response , '<title>Homepage alternative 2 </title>' )
492+ self .assertContains (response , '<title>Home </title>' )
0 commit comments