Class DarkFeatureState

java.lang.Object
com.atlassian.jira.plugin.issuenav.DarkFeatureState
Direct Known Subclasses:
HttpSessionFeatureState, SidebarDarkFeatureState

public class DarkFeatureState extends Object
Records the state of the dark features and can restore them later. Useful in func tests which are expected to run in different configurations regarding which dark features are enabled. You should not use this class to avoid testing behaviour when under the dark and light modes, but instead it should be used to test behaviour in each of those modes where behaviour is different (for example, element or trace IDs, or the functionality on a page may be intentionally different). This class is primarily concerned with dark features that have two keys: one for enabling the dark feature, and another one for disabling it. Note that these should always be checked and set in conjunction as usually the OFF key will override the ON key, and cause JIRA to behave as though the dark feature were not set, even if it is set to true. Dark feature behaviour is complex and can be set in numerous ways, some of which do not allow later disablement. The two typical ways of setting state are: at startup time via a system property, which cannot be changed later; and at run-time through the dark feature manager. Tests can get and set this state using the backdoor. This class _tries_ to take account of that but is naive and does this by ignoring it and just blindly attempting to write state back to JIRA when requested.
  • Constructor Details

    • DarkFeatureState

      public DarkFeatureState(Backdoor backdoor, String darkFeatureOn)
    • DarkFeatureState

      public DarkFeatureState(Backdoor backdoor, String darkFeatureOn, String darkFeatureOff)
    • DarkFeatureState

      public DarkFeatureState(com.atlassian.jira.testkit.client.DarkFeaturesControl darkFeaturesControl, String darkFeatureOnKey)
    • DarkFeatureState

      public DarkFeatureState(com.atlassian.jira.testkit.client.DarkFeaturesControl darkFeaturesControl, String darkFeatureOnKey, String darkFeatureOffKey)
  • Method Details

    • restore

      public void restore()
      Sets the dark features on the instance back to what they were when this DarkFeatureState was constructed.
    • enable

      public void enable()
      Makes a best effort to enable the dark feature. If the dark feature is set to true as a system property, this will likely fail.
    • disable

      public void disable()
      Disables the dark feature.
    • darkFeaturesControl

      protected com.atlassian.jira.testkit.client.DarkFeaturesControl darkFeaturesControl()
    • isEnabled

      public boolean isEnabled()
      Returns:
      whether the sidebar is enabled in practice, this method accounts for the on and off flags