Path of Exile Wiki

Please consider helping keep the wiki up to date. Check the to-do list of updates needed for version 3.14.0.

Game data exports will becoming later as the technical changes in addition to regular changes take some more time.

READ MORE

Path of Exile Wiki
Advertisement

N27 tests failed.

Name Expected Actual
YesY testAddTrackingCategoriesDocPage
YesY testAddTrackingCategoriesInvalidTitle
YesY testAddTrackingCategoriesModuleDoc
YesY testAddTrackingCategoriesModuleTestcases
YesY testAddTrackingCategoriesTemplatePage
YesY testAddTrackingCategoriesTestcasesPage
YesY testContentArg
N testContentExists [[:Template:Documentation/testcases/test3]]
YesY testContentNoContent
YesY testDocPageBlurbError
N testDocPageBlurbModuleDocDoesntExist You might want to [//en.wikipedia.org/w/index.php?title=Module:Non-existent_module_ajlkfdsa/doc&action=edit&preload=Template%3ADocumentation%2Fpreload-module-doc create] a documentation page for this [[Wikipedia:Lua|Scribunto module]].<br /> You might want to [https://pathofexile.fandom.com/wiki/Module:Non-existent_module_ajlkfdsa/doc?action=edit&preload=Template%3ADocumentation%2Fpreload-module create] a documentation page for this [[gphelp:Extension:Scribunto|module]].<br>
N testDocPageBlurbModuleDocExists The above [[Wikipedia:Template documentation|documentation]] is [[Wikipedia:Transclusion|transcluded]] from [[Module:Bananas/doc]]. <span class="template-documentation-toolbar-link">([//en.wikipedia.org/w/index.php?title=Module:Bananas/doc&action=edit edit] &#124; [//en.wikipedia.org/w/index.php?title=Module:Bananas/doc&action=history history])</span><br /> You might want to [https://pathofexile.fandom.com/wiki/Module:Bananas/doc?action=edit&preload=Template%3ADocumentation%2Fpreload-module create] a documentation page for this [[gphelp:Extension:Scribunto|module]].<br>
N testDocPageBlurbTemplateDocDoesntExist Module:Documentation/testcases:582: Failed to assert that You might want to [https://pathofexile.fandom.com/wiki/Template:Non-existent_template_ajlkfdsa/doc?action=edit&preload=Template%3ADocumentation%2Fpreload create] a documentation page for this [[gphelp:Templates|template]].<br> equals expected nil
N testDocPageBlurbTemplateDocExists The above [[Wikipedia:Template documentation|documentation]] is [[Wikipedia:Transclusion|transcluded]] from [[Template:Documentation/doc]]. <span class="template-documentation-toolbar-link">([//en.wikipedia.org/w/index.php?title=Template:Documentation/doc&action=edit edit] &#124; [//en.wikipedia.org/w/index.php?title=Template:Documentation/doc&action=history history])</span><br /> The above [[gphelp:Templates|documentation]] is [[wikipedia:Wikipedia:Transclusion|transcluded]] from [[Template:Documentation/doc]]. <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Documentation/doc?action=edit edit] &#124; [https://pathofexile.fandom.com/wiki/Template:Documentation/doc?action=history history])</span><br>
YesY testEndBoxAlwaysShowNs
N testEndBoxCategoriesBlurb Module:Documentation/testcases:555: String type error (expected string, got nil)
N testEndBoxExperimentBlurbInvalidNs Module:Documentation/testcases:545: String type error (expected string, got nil)
N testEndBoxExperimentBlurbValidNs Module:Documentation/testcases:538: Failed to find pattern "Editors can experiment in this.-<br />" in string "<div id="documentation-meta-data" class="template-documentation__end plainlinks">

You might want to [https://pathofexile.fandom.com/wiki/Template:Example/doc?action=edit&preload=Template%3ADocumentation%2Fpreload create] a documentation page for this [[gphelp:Templates|template]].<br>Editors can experiment in this template's sandbox <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Example/sandbox?action=edit&preload=Template%3ADocumentation%2Fpreload-sandbox create] &#124; [https://pathofexile.fandom.com/wiki/Template:Example/sandbox?preload=Template%3ADocumentation%2Fmirror&action=edit&summary=Create+sandbox+version+of+%5B%5BTemplate%3AExample%5D%5D mirror])</span> and testcases <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Example/testcases?action=edit&preload=Template%3ADocumentation%2Fpreload-testcases create])</span> pages.<br>Please add categories to the [[Template:Example/doc|/doc]] subpage. [[Special:PrefixIndex/Template:Example/|Subpages of this template]].</div>"

YesY testEndBoxLinkBoxArg
YesY testEndBoxLinkBoxOff
YesY testEndBoxNoDocsOtherNs
N testEndBoxPrintBlurb Module:Documentation/testcases:562: Failed to find pattern "<br />A %[%[Help:Books/for experts#Improving the book layout|print version%]%] of this template exists at %[%[.-|/Print%]%]%. If you make a change to this template, please update the print version as well%." in string "<div id="documentation-meta-data" class="template-documentation__end plainlinks">

You might want to [https://pathofexile.fandom.com/wiki/Template:Expand_list/doc?action=edit&preload=Template%3ADocumentation%2Fpreload create] a documentation page for this [[gphelp:Templates|template]].<br>Editors can experiment in this template's sandbox <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Expand_list/sandbox?action=edit&preload=Template%3ADocumentation%2Fpreload-sandbox create] &#124; [https://pathofexile.fandom.com/wiki/Template:Expand_list/sandbox?preload=Template%3ADocumentation%2Fmirror&action=edit&summary=Create+sandbox+version+of+%5B%5BTemplate%3AExpand+list%5D%5D mirror])</span> and testcases <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Expand_list/testcases?action=edit&preload=Template%3ADocumentation%2Fpreload-testcases create])</span> pages.<br>Please add categories to the [[Template:Expand list/doc|/doc]] subpage. [[Special:PrefixIndex/Template:Expand list/|Subpages of this template]].</div>"

YesY testEndBoxSandboxImage
YesY testEndBoxStyles
YesY testEnvBadTitle
N testEnvCompareUrl https://pathofexile.gamepedia.com/index.php?title=Special%3AComparePages&page1=Template%3AMath&page2=Template%3AMath%2Fsandbox https://pathofexile.fandom.com/wiki/Special:ComparePages?page1=Template%3AMath&page2=Template%3AMath%2Fsandbox
YesY testEnvDocSpace
YesY testEnvDocTitle
YesY testEnvDocpageBase
YesY testEnvPrintTitle
YesY testEnvProtectionLevels
YesY testEnvSandboxTitle
YesY testEnvSubjectSpace
YesY testEnvTemplateTitle
YesY testEnvTestcasesTitle
YesY testEnvTitle
YesY testExperimentBlurbModule
N testExperimentBlurbSandboxDoesntExist Module:Documentation/testcases:620: Failed to find plain string "sandbox <span class="template-documentation-toolbar-link">([//en.wikipedia.org/w/index.php?title=Template:Non-existent_template_sajdfasd/sandbox&action=edit&preload=Template%3ADocumentation%2Fpreload-sandbox create] &#124; [//en.wikipedia.org/w/index.php?title=Template:Non-existent_template_sajdfasd/sandbox&preload=Template%3ADocumentation%2Fmirror&action=edit&summary=Create+sandbox+version+of+%5B%5BTemplate%3ANon-existent+template+sajdfasd%5D%5D mirror])</span>" in string "Editors can experiment in this template's sandbox <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Non-existent_template_sajdfasd/sandbox?action=edit&preload=Template%3ADocumentation%2Fpreload-sandbox create] &#124; [https://pathofexile.fandom.com/wiki/Template:Non-existent_template_sajdfasd/sandbox?preload=Template%3ADocumentation%2Fmirror&action=edit&summary=Create+sandbox+version+of+%5B%5BTemplate%3ANon-existent+template+sajdfasd%5D%5D mirror])</span> and testcases <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Non-existent_template_sajdfasd/testcases?action=edit&preload=Template%3ADocumentation%2Fpreload-testcases create])</span> pages."
N testExperimentBlurbSandboxExists Module:Documentation/testcases:614: Failed to find plain string "[[Template:Edit protected/sandbox|sandbox]] <span class="template-documentation-toolbar-link">([//en.wikipedia.org/w/index.php?title=Template:Edit_protected/sandbox&action=edit edit] &#124; [//en.wikipedia.org/w/index.php?title=Special%3AComparePages&page1=Template%3AEdit+protected&page2=Template%3AEdit+protected%2Fsandbox diff])</span>" in string "Editors can experiment in this template's sandbox <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Edit_protected/sandbox?action=edit&preload=Template%3ADocumentation%2Fpreload-sandbox create] &#124; [https://pathofexile.fandom.com/wiki/Template:Edit_protected/sandbox?preload=Template%3ADocumentation%2Fmirror&action=edit&summary=Create+sandbox+version+of+%5B%5BTemplate%3AEdit+protected%5D%5D mirror])</span> and testcases <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Edit_protected/testcases?action=edit&preload=Template%3ADocumentation%2Fpreload-testcases create])</span> pages."
YesY testExperimentBlurbTemplate
N testExperimentBlurbTestcasesDontExist Module:Documentation/testcases:632: Failed to find plain string "testcases <span class="template-documentation-toolbar-link">([//en.wikipedia.org/w/index.php?title=Template:Non-existent_template_sajdfasd/testcases&action=edit&preload=Template%3ADocumentation%2Fpreload-testcases create])</span>" in string "Editors can experiment in this template's sandbox <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Non-existent_template_sajdfasd/sandbox?action=edit&preload=Template%3ADocumentation%2Fpreload-sandbox create] &#124; [https://pathofexile.fandom.com/wiki/Template:Non-existent_template_sajdfasd/sandbox?preload=Template%3ADocumentation%2Fmirror&action=edit&summary=Create+sandbox+version+of+%5B%5BTemplate%3ANon-existent+template+sajdfasd%5D%5D mirror])</span> and testcases <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Non-existent_template_sajdfasd/testcases?action=edit&preload=Template%3ADocumentation%2Fpreload-testcases create])</span> pages."
N testExperimentBlurbTestcasesExist Module:Documentation/testcases:626: Failed to find plain string "[[Template:Edit protected/testcases|testcases]] <span class="template-documentation-toolbar-link">([//en.wikipedia.org/w/index.php?title=Template:Edit_protected/testcases&action=edit edit])</span>" in string "Editors can experiment in this template's sandbox <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Edit_protected/sandbox?action=edit&preload=Template%3ADocumentation%2Fpreload-sandbox create] &#124; [https://pathofexile.fandom.com/wiki/Template:Edit_protected/sandbox?preload=Template%3ADocumentation%2Fmirror&action=edit&summary=Create+sandbox+version+of+%5B%5BTemplate%3AEdit+protected%5D%5D mirror])</span> and testcases <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Edit_protected/testcases?action=edit&preload=Template%3ADocumentation%2Fpreload-testcases create])</span> pages."
YesY testMakeCategoriesBlurb
YesY testMakeCategoryLink
YesY testMakePrintBlurbDoesntExist
N testMakePrintBlurbExists A [[Help:Books/for experts#Improving the book layout|print version]] of this template exists at [[Template:Example/Print|/Print]]. If you make a change to this template, please update the print version as well.[[Category:Templates with print versions]] A [[wikipedia:Help:Books/for experts#Improving the book layout|print version]] of this template exists at [[Template:Example/Print|/Print]]. If you make a change to this template, please update the print version as well.[[Category:Templates with print versions]]
YesY testMakeStartBoxLinksData
YesY testMakeStartBoxLinksDataArgsPreload
YesY testMakeStartBoxLinksDataFilePreload
YesY testMakeStartBoxLinksDataTemplatePreload
YesY testMakeSubpagesBlurbModule
YesY testMakeSubpagesBlurbOther
YesY testMakeSubpagesBlurbTemplate
YesY testMakeToolbar
YesY testMakeUrlLink
YesY testMakeWikilink
YesY testMessage
N testNoTrailingWhitespace Module:Documentation/testcases:734: Failed to find pattern "</table>$" in string "<div id="template-documentation" class="template-documentation iezoomfix clearfix">

<div class="template-documentation__start"> <span class="template-documentation__heading">[[File:Template_info_icon.svg|50px|link=|alt=]] Template documentation</span><span id="doc_editlinks" class="mw-editsection-like plainlinks">&#91;[https://pathofexile.fandom.com/wiki/Template:Example/doc?action=edit&preload=Template%3ADocumentation%2Fpreload create]&#93;</span></div> </div><div id="documentation-meta-data" class="template-documentation__end plainlinks"> You might want to [https://pathofexile.fandom.com/wiki/Template:Example/doc?action=edit&preload=Template%3ADocumentation%2Fpreload create] a documentation page for this [[gphelp:Templates|template]].<br>Editors can experiment in this template's sandbox <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Example/sandbox?action=edit&preload=Template%3ADocumentation%2Fpreload-sandbox create] &#124; [https://pathofexile.fandom.com/wiki/Template:Example/sandbox?preload=Template%3ADocumentation%2Fmirror&action=edit&summary=Create+sandbox+version+of+%5B%5BTemplate%3AExample%5D%5D mirror])</span> and testcases <span class="template-documentation__toolbar">([https://pathofexile.fandom.com/wiki/Template:Example/testcases?action=edit&preload=Template%3ADocumentation%2Fpreload-testcases create])</span> pages.<br>Please add categories to the [[Template:Example/doc|/doc]] subpage. [[Special:PrefixIndex/Template:Example/|Subpages of this template]].</div>"

N testProtectionTemplateProtectedModule Module:Documentation/testcases:274: Failed to assert that nil is true
N testProtectionTemplateProtectedTemplate Module:Documentation/testcases:262: Failed to assert that nil is true
YesY testProtectionTemplateUnprotectedModule
YesY testProtectionTemplateUnprotectedTemplate
N testRenderStartBox <div class="template-documentation-startbox">

<span></span></div>

<div>

<span></span></div>

YesY testRenderStartBoxHeading
YesY testRenderStartBoxHeadingStyleText
YesY testRenderStartBoxLinks
YesY testRenderStartBoxLinksClass
N testRenderStartBoxLinksDoesntExist &#91;[//en.wikipedia.org/w/index.php?title=Template:NonExistentTemplate/doc&action=edit&preload=Template%3AMyPreload create]&#93; &#91;[https://pathofexile.fandom.com/wiki/Template:NonExistentTemplate/doc?action=edit&preload=Template%3AMyPreload create]&#93;
N testRenderStartBoxLinksExists &#91;[[Template:Example/doc|view]]&#93; &#91;[//en.wikipedia.org/w/index.php?title=Template:Example/doc&action=edit edit]&#93; &#91;[//en.wikipedia.org/w/index.php?title=Template:Example/doc&action=history history]&#93; &#91;[//en.wikipedia.org/w/index.php?title=Template:Example&action=purge purge]&#93; &#91;[https://pathofexile.fandom.com/wiki/Template:Example/doc?action=edit&preload=Template%3AMyPreload create]&#93;
YesY testRenderStartBoxLinksId
YesY testSandboxImageBug
YesY testSandboxNoticeBlurbDiff
YesY testSandboxNoticeBlurbDiffNoBasePage
N testSandboxNoticeModuleBlurb Module:Documentation/testcases:204: Failed to find plain string "This is the [[Wikipedia:Template test cases|module sandbox]] page for [[Module:Math]]" in string "<div style="clear: both;"></div><span><table class="plainlinks mbox ombox ombox-notice" role="presentation" style=""><tr><td class="mbox-image">[[File:Sandbox.svg|50px|alt=|link=]]</td><td class="mbox-text" style="">This is the [[wikipedia:Wikipedia:Template sandbox and test cases|module sandbox]] page for [[Module:Math]].[[Category:Template sandboxes]]</td></tr></table></span>"
YesY testSandboxNoticeNoTestcases
YesY testSandboxNoticeNotSandbox
YesY testSandboxNoticeOtherBlurb
N testSandboxNoticeStaticVals Module:Documentation/testcases:190: Failed to find pattern "^%<div class%=%"template%-documentation%-sandbox%-start%"%>%<%/div%>" in string "<div style="clear: both;"></div><span><table class="plainlinks mbox ombox ombox-notice" role="presentation" style=""><tr><td class="mbox-image">[[File:Sandbox.svg|50px|alt=|link=]]</td><td class="mbox-text" style="">This is the [[wikipedia:Wikipedia:Template sandbox and test cases|template sandbox]] page for [[Template:Example]].[[Category:Template sandboxes]]</td></tr></table></span>"
N testSandboxNoticeTemplateBlurb Module:Documentation/testcases:198: Failed to find plain string "This is the [[Wikipedia:Template test cases|template sandbox]] page for [[Template:Example]]" in string "<div style="clear: both;"></div><span><table class="plainlinks mbox ombox ombox-notice" role="presentation" style=""><tr><td class="mbox-image">[[File:Sandbox.svg|50px|alt=|link=]]</td><td class="mbox-text" style="">This is the [[wikipedia:Wikipedia:Template sandbox and test cases|template sandbox]] page for [[Template:Example]].[[Category:Template sandboxes]]</td></tr></table></span>"
N testSandboxNoticeTestcases Module:Documentation/testcases:236: Failed to find plain string "See also the companion subpage for [[Template:Edit protected/testcases|test cases]]." in string "<div style="clear: both;"></div><span><table class="plainlinks mbox ombox ombox-notice" role="presentation" style=""><tr><td class="mbox-image">[[File:Sandbox.svg|50px|alt=|link=]]</td><td class="mbox-text" style="">This is the [[wikipedia:Wikipedia:Template sandbox and test cases|template sandbox]] page for [[Template:Edit protected]].[[Category:Template sandboxes]]</td></tr></table></span>"
YesY testStartBoxContentArg
YesY testStartBoxDataBlankHeading
YesY testStartBoxDataHeadingFile
N testStartBoxDataHeadingModule [[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]] Module documentation [[File:Template_info_icon.svg|50px|link=|alt=]] Module documentation
YesY testStartBoxDataHeadingOther
YesY testStartBoxDataHeadingStyle
YesY testStartBoxDataHeadingStyleOther
YesY testStartBoxDataHeadingStyleTemplate
N testStartBoxDataHeadingTemplate [[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]] Template documentation [[File:Template_info_icon.svg|50px|link=|alt=]] Template documentation
YesY testStartBoxDataLinks
YesY testStartBoxDataNoLinks
YesY testStartBoxMainHtml
YesY testStartBoxTemplateHtml
-- Test cases page for [[Module:Documentation]]. See talk page to run tests.

local doc = require('Module:Documentation')
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()

--------------------------------------------------------------------------------------------
-- Test case helper functions
--------------------------------------------------------------------------------------------

local function getEnv(page)
    -- Gets an env table using the specified page.
    return doc.getEnvironment{page = page}
end

--------------------------------------------------------------------------------------------
-- Test helper functions
--------------------------------------------------------------------------------------------

function suite:testMessage()
    self:assertEquals('sandbox', doc.message('sandbox-subpage'))
    self:assertEquals('Subpages of this foobar', doc.message('subpages-link-display', {'foobar'}))
    self:assertEquals(true, doc.message('display-print-category', nil, 'boolean'))
end

function suite:testMakeToolbar()
    self:assertEquals(nil, doc.makeToolbar())
    self:assertEquals('<span class="template-documentation__toolbar">(Foo)</span>', doc.makeToolbar('Foo'))
    self:assertEquals('<span class="template-documentation__toolbar">(Foo &#124; Bar)</span>', doc.makeToolbar('Foo', 'Bar'))
end

function suite:testMakeWikilink()
    self:assertEquals('[[Foo]]', doc.makeWikilink('Foo'))
    self:assertEquals('[[Foo|Bar]]', doc.makeWikilink('Foo', 'Bar'))
end

function suite:testMakeCategoryLink()
    self:assertEquals('[[Category:Foo]]', doc.makeCategoryLink('Foo'))
    self:assertEquals('[[Category:Foo|Bar]]', doc.makeCategoryLink('Foo', 'Bar'))
end

function suite:testMakeUrlLink()
    self:assertEquals('[Foo Bar]', doc.makeUrlLink('Foo', 'Bar'))
end

--------------------------------------------------------------------------------------------
-- Test env table
--------------------------------------------------------------------------------------------

function suite:assertEnvFieldEquals(expected, page, field)
    local env = getEnv(page)
    self:assertEquals(expected, env[field])
end 

function suite:assertEnvTitleEquals(expected, page, titleField)
    local env = getEnv(page)
    local title = env[titleField]
    self:assertEquals(expected, title.prefixedText)
end 

function suite:testEnvTitle()
    self:assertEnvTitleEquals('gphelp:Templates', 'gphelp:Templates', 'title')
    self:assertEnvTitleEquals('wikipedia:Template:Example/sandbox', 'wikipedia:Template:Example/sandbox', 'title')
end

function suite:testEnvBadTitle()
    local env = doc.getEnvironment{page = 'Bad[]Title'}
    local title = env.title
    self:assertEquals(nil, title)
end

function suite:testEnvTemplateTitle()
    self:assertEnvTitleEquals('Template:Example', 'Template:Example', 'templateTitle')
    self:assertEnvTitleEquals('Template:Example', 'Template talk:Example', 'templateTitle')
    self:assertEnvTitleEquals('Template:Example', 'Template:Example/sandbox', 'templateTitle')
    self:assertEnvTitleEquals('Template:Example', 'Template talk:Example/sandbox', 'templateTitle')
    self:assertEnvTitleEquals('Template:Example', 'Template:Example/testcases', 'templateTitle')
    self:assertEnvTitleEquals('Template:Example/foo', 'Template:Example/foo', 'templateTitle')
    self:assertEnvTitleEquals('File:Example', 'File talk:Example', 'templateTitle')
    self:assertEnvTitleEquals('File:Example', 'File talk:Example/sandbox', 'templateTitle')
end

function suite:testEnvDocTitle()
    self:assertEnvTitleEquals('Template:Example/doc', 'Template:Example', 'docTitle')
    self:assertEnvTitleEquals('Template:Example/doc', 'Template talk:Example', 'docTitle')
    self:assertEnvTitleEquals('Template:Example/doc', 'Template:Example/sandbox', 'docTitle')
    self:assertEnvTitleEquals('Talk:Example/doc', 'Example', 'docTitle')
    self:assertEnvTitleEquals('File talk:Example.png/doc', 'File:Example.png', 'docTitle')
    self:assertEnvTitleEquals('File talk:Example.png/doc', 'File talk:Example.png/sandbox', 'docTitle')
end

function suite:testEnvSandboxTitle()
    self:assertEnvTitleEquals('Template:Example/sandbox', 'Template:Example', 'sandboxTitle')
    self:assertEnvTitleEquals('Template:Example/sandbox', 'Template talk:Example', 'sandboxTitle')
    self:assertEnvTitleEquals('Template:Example/sandbox', 'Template:Example/sandbox', 'sandboxTitle')
    self:assertEnvTitleEquals('Talk:Example/sandbox', 'Example', 'sandboxTitle')
    self:assertEnvTitleEquals('File talk:Example.png/sandbox', 'File:Example.png', 'sandboxTitle')
end

function suite:testEnvTestcasesTitle()
    self:assertEnvTitleEquals('Template:Example/testcases', 'Template:Example', 'testcasesTitle')
    self:assertEnvTitleEquals('Template:Example/testcases', 'Template talk:Example', 'testcasesTitle')
    self:assertEnvTitleEquals('Template:Example/testcases', 'Template:Example/testcases', 'testcasesTitle')
    self:assertEnvTitleEquals('Talk:Example/testcases', 'Example', 'testcasesTitle')
    self:assertEnvTitleEquals('File talk:Example.png/testcases', 'File:Example.png', 'testcasesTitle')
end

function suite:testEnvPrintTitle()
    self:assertEnvTitleEquals('Template:Example/Print', 'Template:Example', 'printTitle')
    self:assertEnvTitleEquals('Template:Example/Print', 'Template talk:Example', 'printTitle')
    self:assertEnvTitleEquals('Template:Example/Print', 'Template:Example/sandbox', 'printTitle')
end

function suite:testEnvProtectionLevels()
    local pipeEnv = getEnv('Help:Signatures')
    self:assertEquals('autoconfirmed', pipeEnv.protectionLevels.edit[1])
    local sandboxEnv = getEnv('Project talk:Community portal')
    local sandboxEditLevels = sandboxEnv.protectionLevels.edit
    if sandboxEditLevels then -- sandboxEditLevels may also be nil if the page is unprotected
        self:assertEquals(nil, sandboxEditLevels[1])
    else
        self:assertEquals(nil, sandboxEditLevels)
    end
end

function suite:testEnvSubjectSpace()
    self:assertEnvFieldEquals(10, 'Template:Sandbox', 'subjectSpace')
    self:assertEnvFieldEquals(10, 'Template talk:Sandbox', 'subjectSpace')
    self:assertEnvFieldEquals(0, 'Foo', 'subjectSpace')
    self:assertEnvFieldEquals(0, 'Talk:Foo', 'subjectSpace')
end

function suite:testEnvDocSpace()
    self:assertEnvFieldEquals(10, 'Template:Sandbox', 'docSpace')
    self:assertEnvFieldEquals(828, 'Module:Sandbox', 'docSpace')
    self:assertEnvFieldEquals(1, 'Foo', 'docSpace')
    self:assertEnvFieldEquals(7, 'File:Example.png', 'docSpace')
    self:assertEnvFieldEquals(9, 'MediaWiki:Watchlist-details', 'docSpace')
    self:assertEnvFieldEquals(15, 'Category:Wikipedians', 'docSpace')
end

function suite:testEnvDocpageBase()
    self:assertEnvFieldEquals('Template:Example', 'Template:Example', 'docpageBase')
    self:assertEnvFieldEquals('Template:Example', 'Template:Example/sandbox', 'docpageBase')
    self:assertEnvFieldEquals('Template:Example', 'Template talk:Example', 'docpageBase')
    self:assertEnvFieldEquals('File talk:Example.png', 'File:Example.png', 'docpageBase')
    self:assertEnvFieldEquals('File talk:Example.png', 'File talk:Example.png', 'docpageBase')
    self:assertEnvFieldEquals('File talk:Example.png', 'File talk:Example.png/sandbox', 'docpageBase')
end

function suite:testEnvCompareUrl()
    local expected = 'https://pathofexile.gamepedia.com/index.php?title=Special%3AComparePages&page1=Template%3AMath&page2=Template%3AMath%2Fsandbox'
    self:assertEnvFieldEquals(expected, 'Template:Math', 'compareUrl') 
    self:assertEnvFieldEquals(expected, 'Template:Math/sandbox', 'compareUrl')
    self:assertEnvFieldEquals(nil, 'Template:Non-existent template adsfasdg', 'compareUrl')
    self:assertEnvFieldEquals(nil, 'Template:Gamename', 'compareUrl') -- Exists but doesn't have a sandbox.
end

--------------------------------------------------------------------------------------------
-- Test sandbox notice
--------------------------------------------------------------------------------------------

function suite.getSandboxNoticeTestData(page)
    local env = getEnv(page)
    local templatePage = page:match('^(.*)/sandbox$')
    local image = '[[Image:Sandbox.svg|50px|alt=|link=]]'
    local templateBlurb = 'This is the [[Wikipedia:Template test cases|template sandbox]] page for [[' .. templatePage .. ']]'
    local moduleBlurb = 'This is the [[Wikipedia:Template test cases|module sandbox]] page for [[' .. templatePage .. ']]'
    local otherBlurb = 'This is the sandbox page for [[' .. templatePage .. ']]'
    local diff = '[//en.wikipedia.org/w/index.php?title=Special%3AComparePages&page1=' .. mw.uri.encode(templatePage) .. '&page2=' .. mw.uri.encode(page) .. ' diff]'
    local testcasesBlurb = 'See also the companion subpage for [[' .. templatePage .. '/testcases|test cases]].'
    local category = '[[Category:Template sandboxes]]'
    local clear = '<div class="template-documentation-sandbox-start"></div>'
    return env, image, templateBlurb, moduleBlurb, otherBlurb, diff, testcasesBlurb, category, clear
end 

function suite:testSandboxNoticeNotSandbox()
    local env = getEnv('Template:Example')
    local notice = doc.sandboxNotice({}, env)
    self:assertEquals(nil, notice)
end

function suite:testSandboxNoticeStaticVals()
    local env, image, templateBlurb, moduleBlurb, otherBlurb, diff, testcasesBlurb, category, clear = suite.getSandboxNoticeTestData('Template:Example/sandbox')
    local notice = doc.sandboxNotice({}, env)

    -- Escape metacharacters (mainly '-')
    clear = clear:gsub( '%p', '%%%0' )

    self:assertStringContains('^' .. clear, notice, false)
    self:assertStringContains(image, notice, true)
    self:assertStringContains(category, notice, true)
end

function suite:testSandboxNoticeTemplateBlurb()
    local env, image, templateBlurb, moduleBlurb, otherBlurb, diff, testcasesBlurb, category = suite.getSandboxNoticeTestData('Template:Example/sandbox')
    local notice = doc.sandboxNotice({}, env)
    self:assertStringContains(templateBlurb, notice, true)
end

function suite:testSandboxNoticeModuleBlurb()
    local env, image, templateBlurb, moduleBlurb, otherBlurb, diff, testcasesBlurb, category = suite.getSandboxNoticeTestData('Module:Math/sandbox')
    local notice = doc.sandboxNotice({}, env)
    self:assertStringContains(moduleBlurb, notice, true)
end

function suite:testSandboxNoticeOtherBlurb()
    local env, image, templateBlurb, moduleBlurb, otherBlurb, diff, testcasesBlurb, category = suite.getSandboxNoticeTestData('User:Mr. Stradivarius/sandbox')
    local notice = doc.sandboxNotice({}, env)
    self:assertStringContains(otherBlurb, notice, true)
end

function suite:testSandboxNoticeBlurbDiff()
    local env, image, templateBlurb, moduleBlurb, otherBlurb, diff, testcasesBlurb, category = suite.getSandboxNoticeTestData('Template:Example/sandbox')
    local notice = doc.sandboxNotice({}, env)
    if mw.title.getCurrentTitle().isTalk then
        -- This test doesn't work in the debug console due to the use of frame:preprocess({{REVISIONID}}).
        -- The frame test doesn't seem to be working for now, so adding a namespace hack.
        self:assertStringContains(diff, notice, true)
    end
end

function suite:testSandboxNoticeBlurbDiffNoBasePage()
    local env, image, templateBlurb, moduleBlurb, otherBlurb, diff, testcasesBlurb, category = suite.getSandboxNoticeTestData('Module:User:Mr. Stradivarius/sandbox')
    local notice = doc.sandboxNotice({}, env)
    if mw.title.getCurrentTitle().isTalk then
        -- This test doesn't work in the debug console due to the use of frame:preprocess({{REVISIONID}}).
        -- The frame test doesn't seem to be working for now, so adding a namespace hack.
        self:assertNotStringContains(diff, notice, true)
    end
end

function suite:testSandboxNoticeTestcases()
    local env, image, templateBlurb, moduleBlurb, otherBlurb, diff, testcasesBlurb, category = suite.getSandboxNoticeTestData('Template:Edit protected/sandbox')
    local notice = doc.sandboxNotice({}, env)
    self:assertStringContains(testcasesBlurb, notice, true)
end

function suite:testSandboxNoticeNoTestcases()
    local env, image, templateBlurb, moduleBlurb, otherBlurb, diff, testcasesBlurb, category = suite.getSandboxNoticeTestData('Template:Example/sandbox')
    local notice = doc.sandboxNotice({}, env)
    self:assertNotStringContains(testcasesBlurb, notice, true)
end

--------------------------------------------------------------------------------------------
-- Test protection template
-- 
-- There's not much we can do with this until {{pp-meta}} gets rewritten in Lua. At the
-- moment the protection detection only works for the current page, and the testcases pages
-- will be unprotected.
--------------------------------------------------------------------------------------------

function suite:testProtectionTemplateUnprotectedTemplate()
    local env = getEnv('Template:Example')
    self:assertEquals(nil, doc.protectionTemplate(env))
end

function suite:testProtectionTemplateProtectedTemplate()
    local env = getEnv('Template:Navbox')
    -- Test whether there is some content. We don't care what the content is, as the protection level
    -- detected will be for the current page, not the template.
    self:assertTrue(doc.protectionTemplate(env))
end

function suite:testProtectionTemplateUnprotectedModule()
    local env = getEnv('Module:Example')
    self:assertEquals(nil, doc.protectionTemplate(env))
end

function suite:testProtectionTemplateProtectedModule()
    local env = getEnv('Module:Yesno')
    -- Test whether there is some content. We don't care what the content is, as the protection level
    -- detected will be for the current page, not the template.
    self:assertTrue(doc.protectionTemplate(env))
end

--------------------------------------------------------------------------------------------
-- Test _startBox
--------------------------------------------------------------------------------------------

function suite:testStartBoxContentArg()
    local pattern = '<div class="template%-documentation__start">\n<span class="template%-documentation__heading">.-</span></div>'
    local startBox = doc._startBox({content = 'some documentation'}, getEnv('Template:Example'))
    self:assertStringContains(pattern, startBox)
end

function suite:testStartBoxTemplateHtml()
    self:assertStringContains(
        '<div class="template%-documentation__start">\n<span class="template%-documentation__heading">.-Template documentation</span><span id="doc_editlinks" class="mw%-editsection%-like plainlinks">.-</span></div>',
        doc._startBox({}, getEnv('Template:Example'))
    )
end

function suite:testStartBoxMainHtml()
    self:assertStringContains(
        '<div class="template%-documentation__start">\n<span class="template%-documentation__heading">.-Documentation</span><span id="doc_editlinks" class="mw%-editsection%-like plainlinks">.-</span></div>',
        doc._startBox({}, getEnv('Foo'))
    )
end

--------------------------------------------------------------------------------------------
-- Test makeStartBoxLinksData
--------------------------------------------------------------------------------------------

function suite:testMakeStartBoxLinksData()
    local env = getEnv('Template:Example')
    local data = doc.makeStartBoxLinksData({}, env)
    self:assertEquals('Template:Example', data.title.prefixedText)
    self:assertEquals('Template:Example/doc', data.docTitle.prefixedText)
    self:assertEquals('view', data.viewLinkDisplay)
    self:assertEquals('edit', data.editLinkDisplay)
    self:assertEquals('history', data.historyLinkDisplay)
    self:assertEquals('purge', data.purgeLinkDisplay)
    self:assertEquals('create', data.createLinkDisplay)
end

function suite:testMakeStartBoxLinksDataFilePreload()
    local env = getEnv('File:Example.png')
    local data = doc.makeStartBoxLinksData({}, env)
    self:assertEquals('Template:Documentation/preload-filespace', data.preload)
end

function suite:testMakeStartBoxLinksDataTemplatePreload()
    local env = getEnv('Template:Example')
    local data = doc.makeStartBoxLinksData({}, env)
    self:assertEquals('Template:Documentation/preload', data.preload)
end

function suite:testMakeStartBoxLinksDataArgsPreload()
    local env = getEnv('Template:Example')
    local data = doc.makeStartBoxLinksData({preload = 'My custom preload'}, env)
    self:assertEquals('My custom preload', data.preload)
end

--------------------------------------------------------------------------------------------
-- Test renderStartBoxLinks
--------------------------------------------------------------------------------------------

function suite.makeExampleStartBoxLinksData(exists)
    -- Makes a data table to be used with testRenderStartBoxLinksExists and testRenderStartBoxLinksDoesntExist.
    local data = {}
    if exists then
        data.title = mw.title.new('Template:Example')
        data.docTitle = mw.title.new('Template:Example/doc')
    else
        data.title = mw.title.new('Template:NonExistentTemplate')
        data.docTitle = mw.title.new('Template:NonExistentTemplate/doc')
    end
    data.viewLinkDisplay = 'view'
    data.editLinkDisplay = 'edit'
    data.historyLinkDisplay = 'history'
    data.purgeLinkDisplay = 'purge'
    data.createLinkDisplay = 'create'
    data.preload = 'Template:MyPreload'
    return data
end

function suite:testRenderStartBoxLinksExists()
    local data = suite.makeExampleStartBoxLinksData(true)
    local expected = '&#91;[[Template:Example/doc|view]]&#93; &#91;[//en.wikipedia.org/w/index.php?title=Template:Example/doc&action=edit edit]&#93; &#91;[//en.wikipedia.org/w/index.php?title=Template:Example/doc&action=history history]&#93; &#91;[//en.wikipedia.org/w/index.php?title=Template:Example&action=purge purge]&#93;'
    self:assertEquals(expected, doc.renderStartBoxLinks(data))
end

function suite:testRenderStartBoxLinksDoesntExist()
    local data = suite.makeExampleStartBoxLinksData(false)
    local expected = '&#91;[//en.wikipedia.org/w/index.php?title=Template:NonExistentTemplate/doc&action=edit&preload=Template%3AMyPreload create]&#93;'
    self:assertEquals(expected, doc.renderStartBoxLinks(data))
end

--------------------------------------------------------------------------------------------
-- Test makeStartBoxData
--------------------------------------------------------------------------------------------

function suite:testStartBoxDataBlankHeading()
    local data = doc.makeStartBoxData({heading = ''}, {})
    self:assertEquals(nil, data)
end

function suite:testStartBoxDataHeadingTemplate()
    local env = getEnv('Template:Example')
    local data = doc.makeStartBoxData({}, env)
    local expected = '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]] Template documentation'
    self:assertEquals(expected, data.heading)
end

function suite:testStartBoxDataHeadingModule()
    local env = getEnv('Module:Bananas')
    local data = doc.makeStartBoxData({}, env)
    local expected = '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]] Module documentation'
    self:assertEquals(expected, data.heading)
end

function suite:testStartBoxDataHeadingFile()
    local env = getEnv('File:Example.png')
    local data = doc.makeStartBoxData({}, env)
    local expected = 'Summary'
    self:assertEquals(expected, data.heading)
end

function suite:testStartBoxDataHeadingOther()
    local env = getEnv('User:Example')
    local data = doc.makeStartBoxData({}, env)
    local expected = 'Documentation'
    self:assertEquals(expected, data.heading)
end

function suite:testStartBoxDataHeadingStyle()
    local data = doc.makeStartBoxData({['heading-style'] = 'foo:bar'}, {})
    self:assertEquals('foo:bar', data.headingStyleText)
end

function suite:testStartBoxDataHeadingStyleTemplate()
    local env = getEnv('Template:Example')
    local data = doc.makeStartBoxData({}, env)
    self:assertEquals(nil, data.headingStyleText)
end

function suite:testStartBoxDataHeadingStyleOther()
    local env = getEnv('User:Example')
    local data = doc.makeStartBoxData({}, env)
    self:assertEquals(nil, data.headingStyleText)
end

function suite:testStartBoxDataLinks()
    local env = getEnv('Template:Example')
    local data = doc.makeStartBoxData({}, env, 'some links')
    self:assertEquals('some links', data.links)
    self:assertEquals('mw-editsection-like plainlinks', data.linksClass)
    self:assertEquals('doc_editlinks', data.linksId)
end

function suite:testStartBoxDataNoLinks()
    local env = getEnv('Template:Example')
    local data = doc.makeStartBoxData({}, env)
    self:assertEquals(nil, data.links)
    self:assertEquals(nil, data.linksClass)
    self:assertEquals(nil, data.linksId)
end

--------------------------------------------------------------------------------------------
-- Test renderStartBox
--------------------------------------------------------------------------------------------

function suite:testRenderStartBox()
    local expected = '<div class="template-documentation-startbox">\n<span></span></div>'
    self:assertEquals(expected, doc.renderStartBox{})
end

function suite:testRenderStartBoxHeadingStyleText()
    self:assertStringContains('\n<span style="foo:bar">', doc.renderStartBox{headingStyleText = 'foo:bar'}, true)
end

function suite:testRenderStartBoxHeading()
    self:assertStringContains('\n<span>Foobar</span>', doc.renderStartBox{heading = 'Foobar'}, true)
end

function suite:testRenderStartBoxLinks()
    self:assertStringContains('<span>list of links</span>', doc.renderStartBox{links = 'list of links'}, true)
end

function suite:testRenderStartBoxLinksClass()
    self:assertStringContains('<span class="linksclass">list of links</span>', doc.renderStartBox{linksClass = 'linksclass', links = 'list of links'}, true)
    self:assertNotStringContains('linksclass', doc.renderStartBox{linksClass = 'linksclass'}, true)
end

function suite:testRenderStartBoxLinksId()
    self:assertStringContains('<span id="linksid">list of links</span>', doc.renderStartBox{linksId = 'linksid', links = 'list of links'}, true)
    self:assertNotStringContains('linksid', doc.renderStartBox{linksId = 'linksid'}, true)
end

--------------------------------------------------------------------------------------------
-- Test _content
--------------------------------------------------------------------------------------------

function suite:testContentArg()
    self:assertEquals('\nsome documentation\n', doc._content({content = 'some documentation'}, {}))
end

function suite:testContentNoContent()
    local env = getEnv('Template:This is a non-existent template agauchvaiu')
    self:assertEquals('\n\n', doc._content({}, env))
end

function suite:testContentExists()
    local env = doc.getEnvironment{'Template:Documentation/testcases/test3'}
    local docs = mw.getCurrentFrame():preprocess('{{Template:Documentation/testcases/test3}}')
    local expected = '\n' .. docs .. '\n'
    self:assertEquals(expected, doc._content({}, env))
end

--------------------------------------------------------------------------------------------
-- Test _endBox
--------------------------------------------------------------------------------------------

function suite:testEndBoxLinkBoxOff()
    local env = getEnv()
    self:assertEquals(nil, doc._endBox({['link box'] = 'off'}, env))
end

function suite:testEndBoxNoDocsOtherNs()
    local env = {
        subjectSpace = 4,
        docTitle = {
            exists = false
        }
    }
    self:assertEquals(nil, doc._endBox({}, env))
end

function suite:testEndBoxAlwaysShowNs()
    self:assertTrue(doc._endBox({}, getEnv('Template:Non-existent template asdfalsdhaw')))
    self:assertTrue(doc._endBox({}, getEnv('Module:Non-existent module asdhewbydcyg')))
    self:assertTrue(doc._endBox({}, getEnv('User:Non-existent user ahfliwebalisyday')))
end

function suite:testEndBoxStyles()
    local env = getEnv('Template:Example')
    local endBox = doc._endBox({}, env)
    self:assertStringContains('id="documentation-meta-data"', endBox, true)
    self:assertNotStringContains('[[File:', endBox, true)
    self:assertNotStringContains('[[Image:', endBox, true)
end

function suite:testEndBoxSandboxImage()
    local env = getEnv('Template:Example/sandbox')
    local endBox = doc._endBox({}, env)
    self:assertNotStringContains('[[File:', endBox, true)
    self:assertNotStringContains('[[Image:', endBox, true)
end

function suite:testEndBoxLinkBoxArg()
    local env = getEnv()
    self:assertStringContains('Custom link box', doc._endBox({['link box'] = 'Custom link box'}, env))
end

function suite:testEndBoxExperimentBlurbValidNs()
    local expected = 'Editors can experiment in this.-<br />'
    self:assertStringContains(expected, doc._endBox({}, getEnv('Template:Example')))
    self:assertStringContains(expected, doc._endBox({}, getEnv('Module:Bananas')))
    self:assertStringContains(expected, doc._endBox({}, getEnv('User:Example')))
end

function suite:testEndBoxExperimentBlurbInvalidNs()
    local expected = 'Editors can experiment in this.-<br />'
    self:assertNotStringContains(expected, doc._endBox({}, getEnv('Wikipedia:Twinkle'))) -- Wikipedia:Twinkle has an existing /doc subpage
end

function suite:testEndBoxCategoriesBlurb()
    local expected = 'Please add categories to the %[%[.-|/doc%]%] subpage%.'
    self:assertStringContains(expected, doc._endBox({}, getEnv('Template:Example')))
    self:assertStringContains(expected, doc._endBox({}, getEnv('Module:Bananas')))
    self:assertStringContains(expected, doc._endBox({}, getEnv('User:Example')))
    self:assertNotStringContains(expected, doc._endBox({[1] = 'Foo'}, getEnv('Template:Example')))
    self:assertNotStringContains(expected, doc._endBox({content = 'Bar'}, getEnv('Template:Example')))
    self:assertNotStringContains(expected, doc._endBox({}, getEnv('Wikipedia:Twinkle')))
end

function suite:testEndBoxPrintBlurb()
    local expected = '<br />A %[%[Help:Books/for experts#Improving the book layout|print version%]%]'
        .. ' of this template exists at %[%[.-|/Print%]%]%.'
        .. ' If you make a change to this template, please update the print version as well%.'
    self:assertStringContains(expected, doc._endBox({}, getEnv('Template:Expand list'))) -- Has a /Print subpage
    self:assertNotStringContains(expected, doc._endBox({}, getEnv('Template:Example'))) -- Doesn't have a /Print subpage, and is not likely to.
end

--------------------------------------------------------------------------------------------
-- Test makeDocPageBlurb
--------------------------------------------------------------------------------------------

function suite:testDocPageBlurbError()
    self:assertEquals(nil, doc.makeDocPageBlurb({}, {}))
end

function suite:testDocPageBlurbTemplateDocExists()
    local env = getEnv('Template:Documentation')
    local expected = 'The above [[Wikipedia:Template documentation|documentation]] is [[Wikipedia:Transclusion|transcluded]] from [[Template:Documentation/doc]]. <span class="template-documentation-toolbar-link">([//en.wikipedia.org/w/index.php?title=Template:Documentation/doc&action=edit edit] &#124; [//en.wikipedia.org/w/index.php?title=Template:Documentation/doc&action=history history])</span><br />'
    self:assertEquals(expected, doc.makeDocPageBlurb({}, env))
end

function suite:testDocPageBlurbTemplateDocDoesntExist()
    local env = getEnv('Template:Non-existent template ajlkfdsa')
    self:assertEquals(nil, doc.makeDocPageBlurb({}, env))
end

function suite:testDocPageBlurbModuleDocExists()
    local env = getEnv('Module:Bananas')
    local expected = 'The above [[Wikipedia:Template documentation|documentation]] is [[Wikipedia:Transclusion|transcluded]] from [[Module:Bananas/doc]]. <span class="template-documentation-toolbar-link">([//en.wikipedia.org/w/index.php?title=Module:Bananas/doc&action=edit edit] &#124; [//en.wikipedia.org/w/index.php?title=Module:Bananas/doc&action=history history])</span><br />'
    self:assertEquals(expected, doc.makeDocPageBlurb({}, env))
end

function suite:testDocPageBlurbModuleDocDoesntExist()
    local env = getEnv('Module:Non-existent module ajlkfdsa')
    local expected = 'You might want to [//en.wikipedia.org/w/index.php?title=Module:Non-existent_module_ajlkfdsa/doc&action=edit&preload=Template%3ADocumentation%2Fpreload-module-doc create] a documentation page for this [[Wikipedia:Lua|Scribunto module]].<br />'
    self:assertEquals(expected, doc.makeDocPageBlurb({}, env))
end

--------------------------------------------------------------------------------------------
-- Test makeExperimentBlurb
--------------------------------------------------------------------------------------------

function suite:testExperimentBlurbTemplate()
    local env = getEnv('Template:Example')
    self:assertStringContains("Editors can experiment in this template's .- and .- pages.", doc.makeExperimentBlurb({}, env))
end

function suite:testExperimentBlurbModule()
    local env = getEnv('Module:Bananas')
    self:assertStringContains("Editors can experiment in this module's .- and .- pages.", doc.makeExperimentBlurb({}, env))
end

function suite:testExperimentBlurbSandboxExists()
    local env = getEnv('Template:Edit protected')
    local pattern = '[[Template:Edit protected/sandbox|sandbox]] <span class="template-documentation-toolbar-link">([//en.wikipedia.org/w/index.php?title=Template:Edit_protected/sandbox&action=edit edit] &#124; [//en.wikipedia.org/w/index.php?title=Special%3AComparePages&page1=Template%3AEdit+protected&page2=Template%3AEdit+protected%2Fsandbox diff])</span>'
    self:assertStringContains(pattern, doc.makeExperimentBlurb({}, env), true)
end

function suite:testExperimentBlurbSandboxDoesntExist()
    local env = getEnv('Template:Non-existent template sajdfasd')
    local pattern = 'sandbox <span class="template-documentation-toolbar-link">([//en.wikipedia.org/w/index.php?title=Template:Non-existent_template_sajdfasd/sandbox&action=edit&preload=Template%3ADocumentation%2Fpreload-sandbox create] &#124; [//en.wikipedia.org/w/index.php?title=Template:Non-existent_template_sajdfasd/sandbox&preload=Template%3ADocumentation%2Fmirror&action=edit&summary=Create+sandbox+version+of+%5B%5BTemplate%3ANon-existent+template+sajdfasd%5D%5D mirror])</span>'
    self:assertStringContains(pattern, doc.makeExperimentBlurb({}, env), true)
end

function suite:testExperimentBlurbTestcasesExist()
    local env = getEnv('Template:Edit protected')
    local pattern = '[[Template:Edit protected/testcases|testcases]] <span class="template-documentation-toolbar-link">([//en.wikipedia.org/w/index.php?title=Template:Edit_protected/testcases&action=edit edit])</span>'
    self:assertStringContains(pattern, doc.makeExperimentBlurb({}, env), true)
end

function suite:testExperimentBlurbTestcasesDontExist()
    local env = getEnv('Template:Non-existent template sajdfasd')
    local pattern = 'testcases <span class="template-documentation-toolbar-link">([//en.wikipedia.org/w/index.php?title=Template:Non-existent_template_sajdfasd/testcases&action=edit&preload=Template%3ADocumentation%2Fpreload-testcases create])</span>'
    self:assertStringContains(pattern, doc.makeExperimentBlurb({}, env), true)
end

--------------------------------------------------------------------------------------------
-- Test makeCategoriesBlurb
--------------------------------------------------------------------------------------------

function suite:testMakeCategoriesBlurb()
    local env = getEnv('Template:Example')
    self:assertEquals('Please add categories to the [[Template:Example/doc|/doc]] subpage.', doc.makeCategoriesBlurb({}, env))
end

--------------------------------------------------------------------------------------------
-- Test makeSubpagesBlurb
--------------------------------------------------------------------------------------------

function suite:testMakeSubpagesBlurbTemplate()
    local env = getEnv('Template:Example')
    self:assertEquals('[[Special:PrefixIndex/Template:Example/|Subpages of this template]].', doc.makeSubpagesBlurb({}, env))
end

function suite:testMakeSubpagesBlurbModule()
    local env = getEnv('Module:Bananas')
    self:assertEquals('[[Special:PrefixIndex/Module:Bananas/|Subpages of this module]].', doc.makeSubpagesBlurb({}, env))
end

function suite:testMakeSubpagesBlurbOther()
    local env = getEnv('File:Example.png')
    self:assertEquals('[[Special:PrefixIndex/File:Example.png/|Subpages of this page]].', doc.makeSubpagesBlurb({}, env))
end

--------------------------------------------------------------------------------------------
-- Test makePrintBlurb
--------------------------------------------------------------------------------------------

function suite:testMakePrintBlurbExists()
    local env = {
        printTitle = {
            exists = true,
            prefixedText = 'Template:Example/Print'
        }
    }
    local expected = 'A [[Help:Books/for experts#Improving the book layout|print version]]'
        .. ' of this template exists at [[Template:Example/Print|/Print]].'
        .. ' If you make a change to this template, please update the print version as well.'
        .. '[[Category:Templates with print versions]]'
    self:assertEquals(expected, doc.makePrintBlurb({}, env))
end

function suite:testMakePrintBlurbDoesntExist()
    local env = {
        printTitle = {
            exists = false,
            prefixedText = 'Template:Example/Print'
        }
    }
    self:assertEquals(nil, doc.makePrintBlurb({}, env))
end

--------------------------------------------------------------------------------------------
-- Test addTrackingCategories
--------------------------------------------------------------------------------------------

function suite.getStrangeUsageCat()
    return '[[Category:Wikipedia pages with strange ((documentation)) usage]]'
end

function suite:testAddTrackingCategoriesTemplatePage()
    local env = getEnv('Template:Example')
    self:assertEquals('', doc.addTrackingCategories(env))
end

function suite:testAddTrackingCategoriesDocPage()
    local env = getEnv('Template:Example/doc')
    self:assertEquals(self.getStrangeUsageCat(), doc.addTrackingCategories(env))
end

function suite:testAddTrackingCategoriesTestcasesPage()
    local env = getEnv('Template:Example/testcases')
    self:assertEquals(self.getStrangeUsageCat(), doc.addTrackingCategories(env))
end

function suite:testAddTrackingCategoriesModuleDoc()
    local env = getEnv('Module:Math/doc')
    self:assertEquals(self.getStrangeUsageCat(), doc.addTrackingCategories(env))
end

function suite:testAddTrackingCategoriesModuleTestcases()
    local env = getEnv('Module:Math/testcases')
    self:assertEquals('', doc.addTrackingCategories(env))
end

function suite:testAddTrackingCategoriesInvalidTitle()
    local env = getEnv('Template:Foo[]Bar')
    self:assertEquals(nil, doc.addTrackingCategories(env))
end

--------------------------------------------------------------------------------------------
-- Whitespace tests
--------------------------------------------------------------------------------------------

function suite:testNoTrailingWhitespace()
    self:assertStringContains('</table>$', doc._main{page = 'Template:Example'})
end

--------------------------------------------------------------------------------------------
-- Whole-module tests
--------------------------------------------------------------------------------------------

function suite:testSandboxImageBug()
    self:assertNotStringContains('<table id="documentation%-meta%-data".-%[%[%w+:Sandbox.svg', doc._main{page = 'Template:Example/sandbox'})
end

return suite
Advertisement