Content Testing and Context.Site
A quick blog post about Content Testing feature of Sitecore and its unfriendliness towards
Context.Site
I went through a few content testing scenarios recently and one thing really puzzled me: Content Testing dialogs stumble upon Context.Site
.
Reference Storefront
If you try to set up a test in the Sitecore Commerce reference storefront and send the page through the workflow, here’s how the variants screenshots will look like:
The base controller is using Context.Site
for view path resolution:
1 | protected string GetRenderingView(string renderingViewName = null) |
And it won’t find anything in the shell
site:
1 | Nested Exception |
Habitat
Trying the same workflow with test in Habitat stumbles upon the validation step:
Here the Context.Site
is being used for custom dictionary functionality:
1 | private Item GetDictionaryRoot(SiteContext site) |
And it also errors out in shell
:
1 | Nested Exception |
Just in case you wondered, Preview.ResolveSite
doesn’t help.
Conclusion
Alistair Deneys explained that Content Testing needs to run screenshot generation in context of shell
to render unpublished content of different versions.
Content Testing needs to quickly learn how to do everything it needs in the context of the current site while getting everything from the
master
database.
While you probably shouldn’t use Context.Site
for view path resolution - we now have official support for MVC areas, and probably shouldn’t use custom dictionary implementation - here’s my blog post on how to make standard dictionary items editable in Experience Editor, you should be allowed to use Context.Site
in your page rendering logic if you need it.
Content Testing and Context.Site