@@ -304,6 +304,50 @@ def test_cannot_fetch_draft_pages(graphql_client, locale):
304304 assert response ["data" ]["cmsPage" ] is None
305305
306306
307+ def test_cannot_fetch_draft_base_page_even_if_translation_is_live (graphql_client , locale ):
308+ """
309+ Test that a draft base page cannot be fetched even if a translation exists that is live.
310+ This ensures the live=True filter is applied to the initial queryset.
311+ """
312+ parent = GenericPageFactory ()
313+ # Create a draft base page (live=False)
314+ page = GenericPageFactory (
315+ slug = "bubble-tea" ,
316+ locale = locale ("en" ),
317+ parent = parent ,
318+ title = "Bubble" ,
319+ body__0__text_section__title__value = "I've Got a Lovely Bunch of Coconuts" ,
320+ live = False ,
321+ )
322+
323+ SiteFactory (hostname = "pycon" , port = 80 , root_page = parent )
324+
325+ # Create a live Italian translation
326+ it_page = page .copy_for_translation (locale = locale ("it" ))
327+ it_page .title = "Bubble Italian"
328+ it_page .save_revision ().publish ()
329+
330+ query = """
331+ query Page ($hostname: String!, $language: String!, $slug: String!) {
332+ cmsPage(hostname: $hostname, language: $language, slug: $slug){
333+ ...on GenericPage {
334+ title
335+ slug
336+ }
337+ }
338+ }
339+ """
340+
341+ # Even though the Italian translation is live, the base page is draft
342+ # so it should not be fetchable
343+ response = graphql_client .query (
344+ query , variables = {"hostname" : "pycon" , "slug" : "bubble-tea" , "language" : "it" }
345+ )
346+
347+ assert not response .get ("errors" )
348+ assert response ["data" ]["cmsPage" ] is None
349+
350+
307351def test_page_for_unknown_locale (graphql_client , locale ):
308352 parent = GenericPageFactory ()
309353 page = GenericPageFactory (
0 commit comments