Use the TestHarness class to test your Apex SDK for Slack apps.
TestHarness Class
Represents a test with a Slack state and user session.
Usage
The TestHarness class enables you to mock the Apex SDK for Slack elements for running in a test environment, allowing the creation of a Slack state and user session as needed.
See Test Slack Apps.
TestHarness Methods
The following are methods for TestHarness.
getNewSlackState()
Signature
public Slack.TestHarness.State getNewSlackState()
Return Value
Type: Slack.TestHarness.State
TestHarness.Actions Class
Represents an actions layout component in a view for the test harness.
Usage
Use TestHarness.Actions to work with actions, such as testing a button or querying an external select component.
Slack.TestHarness.Actions actions = (Slack.TestHarness.Actions)modal.getComponentByName('my_action_name', Slack.TestHarness.Actions.class);
Slack.TestHarness.ExternalSelect externalSelect = (Slack.TestHarness.ExternalSelect)actions.getComponentByName('my_component_name', Slack.TestHarness.ExternalSelect.class);
externalSelect.query('Lookup');
The Slack.TestHarness.Actions object is returned as a window object, which is then cast back into a Slack.TestHarness.Actions object. Get the component by name by casting it back to a Slack.TestHarness.Actions object. See Classes and Casting.
TestHarness.Actions Methods
The following are methods for TestHarness.Actions.
getComponent(idx, clazz)
Gets a child component in the given index on the actions layout component.
Signature
public Object getComponent(Integer idx, System.Type clazz)
Parameters
idx
Type: Integer
The index of the component
clazz
Type: System.Type
The Apex type of the component
Return Value
Type: Object
getComponentByName(name, clazz)
Gets a child component on the actions layout component by name.
Signature
public Object getComponentByName(String name, System.Type clazz)
Parameters
name
Type: String
The name of the actions component
clazz
Type: System.Type
The Apex type of the component
getComponentCount()
Gets the number of child components for the actions component.
Signature
public Integer getComponentCount()
Return Value
Type: Integer
getName()
Signature
public String getName()
Return Value
Type: String
TestHarness.Button Class
Represents a button component in a view for the test harness.
TestHarness.Button Methods
The following are methods for TestHarness.Button.
click()
Simulates clicking a button.
Signature
public void click()
Return Value
Type: void
getConfirm()
Gets the confirm composition object for the button.
Signature
public Slack.TestHarness.Confirm getConfirm()
Return Value
Type: Slack.TestHarness.Confirm
getLabel()
Gets the label for the button.
Signature
public String getLabel()
Return Value
Type: String
getName()
Gets the name for the button.
Signature
public String getName()
Return Value
Type: String
getStyle()
Gets the style for the button.
Signature
public String getStyle()
Return Value
Type: String
getUrl()
Gets the URL for the button.
Signature
public String getUrl()
Return Value
Type: String
getValue()
Gets the value for the button.
Signature
public String getValue()
Return Value
Type: String
TestHarness.Channel Class
Represents a channel for the test harness.
TestHarness.Channel Methods
The following are methods for TestHarness.Channel.
addUser(user)
Adds a user to the channel.
Signature
public void addUser(Slack.TestHarness.User user)
Parameters
user
Type: Slack.TestHarness.User
Adds the specified user to the channel. Returns an exception if the user doesn't belong to the channel.
Return Value
Type: void
canBeOpenedByUser(user)
Gets if the specified user is able to open the channel.
Signature
public Boolean canBeOpenedByUser(Slack.TestHarness.User user)
Parameters
user
Type: Slack.TestHarness.User
getId()
Gets the channel ID.
Signature
public String getId()
Return Value
Type: String
getLocale()
Signature
public String getLocale()
Return Value
Type: String
getMessageCount(user)
Gets the message count on the channel for the specified user.
Signature
public Integer getMessageCount(Slack.TestHarness.User user)
Parameters
user
Type: Slack.TestHarness.User
Return Value
Type: Integer
getMessages(user)
Gets the list of messages for the channel for the specified user.
Signature
public List<Slack.TestHarness.Message> getMessages(Slack.TestHarness.User user)
Parameters
user
Type: Slack.TestHarness.User
Return Value
Type: List<Slack.TestHarness.Message>
getName()
Gets the name for the channel.
Signature
public String getName()
Return Value
Type: String
getTeam()
Gets the team for the channel.
Signature
public Slack.TestHarness.Team getTeam()
Return Value
Type: Slack.TestHarness.Team
isPrivate()
Returns true if the channel is private, or false otherwise.
Signature
public Boolean isPrivate()
Return Value
Type: Boolean
removeUser(user)
Removes the specified user from the channel.
Signature
public void removeUser(Slack.TestHarness.User user)
Parameters
user
Type: Slack.TestHarness.User
Return Value
Type: void
sendMessage(userSession, text)
Simulates sending a message to the channel from the user's session.
Signature
public Slack.TestHarness.Message sendMessage(Slack.TestHarness.UserSession userSession, String text)
Parameters
userSession
Type: Slack.TestHarness.UserSession
text
Type: String
TestHarness.Checkbox Class
Represents a checkbox component in a view for the test harness.
TestHarness.Checkbox Methods
The following are methods for TestHarness.Checkbox.
getConfirm()
Gets the confirm composition object for the checkbox.
Signature
public Slack.TestHarness.Confirm getConfirm()
Return Value
Type: Slack.TestHarness.Confirm
getDescription()
Gets the description for the checkbox.
Signature
public String getDescription()
Return Value
Type: String
getInitialValue()
Gets the initial value for the checkbox.
Signature
public Boolean getInitialValue()
Return Value
Type: Boolean
getLabel()
Gets the label for the checkbox.
Signature
public String getLabel()
getName()
Gets the name of the checkbox.
Signature
public String getName()
Return Value
Type: String
getValue()
Gets the value of the checkbox.
Signature
public Boolean getValue()
Return Value
Type: Boolean
setValue(value)
Sets the value of the checkbox. If the checkbox contains an onchange event, an action is fired.
Signature
public void setValue(Boolean value)
Parameters
value
Type: Boolean
Return Value
Type: void
toggleValue()
Toggles the value of the checkbox. If the checkbox contains an onchange event, an action is fired.
Signature
public void toggleValue()
Return Value
Type: void
TestHarness.CheckboxGroup Class
Represents a checkbox group component in a view for the test harness.
TestHarness.CheckboxGroup Methods
The following are methods for TestHarness.CheckboxGroup.
getConfirm()
Gets the confirm composition object for the checkbox group.
Signature
public Slack.TestHarness.Confirm getConfirm()
Return Value
Type: Slack.TestHarness.Confirm
getDescription()
Signature
public String getDescription()
Return Value
Type: String
getInitialValue()
Gets the initial value for the checkbox group.
Signature
public List<String> getInitialValue()
Return Value
Type: List<String>
getLabel()
Signature
public String getLabel()
Return Value
Type: String
getName()
Gets the name of the checkbox group.
Signature
public String getName()
Return Value
Type: String
getValue()
Gets the value of the checkbox group.
Signature
public List<String> getValue()
Return Value
Type: List<String>
setValue(listOfIdentifiers)
Sets the value of the checkbox group. If the checkbox group contains an onchange event, an action is fired.
Signature
public void setValue(List<String> listOfIdentifiers)
Parameters
listOfIdentifiers
Type: List<String>
Return Value
Type: void
toggleValue(option)
Signature
public void toggleValue(Slack.TestHarness.Option option)
Parameters
option
Type: Slack.TestHarness.Option
Return Value
Type: void
toggleValue(identifier)
Toggles the value of an individual option for the checkbox group. If the checkbox group contains an onchange event, an action is fired.
Signature
public void toggleValue(String identifier)
Parameters
identifier
Type: String
Return Value
Type: void
TestHarness.Confirm Class
Represents a confirm composition object in a view for the test harness.
TestHarness.Confirm Methods
The following are methods for TestHarness.Confirm.
getConfirm()
Gets the confirm button text.
Signature
public String getConfirm()
Return Value
Type: String
getDeny()
Gets the deny button text.
Signature
public String getDeny()
Return Value
Type: String
getStyle()
Gets the confirmation style.
Signature
public String getStyle()
Return Value
Type: String
getText()
Gets the confirmation dialog text.
Signature
public String getText()
Return Value
Type: String
getTitle()
Gets the confirmation dialog title.
Signature
public String getTitle()
Return Value
Type: String
TestHarness.Context Class
Represents the context layout component in a view for the test harness.
TestHarness.Context Methods
The following are methods for TestHarness.Context.
getComponent(idx, clazz)
Gets a child component in a given index on the context component.
Signature
public Object getComponent(Integer idx, System.Type clazz)
Parameters
idx
Type: Integer
The index of the component
clazz
Type: System.Type
The Apex type of the component
Return Value
Type: Object
getComponentCount()
Gets the number of child components on the context component.
Signature
public Integer getComponentCount()
Return Value
Type: Integer
getName()
Gets the name of the context component.
Signature
public String getName()
Return Value
Type: String
TestHarness.ConversationsSelect Class
Represents a conversations select component in a view for the test harness.
TestHarness.ConversationsSelect Methods
The following are methods for TestHarness.ConversationsSelect.
getConfirm()
Gets the confirm composition object for the component.
Signature
public Slack.TestHarness.Confirm getConfirm()
Return Value
Type: Slack.TestHarness.Confirm
getFilter()
Gets the filter composition object for the conversations select.
Signature
public Slack.TestHarness.Filter getFilter()
Return Value
Type: Slack.TestHarness.Filter
getInitialMultiselectValue()
Gets the initial value for the conversations select. If the component isn’t a multi-select, an exception is thrown.
Signature
public List<String> getInitialMultiselectValue()
Return Value
Type: List<String>
getInitialValue()
Gets the initial value for the conversations select. If the component is a multi-select, an exception is thrown.
Signature
public String getInitialValue()
Return Value
Type: String
getMaxSelection()
Gets the max selection for the conversations select. Returns 1 if the component isn’t a multi-select.
Signature
public Integer getMaxSelection()
Return Value
Type: Integer
getMultiselectValue()
Gets the value for the conversations select. If the component isn’t a multi-select, an exception is thrown.
Signature
public List<String> getMultiselectValue()
Return Value
Type: List<String>
getName()
Gets the name for the conversations select.
Signature
public String getName()
Return Value
Type: String
getOptions()
Gets the list of options for the conversations select.
Signature
public List<Slack.TestHarness.Option> getOptions()
Return Value
Type: List<Slack.TestHarness.Option>
getPlaceholder()
Gets the placeholder for the conversations select.
Signature
public String getPlaceholder()
Return Value
Type: String
getValue()
Gets the value for the component. If the component is a multi-select, an exception is thrown.
Signature
public String getValue()
Return Value
Type: String
isMultiselect()
Returns true if the conversations select is a multi-select.
Signature
public Boolean isMultiselect()
Return Value
Type: Boolean
setMultiselectValue(listOfIdentifiers)
Sets the value of the conversations select. If the conversations select contains an onchange event, an action is fired. If the component isn’t a multi-select, an exception is thrown.
Signature
public void setMultiselectValue(List<String> listOfIdentifiers)
Parameters
listOfIdentifiers
Type: List<String>
Return Value
Type: void
setValue(identifier)
Sets the value of the conversations select. If the conversations select contains an onchange event, an action is fired. If the conversations select is a multi-select, an exception is thrown.
Signature
public void setValue(String identifier)
Parameters
identifier
Type: String
TestHarness.Datasource Class
Represents a datasource composition object for the test harness.
TestHarness.Datasource Methods
The following are methods for TestHarness.Datasource.
getDefinition()
Signature
public String getDefinition()
Return Value
Type: String
getProperties()
Signature
public Map<String,Object> getProperties()
Return Value
Type: Map<String,Object>
TestHarness.DatePicker Class
Represents a date picker component in a view for the test harness.
TestHarness.DatePicker Methods
The following are methods for TestHarness.DatePicker.
getConfirm()
Gets the confirm composition object for the date picker.
Signature
public Slack.TestHarness.Confirm getConfirm()
Return Value
Type: Slack.TestHarness.Confirm
getInitialValue()
Gets the initial value for the date picker.
Signature
public String getInitialValue()
Return Value
Type: String
getName()
Gets the name for the date picker.
Signature
public String getName()
Return Value
Type: String
getPlaceholder()
Gets the placeholder for the date picker.
public String getPlaceholder()
Return Value
Type: String
getValue()
Gets the value for the date picker.
Signature
public String getValue()
Return Value
Type: String
setValue(value)
Sets the value for the date picker.
Signature
public void setValue(String value)
Parameters
value
Type: String
TestHarness.DateTimePicker Class
Represents a date time picker component in a view for the test harness.
TestHarness.DateTimePicker Methods
The following are methods for TestHarness.DateTimePicker.
getConfirm()
Gets the confirm composition object for the date time picker.
Signature
public Slack.TestHarness.Confirm getConfirm()
Return Value
Type: Slack.TestHarness.Confirm
getDateLabel()
Gets the label for the date input.
Signature
public String getDateLabel()
Return Value
Type: String
getInitialValue()
Gets the initial value for the date time picker.
Signature
public String getInitialValue()
Return Value
Type: String
getName()
Gets the name for the date time picker.
Signature
public String getName()
Return Value
Type: String
getPlaceholder()
Gets the placeholder for the date time picker.
Signature
public String getPlaceholder()
Return Value
Type: String
getRequired()
Gets the required value for the date time picker.
Signature
public Boolean getRequired()
Return Value
Type: Boolean
getSubmissionName()
Gets the submission name for the date time picker.
Signature
public String getSubmissionName()
Return Value
Type: String
getTimeLabel()
Gets the label for the time input.
Signature
public String getTimeLabel()
Return Value
Type: String
getValue()
Gets the value for the date time picker.
Signature
public String getValue()
Return Value
Type: String
setDateValue(value)
Sets the date value on the component.
Signature
public void setDateValue(String value)
Parameters
value
Type: String
Return Value
Type: void
setTimeValue(value)
Sets the time value on the component.
Signature
public void setTimeValue(String value)
Parameters
value
Type: String
Return Value
Type: void
setValue(value)
Sets the value for the date time picker.
Signature
public void setValue(String value)
Parameters
value
Type: String
Return Value
Type: void
TestHarness.Divider Class
Represents a divider component in a view for the test harness.
TestHarness.Divider Methods
The following are methods for TestHarness.Divider.
getName()
Gets the name for the divider.
Signature
public String getName()
Return Value
Type: String
TestHarness.Enterprise Class
Represents a Slack Enterprise for the test harness.
TestHarness.Enterprise Methods
The following are methods for TestHarness.Enterprise.
getId()
Gets the ID for the enterprise
Signature
public String getId()
Return Value
Type: String
getName()
Gets the name for the enterprise.
Signature
public String getName()
Return Value
Type: String
TestHarness.ExternalSelect Class
Represents an external select component in a view for the test harness.
TestHarness.ExternalSelect Methods
The following are methods for TestHarness.ExternalSelect.
getConfirm()
Gets the confirm composition object for the external select.
Signature
public Slack.TestHarness.Confirm getConfirm()
Return Value
Type: Slack.TestHarness.Confirm
getDatasource()
Gets the datasource composition object for the external select.
Signature
public Slack.TestHarness.Datasource getDatasource()
Return Value
Type: Slack.TestHarness.Datasource
getInitialMultiselectValue()
Gets the initial value for the external select. If the component isn’t a multi-select, an exception is thrown.
Signature
public List<String> getInitialMultiselectValue()
Return Value
getInitialOptions()
Gets the initial list of resolved options for the component.
Signature
public List<Slack.TestHarness.Option> getInitialOptions()
Return Value
Type: List<Slack.TestHarness.Option>
getInitialValue()
Gets the initial value for the external select. If the component is a multi-select, an exception is thrown.
Signature
public String getInitialValue()
Return Value
Type: String
getMaxSelection()
Gets the max selection for the external select. Returns 1 if the component isn’t a multi-select.
Signature
public Integer getMaxSelection()
Return Value
Type: Integer
getMinQueryLength()
Gets the min query length for the external select.
Signature
public Integer getMinQueryLength()
Return Value
Type: Integer
getMultiselectValue()
Gets the value for the external select. If the component isn’t a multi-select, an exception is thrown.
Signature
public List<String> getMultiselectValue()
Return Value
Type: List<String>
getName()
Gets the name for the external select.
Signature
public String getName()
Return Value
Type: String
getOptionGroups()
Signature
public List<Slack.TestHarness.OptionGroup> getOptionGroups()
Return Value
Type: List<Slack.TestHarness.OptionGroup>
getOptions()
Gets the list of options for the external select.
Signature
public List<Slack.TestHarness.Option> getOptions()
Return Value
Type: List<Slack.TestHarness.Option>
getPlaceholder()
Gets the placeholder for the external select.
Signature
public String getPlaceholder()
Return Value
Type: String
getValue()
Gets the value for the external select. If the component is a multi-select, an exception is thrown.
Signature
public String getValue()
Return Value
Type: String
isMultiselect()
Returns true if the external select is a multi-select.
Signature
public Boolean isMultiselect()
Return Value
Type: Boolean
query(query)
Simulates a query on the external select. If the min query length isn’t met, an exception is thrown.
Signature
public void query(String query)
Parameters
query
Type: String
Return Value
Type: void
setMultiselectValue(listOfIdentifiers)
Sets the value of the external select. If the external select contains an onchange event, an action is fired. If the component isn’t a multi-select, an exception is thrown.
Signature
public void setMultiselectValue(List<String> listOfIdentifiers)
Parameters
listOfIdentifiers
Type: List<String>
Return Value
Type: void
setValue(identifier)
Sets the value of the external select. If the external select contains an onchange event, an action is fired. If the component is a multi-select, an exception is thrown.
Signature
public void setValue(String identifier)
Parameters
identifier
Type: String
Return Value
Type: void
TestHarness.File Class
TestHarness.File Methods
The following are methods for `TestHarness.File '.
clone()
Signature
public Object clone()
Return Value
Type: Object
getExternalId()
Signature
public String getExternalId()
Return Value
Type: String
getName()
Signature
public String getName()
Return Value
Type: String
getSource()
Signature
public String getSource()
Return Value
Type: String
toString()
Signature
public String toString()
Return Value
Type: String
TestHarness.Filter Class
Represents a filter composition object in a view for the test harness.
TestHarness.Filter Methods
The following are methods for TestHarness.Filter.
getExcludeBotUsers()
Gets the excludeBotUsers value for the filter object.
Signature
public Boolean getExcludeBotUsers()
Return Value
Type: Boolean
getExcludeExternalShared()
Gets the resolved exclude external shared value for the filter object.
Signature
public Boolean getExcludeExternalShared()
Return Value
Type: Boolean
getInclude()
Gets the include list for the filter object.
Signature
public List<String> getInclude()
Return Value
Type: List<String>
TestHarness.Header Class
Represents a header component in a view for the test harness.
TestHarness.Header Methods
The following are methods for TestHarness.Header.
getName()
Gets the name for the header.
Signature
public String getName()
Return Value
Type: String
getText()
Gets the text for the header.
Signature
public String getText()
Return Value
Type: String
TestHarness.Home Class
Represents a home surface component in a view for the test harness.
TestHarness.Home Methods
The following are methods for TestHarness.Home.
getButtonByLabel(label)
Gets a button component by its label value.
Signature
public Slack.TestHarness.Button getButtonByLabel(String label)
Return Value
Type: Slack.TestHarness.Button
getComponent(idx, clazz)
Gets a child component on the home component.
Signature
public Object getComponent(Integer idx, System.Type clazz)
Parameters
idx
Type: Integer
clazz
Type: System.Type
Return Value
Type: Object
getComponentByName(name, clazz)
Signature
public Object getComponentByName(String name, System.Type clazz)
Return Value
name
Type: String
clazz
Type: System.Type
Return Value
Type: Object
getComponentCount()
Gets the number of child components on the home component.
Signature
public Integer getComponentCount()
Return Value
Type: Integer
getInputByLabel(label)
Signature
public Slack.TestHarness.Input getInputByLabel(String label)
Parameters
label
Type: String
Return Value
Type: Slack.TestHarness.Input
TestHarness.Image Class
Represents an image component in a view for the test harness.
TestHarness.Image Methods
The following are methods for TestHarness.Image.
getAltText()
Gets the alternative text for the image.
Signature
public String getAltText()
Return Value
Type: String
getImageUrl()
Gets the URL for the image.
Signature
public String getImageUrl()
Return Value
Type: String
getName()
Gets the name for the image.
Signature
public String getName()
Return Value
Type: String
getTitle()
Gets the title for the image.
Signature
public String getTitle()
Return Value
Type: String
TestHarness.InlineImage Class
Represents an inline image component in a view for the test harness.
TestHarness.InlineImage Methods
The following are methods for TestHarness.InlineImage.
getAltText()
Gets the alternative text for the inline image.
Signature
public String getAltText()
Return Value
Type: String
getImageUrl()
Gets the URL for the inline image.
Signature
public String getImageUrl()
Return Value
Type: String
getName()
Gets the name for the inline image.
Signature
public String getName()
Return Value
Type: String
TestHarness.Input Class
Represents an input layout component in a view for a test harness.
TestHarness.Input Methods
The following are methods for TestHarness.Input.
getComponent(clazz)
Gets a child component on the input component.
Signature
public Object getComponent(System.Type clazz)
Parameters
clazz
Type: System.Type
Return Value
Type: Object
getComponentByName(name, clazz)
Gets a child component on the input component by name.
Signature
public Object getComponentByName(String name, System.Type clazz)
Parameters
name
Type: String
clazz
Type: System.Type
Return Value
Type: Object
getHint()
Gets the hint for the input component.
Signature
public String getHint()
Return Value
Type: String
getLabel()
Gets the label for the input component.
Signature
public String getLabel()
Return Value
Type: String
getName()
Gets the name for the input component.
Signature
public String getName()
Return Value
Type: String
isRequired()
Returns true if the input component is required.
Signature
public Boolean isRequired()
Return Value
Type: Boolean
TestHarness.Message Class
Represents a message surface component in a view for the test harness.
TestHarness.Message Methods
The following are methods for TestHarness.Message.
canBySeenByUser(user)
Returns true if the message can be seen by the specified user.
Signature
public Boolean canBySeenByUser(Slack.TestHarness.User user)
Parameters
user
Type: Slack.TestHarness.User
Return Value
Type: Boolean
getButtonByLabel(label)
Gets a button component by its label value.
Signature
public Slack.TestHarness.Button getButtonByLabel(String label)
Parameters
label
Type: String
Return Value
Type: Slack.TestHarness.Button
getChannel()
Gets the channel value for the message.
Signature
public Slack.TestHarness.Channel getChannel()
Return Value
Type: Slack.TestHarness.Channel
getComponent(idx, clazz)
Gets a child component in a given index on the message component.
Signature
public Object getComponent(Integer idx, System.Type clazz)
Parameters
idx
Type: Integer
clazz
Type: System.Type
Return Value
Type: Object
getComponentByName(name, clazz)
Gets a child component on the message component by name.
Signature
public Object getComponentByName(String name, System.Type clazz)
Return Value
Type: String
getComponentCount()
Gets the number of child components for the message component.
Signature
public Integer getComponentCount()
Return Value
Type: Integer
getInputByLabel(label)
Gets the input component by label for the message component.
Signature
public Slack.TestHarness.Input getInputByLabel(String label)
Parameters
label
Type: String
Return Value
Type: Slack.TestHarness.Input
getMessageTs()
Gets the timestamp for the message.
Signature
public String getMessageTs()
Return Value
Type: String
getText()
Gets the text for the message.
Signature
public String getText()
Return Value
Type: String
isEphemeralMessage()
Returns true if the message is ephemeral.
Signature
public Boolean isEphemeralMessage()
Return Value
Type: Boolean
TestHarness.Modal Class
Represents a modal surface component in a view for the test harness.
TestHarness.Modal Methods
The following are methods for TestHarness.Modal.
close()
Simulates closing a modal, which returns the view_closed payload.
Signature
public void close()
Return Value
Type: void
getButtonByLabel(label)
Gets a button component by its label value.
Signature
public Slack.TestHarness.Button getButtonByLabel(String label)
Parameters
label
Type: String
Return Value
Type: Slack.TestHarness.Button
getCloseLabel()
Gets the close label for the modal.
Signature
public String getCloseLabel()
Return Value
Type: String
getComponent(idx, clazz)
Gets a child component in the given index on the modal component.
Signature
public Object getComponent(Integer idx, System.Type clazz)
Parameters
idx
Type: Integer
clazz
Type: System.Type
Return Value
Type: Object
getComponentByName(name, clazz)
Gets a child component on the modal component by name.
Signature
public Object getComponentByName(String name, System.Type clazz)
Parameters
name
Type: String
clazz
Type: System.Type
Return Value
Type: Object
getComponentCount()
Gets the number of child components for the modal component.
Signature
public Integer getComponentCount()
Return Value
Type: Integer
getInputByLabel(label)
Gets an input block component by its label value.
Signature
public Slack.TestHarness.Input getInputByLabel(String label)
Parameters
label
Type: String
Return Value
Type: Slack.TestHarness.Input
getInputError(inputBlockName)
Gets any input error for a given input block by name.
Signature
public String getInputError(String inputBlockName)
Parameters
inputBlockName
Type: String
Return Value
Type: String
getInputErrorBlocks()
Signature
public List<String> getInputErrorBlocks()
Return Value
Type: List<String>
getSubmitLabel()
Signature
public String getSubmitLabel()
Return Value
Type: String
getTitle()
Signature
public String getTitle()
Return Value
Type: String
hasInputErrors()
Signature
public Boolean hasInputErrors()
Return Value
Type: Boolean
submit()
Signature
public void submit()
Return Value
Type: void
TestHarness.Option Class
Represents an option component in a view for a test harness.
TestHarness.Option Methods
The following are methods for TestHarness.Option.
getDescription()
Gets the description for the option.
Signature
public String getDescription()
Return Value
Type: String
getIdentifier()
Gets the identifier for the option.
Signature
public String getIdentifier()
Return Value
Type: String
getLabel()
Gets the label for the option.
Signature
public String getLabel()
Return Value
Type: String
getUrl()
Gets the url for the option.
Signature
public String getUrl()
Return Value
Type: String
getValue()
Gets the value for the option.
Signature
public Boolean getValue()
Return Value
Type: Boolean
TestHarness.OptionGroup Class
Represents an option group component in a view for the test harness.
TestHarness.OptionGroup Methods
The following are methods for TestHarness.OptionGroup.
getLabel()
Gets the label for the option group.
Signature
public String getLabel()
Return Value
Type: String
getOptions()
Gets the list of options for the option group.
Signature
public List<Slack.TestHarness.Option> getOptions()
Return Value
Type: List<Slack.TestHarness.Option>
TestHarness.Overflow Class
Represents an overflow menu within a section or an actions component in a view for the test harness.
TestHarness.Overflow Methods
The following are methods for TestHarness.Overflow.
clickOption(idx)
Simulates clicking the component with the specified option index. If the component contains an onclick event, an action is fired.
Signature
public void clickOption(Integer idx)
Parameters
idx
Type: Integer
Return Value
Type: void
clickOption(option)
Simulates clicking the component with the specified option. If the component contains an onclick event, an action is fired.
Signature
public void clickOption(Slack.TestHarness.Option option)
Parameters
option
Type: Slack.TestHarness.Option
Return Value
Type: void
clickOption(identifier)
Simulates clicking the component with the specified option identifier. If the component contains an onclick event, an action is fired.
Signature
public void clickOption(String identifier)
Parameters
identifier
Type: String
Return Value
Type: void
getConfirm()
Gets the confirm composition object for the overflow menu.
Signature
public Slack.TestHarness.Confirm getConfirm()
Return Value
Type: Slack.TestHarness.Confirm
getName()
Gets the name for the overflow menu.
Signature
public String getName()
Return Value
Type: String
getOptions()
Gets the list of options for the overflow menu.
Signature
public List<Slack.TestHarness.Option> getOptions()
Return Value
Type: List<Slack.TestHarness.Option>
TestHarness.RadioGroup Class
Represents a radio group component
TestHarness.RadioGroup Methods
The following are methods for TestHarness.RadioGroup.
getConfirm()
Gets the confirm composition object for the radio group.
Signature
public Slack.TestHarness.Confirm getConfirm()
Return Value
Type: Slack.TestHarness.Confirm
getInitialValue()
Gets the initial value for the radio group.
Signature
public String getInitialValue()
Return Value
Type: String
getName()
Gets the name for the radio group.
Signature
public String getName()
Return Value
Type: String
getOptions()
Gets the list of options for the radio group.
Signature
public List<Slack.TestHarness.Option> getOptions()
Return Value
Type: List<Slack.TestHarness.Option>
getValue()
Gets the value for the radio group.
Signature
public String getValue()
Return Value
Type: String
setValue(identifier)
Sets the value for the radio group. If the radio group contains an onchange event, an action is fired.
Signature
public void setValue(String identifier)
Return Value
Type: void
TestHarness.Section Class
Represents a section component in a view for the test harness.
TestHarness.Section Methods
The following are methods for TestHarness.Section.
getComponent(idx, clazz)
Gets a child component in the given index on the section component.
Signature
public Object getComponent(Integer idx, System.Type clazz)
Parameters
idx
Type: Integer
clazz
Type: System.Type
getComponent(clazz)
Gets a child component on the section component.
Signature
public Object getComponent(System.Type clazz)
Parameters
clazz
Type: System.Type
Return Value
Type: Object
getComponentByName(name, clazz)
Gets a child component on the section component by name.
Signature
public Object getComponentByName(String name, System.Type clazz)
Parameters
name
Type: String
clazz
Type: System.Type
Return Value
Type: Object
getFieldCount()
Gets the field count for the section component.
Signature
public Integer getFieldCount()
Return Value
Type: Integer
getFieldText(idx)
Gets the field text for the section component at the specified index.
Signature
public String getFieldText(Integer idx)
Parameters
idx
Type: Integer
Return Value
Type: String
getName()
Gets the name for the section component.
Signature
public String getName()
Return Value
Type: String
getText()
Gets the text for the component.
Signature
public String getText()
Return Value
Type: String
TestHarness.SelectInput Class
Represents a select component in a view for the test harness.
TestHarness.SelectInput Methods
The following are methods for TestHarness.SelectInput.
getConfirm()
Gets the confirm composition object for the component.
Signature
public Slack.TestHarness.Confirm getConfirm()
Return Value
Type: Slack.TestHarness.Confirm
getInitialMultiselectValue()
Gets the initial value for the select component. If the component isn’t a multi-select, an exception is thrown.
Signature
public List<String> getInitialMultiselectValue()
Return Value
Type: List<String>
getInitialValue()
Gets the initial value for the select component. If the component is a multi-select, an exception is thrown.
Signature
public String getInitialValue()
Return Value
Type: String
getMaxSelection()
Gets the maxSelection value, which shows the maximum number of options that can be selected. Returns 1 if the component isn’t a multi-select.
Signature
public Integer getMaxSelection()
Return Value
Type: Integer
getMultiselectValue()
Gets the value for the select component. If the component isn’t a multi-select, an exception is thrown.
Signature
public List<String> getMultiselectValue()
Return Value
Type: List<String>
getName()
Gets the name of the select component.
Signature
public String getName()
Return Value
Type: String
getOptions()
Gets the list of options for the select component.
Signature
public List<Slack.TestHarness.Option> getOptions()
Return Value
Type: List<Slack.TestHarness.Option>
getOptionsGroups()
Gets the list of option groups for the select component.
Signature
public List<Slack.TestHarness.OptionGroup> getOptionsGroups()
Return Value
Type: List<Slack.TestHarness.OptionGroup>
getPlaceholder()
Gets the placeholder for the select component.
Signature
public String getPlaceholder()
Return Value
Type: String
getValue()
Gets the value for the select component.
Signature
public String getValue()
Return Value
Type: String
isMultiselect()
Returns true if the select component is a multi-select.
Signature
public Boolean isMultiselect()
Return Value
Type: Boolean
setMultiselectValue(listOfIdentifiers)
Sets the value of the select component. If the component contains an onchange event, an action is fired. If the component isn’t a multi-select, an exception is thrown.
Signature
public void setMultiselectValue(List<String> listOfIdentifiers)
Parameters
listOfIdentifiers
Type: List<String>
Return Value
Type: void
setValue(identifier)
Sets the value of the select component. If the component contains an onchange event, an action is fired. If the component is a multi-select, an exception is thrown.
Signature
public void setValue(String identifier)
Parameters
identifier
Type: String
Return Value
Type: void
TestHarness.State Class
Represents a Slack State that sets up your test harness.
TestHarness.State Methods
The following are methods for TestHarness.State.
clearAllClientMocks()
Signature
public void clearAllClientMocks()
Return Value
Type: void
clearAppClientMock()
Signature
public void clearAppClientMock()
Return Value
Type: void
clearBotClientMock()
Signature
public void clearBotClientMock()
Return Value
Type: void
clearUserClientMock()
Signature
public void clearUserClientMock()
Return Value
Type: void
createDirectChannel(user)
Creates a direct channel for the given user.
Signature
public Slack.TestHarness.Channel createDirectChannel(Slack.TestHarness.User user)
Parameters
user
Type: Slack.TestHarness.User
Return Value
Type: Slack.TestHarness.Channel
createEnterprise(enterpriseId, enterpriseName)
Creates an enterprise for the test harness.
Signature
public Slack.TestHarness.Enterprise createEnterprise(String enterpriseId, String enterpriseName)
Parameters
enterpriseId
Type: String
enterpriseName
Type: String
Return Value
Type: Slack.TestHarness.Enterprise
createEnterprise(enterpriseName)
Signature
public Slack.TestHarness.Enterprise createEnterprise(String enterpriseName)
Return Value
Type: Slack.TestHarness.Enterprise
createPrivateChannel(team, channelName, locale)
Signature
public Slack.TestHarness.Channel createPrivateChannel(Slack.TestHarness.Team team, String channelName, String locale)
Parameters
team
Type: Slack.TestHarness.Team
channelName
Type: String
locale
Type: String
Return Value
Type: Slack.TestHarness.Channel
createPrivateChannel(channelName)
Creates a private channel with the specified name.
Signature
public Slack.TestHarness.Channel createPrivateChannel(String channelName)
Parameters
channelName
Type: String
Return Value
Type: Slack.TestHarness.Channel
createPrivateChannel(team, channelName)
Creates a private channel for the default team.
Signature
public Slack.TestHarness.Channel createPrivateChannel(Slack.TestHarness.Team team, String channelName)
Parameters
team
Type: Slack.TestHarness.Team
channelName
Type: String
Return Value
Type: Slack.TestHarness.Channel
createPublicChannel(channelName)
Creates a public channel with the specified name.
Signature
public Slack.TestHarness.Channel createPublicChannel(String channelName)
Parameters
channelName
Type: String
Return Value
Type: Slack.TestHarness.Channel
createPublicChannel(team, channelName)
Creates a public channel for the specified team.
Signature
public Slack.TestHarness.Channel createPublicChannel(Slack.TestHarness.Team team, String channelName)
Parameters
team
Type: Slack.TestHarness.Team
channelName
Type: String
Return Value
Type: Slack.TestHarness.Channel
createTeam(teamDomain)
Creates a team for the default enterprise.
Signature
public Slack.TestHarness.Team createTeam(String teamDomain)
Parameters
teamDomain
Type: String
Return Value
Type: Slack.TestHarness.Team
createTeam(teamDomain, enterprise)
Creates a team using the specified enterprise name.
Signature
public Slack.TestHarness.Team createTeam(String teamDomain, Slack.TestHarness.Enterprise enterprise)
Parameters
teamDomain
Type: String
enterprise
Type: Slack.TestHarness.Enterprise
Return Value
Type: Slack.TestHarness.Team
createUser(username, name)
Creates a user on the default team.
Signature
public Slack.TestHarness.User createUser(String username, String name)
Parameters
username
Type: String
name
Type: String
Return Value
Type: Slack.TestHarness.User
createUser(username, name, team)
Creates a user on the specified team.
Signature
public Slack.TestHarness.User createUser(String username, String name, Slack.TestHarness.Team team)
Parameters
username
Type: String
name
Type: String
team
Type: Slack.TestHarness.Team
Return Value
Type:
createUserSession()
Creates a user session using the default user and default channel.
Signature
public Slack.TestHarness.UserSession createUserSession()
Return Value
Type: Slack.TestHarness.UserSession
createUserSession(user, defaultChannel)
Signature
public Slack.TestHarness.UserSession createUserSession(Slack.TestHarness.User user, Slack.TestHarness.Channel defaultChannel)
Parameters
user
Type: Slack.TestHarness.User
defaultChannel
Type: Slack.TestHarness.Channel
Return Value
Type: Slack.TestHarness.UserSession
getChannel(team, channelId)
Gets a channel based on its ID for the specified team.
Signature
public Slack.TestHarness.Channel getChannel(Slack.TestHarness.Team team, String channelId)
Parameters
team
Type: Slack.TestHarness.Team
Return Value
Type: Slack.TestHarness.Channel
getChannels(team)
Gets the list of channels for the specified team.
Signature
public List<Slack.TestHarness.Channel> getChannels(Slack.TestHarness.Team team)
Parameters
team
Type: Slack.TestHarness.Team
Return Value
Type: List<Slack.TestHarness.Channel>
getDefaultChannel()
Gets the default channel for the test harness.
Signature
public Slack.TestHarness.Channel getDefaultChannel()
Return Value
Type: Slack.TestHarness.Channel
getDefaultEnterprise()
Gets the default enterprise for the test harness.
Signature
public Slack.TestHarness.Enterprise getDefaultEnterprise()
Return Value
Type: Slack.TestHarness.Enterprise
getDefaultTeam()
Gets the default team for the test harness.
Signature
public Slack.TestHarness.Team getDefaultTeam()
Return Value
Type: Slack.TestHarness.Team
getDefaultUser()
Gets the default user for the test harness.
Signature
public Slack.TestHarness.User getDefaultUser()
Return Value
Type: Slack.TestHarness.User
getLocale()
Signature
public String getLocale()
Return Value
Type: String
getUser(team, username)
Gets a user for the test harness.
Signature
public Slack.TestHarness.User getUser(Slack.TestHarness.Team team, String username)
Parameters
team
Type: Slack.TestHarness.Team
username
Type: String
Return Value
Type: Slack.TestHarness.User
getUserByUsername(team, username)
Signature
public Slack.TestHarness.User getUserByUsername(Slack.TestHarness.Team team, String username)
Parameters
team
Type: Slack.TestHarness.Team
username
Type: String
Return Value
Type: Slack.TestHarness.User
getUsers(team)
Signature
public List<Slack.TestHarness.User> getUsers(Slack.TestHarness.Team team)
Parameters
team
Type: Slack.TestHarness.Team
Return Value
Type: List<Slack.TestHarness.User>
setAppClientMock(appClientMock)
Signature
public void setAppClientMock(Slack.AppClientMock appClientMock)
Parameters
appClientMock
Type: Slack.AppClientMock
Return Value
Type: void
setBotClientMock(botClientMock)
Signature
public void setBotClientMock(Slack.BotClientMock botClientMock)
Parameters
botClientMock
Type: Slack.BotClientMock
Return Value
Type: void
setLocale(locale)
Signature
public void setLocale(String locale)
Parameters
locale
Type: String
Return Value
Type: void
setUserClientMock(userClientMock)
Signature
public void setUserClientMock(Slack.UserClientMock userClientMock)
Parameters
userClientMock
Type: Slack.UserClientMock
Return Value
Type: void
TestHarness.Team Class
Represents a team or workspace for the test harness.
TestHarness.Team Methods
The following are methods for TestHarness.Team.
getChannels()
Gets the list of channels for the team.
Signature
public List<Slack.TestHarness.Channel> getChannels()
Type: List<Slack.TestHarness.Channel>
getEnterprise()
Gets the enterprise for the team.
Signature
public Slack.TestHarness.Enterprise getEnterprise()
Return Value
Type: Slack.TestHarness.Enterprise
getId()
Gets the ID for the team.
Signature
public String getId()
Return Value
Type: String
getTeamDomain()
Gets the domain for the team.
Signature
public String getTeamDomain()
Return Value
Type: String
TestHarness.Text Class
Represents a text component in a view for a test harness.
TestHarness.Text Methods
The following are methods for TestHarness.Text.
getText()
Gets the text for the component.
Signature
public String getText()
Return Value
Type: String
TestHarness.TextInput Class
Represents the text input component in a view for the test harness.
TestHarness.TextInput Methods
The following are methods for TestHarness.TextInput.
getInitialValue()
Gets the initial value for the text input component.
Signature
public String getInitialValue()
Return Value
Type: String
getMaxLength()
Gets the maximum length for the text input component.
Signature
public Integer getMaxLength()
Return Value
Type: Integer
getMinLength()
Gets the minimum length for the text input component.
Signature
public Integer getMinLength()
Return Value
Type: Integer
getName()
Gets the name for the text input component.
Signature
public String getName()
Return Value
Type: String
getPlaceholder()
Gets the placeholder for the text input component.
Signature
public String getPlaceholder()
Return Value
Type: String
getValue()
Gets the value for the text input component.
Signature
public String getValue()
Return Value
Type: String
isMultiline()
Gets the multiline value for the text input component.
Signature
public Boolean isMultiline()
Return Value
Type: Boolean
setValue(value)
Sets the value for the text input component.
Signature
public void setValue(String value)
Return Value
Type: String
TestHarness.TimePicker Class
Represents the time picker component in a view for the test harness.
TestHarness.TimePicker Methods
The following are methods for TestHarness.TimePicker.
getConfirm()
Gets the confirm composition object for the time picker component.
Signature
public Slack.TestHarness.Confirm getConfirm()
Return Value
Type: Slack.TestHarness.Confirm
getInitialValue()
Gets the initial value for the time picker component.
Signature
public String getInitialValue()
Return Value
Type: String
getName()
Gets the name for the time picker component.
Signature
public String getName()
Return Value
Type: String
getPlaceholder()
Gets the placeholder for the time picker component.
Signature
public String getPlaceholder()
Return Value
Type: String
getValue()
Gets the value for the time picker component.
Signature
public String getValue()
Return Value
Type: String
setValue(value)
Sets the value for the time picker component.
Signature
public void setValue(String value)
Return Value
Type: void
TestHarness.User Class
Represents a Slack user for the test harness.
TestHarness.User Methods
The following are methods for TestHarness.User.
getId()
Gets the ID for the user.
Signature
public String getId()
Return Value
Type: String
getLocale()
Signature
public String getLocale()
Return Value
Type: String
getName()
Gets the name for the user.
Signature
public String getName()
Return Value
Type: String
getTeam()
Gets the team for the user.
Signature
public Slack.TestHarness.Team getTeam()
Return Value
Type: Slack.TestHarness.Team
getUsername()
Gets the username for the user.
Signature
public String getUsername()
Return Value
Type: String
TestHarness.UserSession Class
Represents a user session that denotes a user interacting with Slack using a client, maintaining session-specific state such as an open channel or modal.
TestHarness.UserSession Methods
The following are methods for TestHarness.UserSession.
closeAllModals()
Simulates closing all modals in the modal stack for the user session.
Signature
public void closeAllModals()
Return Value
Type: void
closeModal()
Simulates closing the currently visible modal on top of the modal stack for the user session.
Signature
public void closeModal()
Return Value
Type: void
executeEvent(event, slackApp)
Executes an event in the context of an existing user session. The session is used to retrieve the user, team, and enterprise to set on the request. The session is also used for any relevant input or output context for the specific event.
Signature
public void executeEvent(Slack.Event event, Slack.App slackApp)
Parameters
event
Type: Slack.Event
slackApp
Type: Slack.App
Return Value
Type: void
executeGlobalShortcut(globalShortcut, slackApp)
Simulates executing a global shortcut for the user session.
Signature
public void executeGlobalShortcut(String globalShortcut, Slack.App slackApp)
Parameters
globalShortcut
Type: String
slackApp
Type: Slack.App
Return Value
Type: void
executeMessageShortcut(messageShortcut, message, slackApp)
Simulates executing a message shortcut for a given message for the user session.
Signature
public void executeMessageShortcut(String messageShortcut, Slack.TestHarness.Message message, Slack.App slackApp)
Parameters
messageShortcut
Type: String
message
Type: Slack.TestHarness.Message
slackApp
Type: Slack.App
Return Value
Type: void
executeSlashCommand(command, slackApp)
Simulates executing a slash command on the given Slack app ID for the user session.
Signature
public void executeSlashCommand(String command, Slack.App slackApp)
Parameters
command
Type: String
slackApp
Type: Slack.App
Return Value
Type: void
executeSlashCommand(command, text, slackApp)
Simulates executing a slash command with a text payload for the user session.
Signature
public void executeSlashCommand(String command, String text, Slack.App slackApp)
Parameters
command
Type: String
text
Type: String
slackApp
Type: Slack.App
Return Value
Type: void
getAppHome()
Gets the open app home for the user session.
Signature
public Slack.TestHarness.Home getAppHome()
Return Value
Type: Slack.TestHarness.Home
getMessageCount()
Gets the message count for the user session.
Signature
public Integer getMessageCount()
Return Value
Type: Integer
getMessages()
Gets the list of messages for the user session.
Signature
public List<Slack.TestHarness.Message> getMessages()
Return Value
Type: List<Slack.TestHarness.Message>
getModalStack()
Gets the list of modals in stack order for the user session.
Signature
public List<Slack.TestHarness.Modal> getModalStack()
Return Value
Type: List<Slack.TestHarness.Modal>
getOpenChannel()
Gets the open channel for the user session.
Signature
public Slack.TestHarness.Channel getOpenChannel()
Return Value
Type: Slack.TestHarness.Channel
getState()
Gets the Slack state.
Signature
public Slack.TestHarness.State getState()
Return Value
Type: Slack.TestHarness.State
getTopModal()
Gets the open modal on top of the modal stack for the user session.
Signature
public Slack.TestHarness.Modal getTopModal()
Return Value
Type: Slack.TestHarness.Modal
getUser()
Gets the user for the user session.
Signature
public Slack.TestHarness.User getUser()
Return Value
Type: Slack.TestHarness.User
openAppHome(slackApp)
Simulates opening the app home for a given app ID for the user session.
Signature
public Slack.TestHarness.Home openAppHome(Slack.App slackApp)
Parameters
slackApp
Type: Slack.App
Return Value
Type: Slack.TestHarness.Home
openChannel(channelId)
Simulates opening a channel for the given channel ID for the user session.
Signature
public Slack.TestHarness.Channel openChannel(String channelId)
Parameters
channelId
Type: String
Return Value
Type: Slack.TestHarness.Channel
postMessage(message)
Simulates posting a message to the open channel for the user session.
Signature
public Slack.TestHarness.Message postMessage(String message)
Parameters
message
Type: String
Return Value
Type: Slack.TestHarness.Message
TestHarness.UsersSelect Class
Represents a users select component in a view for the test harness.
TestHarness.UsersSelect Methods
The following are methods for TestHarness.UsersSelect.
getConfirm()
Gets the confirm composition object for the users select component.
Signature
public Slack.TestHarness.Confirm getConfirm()
Return Value
Type: Slack.TestHarness.Confirm
getInitialMultiselectValue()
Gets the initial value for the users select component. If the component isn’t a multi-select, an exception is thrown.
Signature
public List<String> getInitialMultiselectValue()
Return Value
Type: List<String>
getInitialValue()
Gets the initial value for the users select component. If the component is a multi-select, an exception is thrown.
Signature
public void getInitialValue()
Return Value
Type: void
getMaxSelection()
Gets the resolved max selection for the users select component. Returns 1 if the component isn’t a multi-select.
Signature
public Integer getMaxSelection()
Return Value
Type: Integer
getMultiselectValue()
Gets the value for the users select component. If the component isn’t a multi-select, an exception is thrown.
Signature
public List<String> getMultiselectValue()
Return Value
Type: List<String>
getName()
Gets the name for the users select component.
Signature
public String getName()
Return Value
Type: String
getOptions()
Gets the list of options for the users select component.
Signature
public List<Slack.TestHarness.Option> getOptions()
Return Value
Type: List<Slack.TestHarness.Option>
getPlaceholder()
Gets the placeholder for the users select component.
Signature
public String getPlaceholder()
Return Value
Type: String
getValue()
Gets the value for the users select component.
Signature
public String getValue()
Return Value
Type: String
isMultiselect()
Gets the value for the users select component. If the component isn’t a multi-select, an exception is thrown.
Signature
public Boolean isMultiselect()
Return Value
Type: Boolean
setMultiselectValue(listOfIdentifiers)
Sets the value of the users select component. If the component contains an onchange event, an action is fired. If the component isn’t a multi-select, an exception is thrown.
Signature
public void setMultiselectValue(List<String> listOfIdentifiers)
Parameters
listOfIdentifiers
Type: List<String>
Return Value
Type: void
setValue(identifier)
Sets the value of the users select component. If the component contains an onchange event, an action is fired. If the component is a multi-select, an exception is thrown.
Signature
public void setValue(String identifier)
Parameters
identifier
Type: String
Return Value
Type: void