Class AbstractTestCriticalResources

java.lang.Object
com.atlassian.jira.pageobjects.JiraWebDriverTest
com.atlassian.jira.pageobjects.BaseJiraWebTest
com.atlassian.jira.webtest.webdriver.tests.frontend.resources.AbstractTestCriticalResources
Direct Known Subclasses:
TestCriticalCSS, TestCriticalJS

public abstract class AbstractTestCriticalResources extends BaseJiraWebTest
Abstract test class for detecting whether resources loaded during page load are in fact used. This class helps to prevent adding unnecessary stylesheets and javascript files to HEAD section of document.

On test failure, a developer can either fix it by deferring resource loading or adding an entry to the appropriate exempt resource list file. Instructions for either option are listed in the test failure message.

Since:
7.0, 8.0 keeping common resources separately, following DRY when it comes to updating AUI, for example
  • Field Details

  • Constructor Details

    • AbstractTestCriticalResources

      public AbstractTestCriticalResources()
  • Method Details

    • visitPage

      protected void visitPage(Runnable visitor)
    • verifyResources

      protected void verifyResources(String exemptResourceFile, CriticalResources.ResourceType resourceType) throws IOException
      Throws:
      IOException
    • verifyResources

      protected void verifyResources(String exemptResourceFile, CriticalResources.ResourceType resourceType, boolean includeCommonResources) throws IOException
      Throws:
      IOException
    • getCommonPageURL

      protected String getCommonPageURL()
    • assertCriticalNetworkRequests

      protected void assertCriticalNetworkRequests(CriticalResources.ResourceType resourceType, List<String> expected)
      Verifies that scripts or stylesheets that were drained on the page load match the given list (such resources block further processing and take part in the critical path).
      Parameters:
      resourceType - look either for Scripts or Stylesheets
      expected - the list of critical resources (in the format of "[context|resource]:[name]")