diff --git a/make_post_sell/templates/home.j2 b/make_post_sell/templates/home.j2 index d114072..bd77159 100644 --- a/make_post_sell/templates/home.j2 +++ b/make_post_sell/templates/home.j2 @@ -25,9 +25,9 @@ {% else %} -
Create your own shop and start selling digital products in minutes.
+ Get Started {% endif %} diff --git a/make_post_sell/tests/test_functional.py b/make_post_sell/tests/test_functional.py index 97847e0..07b5924 100644 --- a/make_post_sell/tests/test_functional.py +++ b/make_post_sell/tests/test_functional.py @@ -98,9 +98,17 @@ class FunctionalTests(unittest.TestCase): class UnauthenticatedFunctionalTests(FunctionalTests): def test_root_home_page(self): res = self.testapp.get("/", status=200) - self.assertIn(b"log in", res.body) + self.assertIn(b"Get Started", res.body) self.assertIn(b"Cart $0.00 (0)", res.body) + def test_root_home_page_landing_content(self): + """Anonymous visitors see the MPS landing with tagline and signup CTA.""" + res = self.testapp.get("/", status=200) + body = res.body.decode() + self.assertIn("Make. Post. Sell.", body) + self.assertIn("start selling digital products", body) + self.assertIn("/join-or-log-in", body) + def test_new_product_redirects(self): redirect_res = self.testapp.get("/p/new", status=302) res = redirect_res.follow() @@ -303,6 +311,33 @@ class AuthenticatedFunctionalTests(FunctionalTests): res = redirect_res.follow() self.assertIn(b"You must have a shop editor role to access that.", res.body) + def test_home_redirects_to_new_shop_when_no_shop(self): + """Authenticated user with no shop redirects from / to /s/new.""" + self.log_in_user(self.user2_creds) + res = self.testapp.get("/", status=302) + self.assertIn("/s/new", res.location) + + def test_home_no_redirect_when_user_has_shop(self): + """Authenticated user with a shop sees the home page, no redirect.""" + self._create_shop_helper() + res = self.testapp.get("/", status=200) + # Should render the shop home, not the "no shop" landing + self.assertNotIn(b"You don't have any shops", res.body) + + def test_home_shows_flash_instead_of_redirect(self): + """When a flash message is pending, home renders instead of redirecting. + + This ensures flash messages from other views (e.g. shop_editor_required) + are displayed rather than lost in a redirect chain. + """ + self.log_in_user(self.user2_creds) + # /p/new without a shop queues a flash and redirects to / + redirect_res = self.testapp.get("/p/new", status=302) + # Following should render home with the flash, not redirect again + res = redirect_res.follow() + self.assertEqual(res.status_int, 200) + self.assertIn(b"You must have a shop editor role", res.body) + def _create_shop_helper( self, user_creds=None, shop_params=None, log_out_user=False ): diff --git a/make_post_sell/views/shop.py b/make_post_sell/views/shop.py index 1c8be39..7da932c 100644 --- a/make_post_sell/views/shop.py +++ b/make_post_sell/views/shop.py @@ -74,6 +74,10 @@ def get_shop_from_matchdict(request, prefetched_shop=None): @view_config(route_name="home", renderer="home.j2") def home(request): + if request.is_saas_domain and request.user and request.user.authenticated: + if not request.shop and not request.user.active_shop: + if not request.session.peek_flash(): + return HTTPFound("/s/new") products = None if request.shop: products = get_products_from_a_shop(request.shop)