Work with the Test Harness

Use the TestHarness class to test your Apex SDK for Slack apps.

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

Return Value

Type: Slack.TestHarness.State

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 click on a modal or querying an external select component.

The Slack.TestHarness.Actions object is returned as a modal 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

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

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

Return Value

Type: Integer

getName()

Signature

Return Value

Type: String

Represents a button component in a view for the test harness.

TestHarness.Button Methods

The following are methods for TestHarness.Button.

click()

Simulates clicking on the button.

Signature

Return Value

Type: void

getConfirm()

Gets the confirm composition object for the button.

Signature

Return Value

Type: Slack.TestHarness.Confirm

getLabel()

Gets the label for the button.

Signature

Return Value

Type: String

getName()

Gets the name for the button.

Signature

Return Value

Type: String

getStyle()

Gets the style for the button.

Signature

Return Value

Type: String

getUrl()

Gets the URL for the button.

Signature

Return Value

Type: String

getValue()

Gets the value for the button.

Signature

Return Value

Type: String

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

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 whether or not the channel can be opened by the specified user.

Signature

Parameters

user

Type: Slack.TestHarness.User

getId()

Gets the channel ID.

Signature

Return Value

Type: String

getMessageCount(user)

Gets the message count on the channel for the specified user.

Signature

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

Parameters

user

Type: Slack.TestHarness.User

Return Value

Type: List<Slack.TestHarness.Message>

getName()

Gets the name for the channel.

Signature

Return Value

Type: String

getTeam()

Gets the team for the channel.

Signature

Return Value

Type: Slack.TestHarness.Team

isPrivate()

Returns true if the channel is private, or false otherwise.

Signature

Return Value

Type: Boolean

removeUser(user)

Removes the specified user from the channel.

Signature

Parameters

user

Type: Slack.TestHarness.User

Return Value

Type: void

sendMessage(userSession, text)

Simulates sending a message to the channel from the users session.

Signature

Parameters

userSession

Type: Slack.TestHarness.UserSession

Add parameter description.

text

Type: String

Add parameter description.

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

Return Value

Type: Slack.TestHarness.Confirm

getDescription()

Gets the description for the checkbox.

Signature

Return Value

Type: String

getInitialValue()

Gets the initial value for the checkbox.

Signature

Return Value

Type: Boolean

getLabel()

Gets the label for the checkbox.

Signature

getName()

Gets the name of the checkbox.

Signature

Return Value

Type: String

getValue()

Gets the value of the checkbox.

Signature

Return Value

Type: Boolean

setValue(value)

Sets the value of the checkbox. If the checkbox contains an onchange event, an action is fired.

Signature

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

Return Value

Type: void

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

Return Value

Type: Slack.TestHarness.Confirm

getInitialValue()

Gets the initial value for the checkbox group.

Signature

Return Value

Type: List<String>

getName()

Gets the name of the checkbox group.

Signature

Return Value

Type: String

getOptions()

Gets the list of options for the checkbox group.

Signature

Return Value

Type: List<Slack.TestHarness.Option>

getValue()

Gets the value of the checkbox group.

Signature

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

Parameters

listOfIdentifiers

Type: List<String>

Return Value

Type: void

toggleValue(option)

Signature

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

Parameters

identifier

Type: String

Return Value

Type: void

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

Return Value

Type: String

getDeny()

Gets the deny button text.

Signature

Return Value

Type: String

getStyle()

Gets the confirmation style.

Signature

Return Value

Type: String

getText()

Gets the confirmation dialog text.

Signature

Return Value

Type: String

getTitle()

Gets the confirmation dialog title.

Signature

Return Value

Type: String

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

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

Return Value

Type: Integer

getName()

Gets the name of the context component.

Signature

Return Value

Type: String

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

Return Value

Type: Slack.TestHarness.Confirm

getFilter()

Gets the filter composition object for the conversations select.

Signature

Return Value

Type: Slack.TestHarness.Filter

getInitialMultiselectValue()

Gets the initial value for the conversations select. If the component is not a multi-select, an exception is thrown.

Signature

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

Return Value

Type: String

getMaxSelection()

Gets the max selection for the conversations select. Returns 1 if the component is not a multi-select.

Signature

Return Value

Type: Integer

getMultiselectValue()

Gets the value for the conversations select. If the component is not a multi-select, an exception is thrown.

Signature

Return Value

Type: List<String>

getName()

Gets the name for the conversations select.

Signature

Return Value

Type: String

getOptions()

Gets the list of options for the conversations select.

Signature

Return Value

Type: List<Slack.TestHarness.Option>

getPlaceholder()

Gets the placeholder for the conversations select.

Signature

Return Value

Type: String

getValue()

Gets the value for the component. If the component is a multi-select, an exception is thrown.

Signature

Return Value

Type: String

isMultiselect()

Returns true if the conversations select is a multi-select.

Signature

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 is not a multi-select, an exception is thrown.

Signature

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

Parameters

identifier

Type: String

Represents a datasource composition object for the test harness.

TestHarness.Datasource Methods

The following are methods for TestHarness.Datasource.

getDefinition()

Signature

Return Value

Type: String

getProperties()

Signature

Return Value

Type: Map<String,Object>

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

Return Value

Type: Slack.TestHarness.Confirm

getInitialValue()

Gets the initial value for the date picker.

Signature

Return Value

Type: String

getName()

Gets the name for the date picker.

Signature

Return Value

Type: String

getPlaceholder()

Gets the placeholder for the date picker.

Return Value

Type: String

getValue()

Gets the value for the date picker.

Signature

Return Value

Type: String

setValue(value)

Sets the value for the date picker.

Signature

Parameters

value

Type: String

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

Return Value

Type: Slack.TestHarness.Confirm

getDateLabel()

Gets the label for the date input.

Signature

Return Value

Type: String

getInitialValue()

Gets the initial value for the date time picker.

Signature

Return Value

Type: String

getName()

Gets the name for the date time picker.

Signature

Return Value

Type: String

getPlaceholder()

Gets the placeholder for the date time picker.

Signature

Return Value

Type: String

getRequired()

Gets the required value for the date time picker.

Signature

Return Value

Type: Boolean

getSubmissionName()

Gets the submission name for the date time picker.

Signature

Return Value

Type: String

getTimeLabel()

Gets the label for the time input.

Signature

Return Value

Type: String

getValue()

Gets the value for the date time picker.

Signature

Return Value

Type: String

setDateValue(value)

Sets the date value on the component.

Signature

Parameters

value

Type: String

Return Value

Type: void

setTimeValue(value)

Sets the time value on the component.

Signature

Parameters

value

Type: String

Return Value

Type: void

setValue(value)

Sets the value for the date time picker.

Signature

Parameters

value

Type: String

Return Value

Type: void

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

Return Value

Type: String

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

Return Value

Type: String

getName()

Gets the name for the enterprise.

Signature

Return Value

Type: String

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

Return Value

Type: Slack.TestHarness.Confirm

getDatasource()

Gets the datasource composition object for the external select.

Signature

Return Value

Type: Slack.TestHarness.Datasource

getInitialMultiselectValue()

Gets the initial value for the external select. If the component is not a multi-select, an exception is thrown.

Signature

Return Value

getInitialOptions()

Gets the initial list of resolved options for the component.

Signature

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

Return Value

Type: String

getMaxSelection()

Gets the max selection for the external select. Returns 1 if the component is not a multi-select.

Signature

Return Value

Type: Integer

getMinQueryLength()

Gets the min query length for the external select.

Signature

Return Value

Type: Integer

getMultiselectValue()

Gets the value for the external select. If the component is not a multi-select, an exception is thrown.

Signature

Return Value

Type: List<String>

getName()

Gets the name for the external select.

Signature

Return Value

Type: String

getOptions()

Gets the list of options for the external select.

Signature

Return Value

Type: List<Slack.TestHarness.Option>

getPlaceholder()

Gets the placeholder for the external select.

Signature

Return Value

Type: String

getValue()

Gets the value for the external select. If the component is a multi-select, an exception is thrown.

Signature

Return Value

Type: String

isMultiselect()

Returns true if the external select is a multi-select.

Signature

Return Value

Type: Boolean

query(query)

Simulates a query on the external select. If the min query length is not met, an exception is thrown.

Signature

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 is not a multi-select, an exception is thrown.

Signature

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

Parameters

identifier

Type: String

Return Value

Type: void

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

Return Value

Type: Boolean

getExcludeExternalShared()

Gets the resolved exclude external shared value for the filter object.

Signature

Return Value

Type: Boolean

getInclude()

Gets the include list for the filter object.

Signature

Return Value

Type: List<String>

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

Return Value

Type: String

getText()

Gets the text for the header.

Signature

Return Value

Type: String

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

Return Value

Type: Slack.TestHarness.Button

getComponent(idx, clazz)

Gets a child component on the home component.

Signature

Parameters

idx

Type: Integer

clazz

Type: System.Type

Return Value

Type: Object

getComponentCount()

Gets the number of child components on the home component.

Signature

Return Value

Type: Integer

getInputByLabel(label)

Signature

Parameters

label

Type: String

Return Value

Type: Slack.TestHarness.Input

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

Return Value

Type: String

getImageUrl()

Gets the URL for the image.

Signature

Return Value

Type: String

getName()

Gets the name for the image.

Signature

Return Value

Type: String

getTitle()

Gets the title for the image.

Signature

Return Value

Type: String

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

Return Value

Type: String

getImageUrl()

Gets the URL for the inline image.

Signature

Return Value

Type: String

getName()

Gets the name for the inline image.

Signature

Return Value

Type: String

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

Parameters

clazz

Type: System.Type

Return Value

Type: Object

getComponentByName(name, clazz)

Gets a child component on the input component by name.

Signature

Parameters

name

Type: String

clazz

Type: System.Type

Return Value

Type: Object

getHint()

Gets the hint for the input component.

Signature

Return Value

Type: String

getLabel()

Gets the label for the input component.

Signature

Return Value

Type: String

getName()

Gets the name for the input component.

Signature

Return Value

Type: String

isRequired()

Returns true if the input component is required.

Signature

Return Value

Type: Boolean

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

Parameters

user

Type: Slack.TestHarness.User

Return Value

Type: Boolean

getButtonByLabel(label)

Gets a button component by its label value.

Signature

Parameters

label

Type: String

Return Value

Type: Slack.TestHarness.Button

getChannel()

Gets the channel value for the message.

Signature

Return Value

Type: Slack.TestHarness.Channel

getComponent(idx, clazz)

Gets a child component in a given index on the message component.

Signature

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

Return Value

Type: String

getComponentCount()

Gets the number of child components for the message component.

Signature

Return Value

Type: Integer

getInputByLabel(label)

Gets the input component by label for the message component.

Signature

Parameters

label

Type: String

Return Value

Type: Slack.TestHarness.Input

getMessageTs()

Gets the timestamp for the message.

Signature

Return Value

Type: String

getText()

Gets the text for the message.

Signature

Return Value

Type: String

isEphemeralMessage()

Returns true if the message is ephemeral.

Signature

Return Value

Type: Boolean

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

Return Value

Type: void

getButtonByLabel(label)

Gets a button component by its label value.

Signature

Parameters

label

Type: String

Return Value

Type: Slack.TestHarness.Button

getCloseLabel()

Gets the close label for the modal.

Signature

Return Value

Type: String

getComponent(idx, clazz)

Gets a child component in the given index on the modal component.

Signature

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

Parameters

name

Type: String

clazz

Type: System.Type

Return Value

Type: Object

getComponentCount()

Gets the number of child components for the modal component.

Signature

Return Value

Type: Integer

getInputByLabel(label)

Gets an input block component by its label value.

Signature

Parameters

label

Type: String

Return Value

Type: Slack.TestHarness.Input

getInputError(inputBlockName)

Gets any input error for a given input block by name.

Signature

Parameters

inputBlockName

Type: String

Return Value

Type: String

getSubmitLabel()

Signature

Return Value

Type: String

getTitle()

Signature

Return Value

Type: String

hasInputErrors()

Signature

Return Value

Type: Boolean

submit()

Signature

Return Value

Type: void

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

Return Value

Type: String

getIdentifier()

Gets the identifier for the option.

Signature

Return Value

Type: String

getLabel()

Gets the label for the option.

Signature

Return Value

Type: String

getUrl()

Gets the url for the option.

Signature

Return Value

Type: String

getValue()

Gets the value for the option.

Signature

Return Value

Type: Boolean

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

Return Value

Type: String

getOptions()

Gets the list of options for the option group.

Signature

Return Value

Type: List<Slack.TestHarness.Option>

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

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

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

Parameters

identifier

Type: String

Return Value

Type: void

getConfirm()

Gets the confirm composition object for the overflow menu.

Signature

Return Value

Type: Slack.TestHarness.Confirm

getName()

Gets the name for the overflow menu.

Signature

Return Value

Type: String

getOptions()

Gets the list of options for the overflow menu.

Signature

Return Value

Type: List<Slack.TestHarness.Option>

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

Return Value

Type: Slack.TestHarness.Confirm

getInitialValue()

Gets the initial value for the radio group.

Signature

Return Value

Type: String

getName()

Gets the name for the radio group.

Signature

Return Value

Type: String

getOptions()

Gets the list of options for the radio group.

Signature

Return Value

Type: List<Slack.TestHarness.Option>

getValue()

Gets the value for the radio group.

Signature

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

Return Value

Type: void

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

Parameters

idx

Type: Integer

clazz

Type: System.Type

getComponent(clazz)

Gets a child component on the section component.

Signature

Parameters

clazz

Type: System.Type

Return Value

Type: Object

getComponentByName(name, clazz)

Gets a child component on the section component by name.

Signature

Parameters

name

Type: String

clazz

Type: System.Type

Return Value

Type: Object

getFieldCount()

Gets the field count for the section component.

Signature

Return Value

Type: Integer

getFieldText(idx)

Gets the field text for the section component at the specified index.

Signature

Parameters

idx

Type: Integer

Return Value

Type: String

getName()

Gets the name for the section component.

Signature

Return Value

Type: String

getText()

Gets the text for the component.

Signature

Return Value

Type: String

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

Return Value

Type: Slack.TestHarness.Confirm

getInitialMultiselectValue()

Gets the initial value for the select component. If the component is not a multi-select, an exception is thrown.

Signature

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

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 is not a multi-select.

Signature

Return Value

Type: Integer

getMultiselectValue()

Gets the value for the select component. If the component is not a multi-select, an exception is thrown.

Signature

Return Value

Type: List<String>

getName()

Gets the name of the select component.

Signature

Return Value

Type: String

getOptions()

Gets the list of options for the select component.

Signature

Return Value

Type: List<Slack.TestHarness.Option>

getOptionsGroups()

Gets the list of option groups for the select component.

Signature

Return Value

Type: List<Slack.TestHarness.OptionGroup>

getPlaceholder()

Gets the placeholder for the select component.

Signature

Return Value

Type: String

getValue()

Gets the value for the select component.

Signature

Return Value

Type: String

isMultiselect()

Returns true if the select component is a multi-select.

Signature

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 is not a multi-select, an exception is thrown.

Signature

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

Parameters

identifier

Type: String

Return Value

Type: void

Represents a Slack State that sets up your test harness.

TestHarness.State Methods

The following are methods for TestHarness.State.

createDirectChannel(user)

Creates a direct channel for the given user.

Signature

Parameters

user

Type: Slack.TestHarness.User

Return Value

Type: Slack.TestHarness.Channel

createEnterprise(enterpriseId, enterpriseName)

Creates an enterprise for the test harness.

Signature

Parameters

enterpriseId

Type: String

enterpriseName

Type: String

Return Value

Type: Slack.TestHarness.Enterprise

createPrivateChannel(channelName)

Creates a private channel with the specified name.

Signature

Parameters

channelName

Type: String

Return Value

Type: Slack.TestHarness.Channel

createPrivateChannel(team, channelName)

Creates a private channel for the default team.

Signature

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

Parameters

channelName

Type: String

Return Value

Type: Slack.TestHarness.Channel

createPublicChannel(team, channelName)

Creates a public channel for the specified team.

Signature

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

Parameters

teamDomain

Type: String

Return Value

Type: Slack.TestHarness.Team

createTeam(teamDomain, enterprise)

Creates a team using the specified enterprise name.

Signature

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

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

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

Return Value

Type: Slack.TestHarness.UserSession

createUserSession(user, defaultChannel)

Signature

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

Parameters

team

Type: Slack.TestHarness.Team

Return Value

Type: Slack.TestHarness.Channel

getChannels(team)

Gets the list of channels for the specified team.

Signature

Parameters

team

Type: Slack.TestHarness.Team

Return Value

Type: List<Slack.TestHarness.Channel>

getDefaultChannel()

Gets the default channel for the test harness.

Signature

Return Value

Type: Slack.TestHarness.Channel

getDefaultEnterprise()

Gets the default enterprise for the test harness.

Signature

Return Value

Type: Slack.TestHarness.Enterprise

getDefaultTeam()

Gets the default team for the test harness.

Signature

Return Value

Type: Slack.TestHarness.Team

getDefaultUser()

Gets the default user for the test harness.

Signature

Return Value

Type: Slack.TestHarness.User

getUser(team, username)

Gets a user for the test harness.

Signature

Parameters

team

Type: Slack.TestHarness.Team

username

Type: String

Return Value

Type: Slack.TestHarness.User

getUsers(team)

Signature

Parameters

team

Type: Slack.TestHarness.Team

Return Value

Type: List<Slack.TestHarness.User>

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

Type: List<Slack.TestHarness.Channel>

getEnterprise()

Gets the enterprise for the team.

Signature

Return Value

Type: Slack.TestHarness.Enterprise

getId()

Gets the ID for the team.

Signature

Return Value

Type: String

getTeamDomain()

Gets the domain for the team.

Signature

Return Value

Type: String

Represents a text component in a view for a test harness.

TestHarness.Text Methods

The following are methods for TestHarness.Text.

getName()

Gets the name of the text component.

Signature

Return Value

Type: String

getText()

Gets the text for the component.

Signature

Return Value

Type: String

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

Return Value

Type: String

getMaxLength()

Gets the maximum length for the text input component.

Signature

Return Value

Type: Integer

getMinLength()

Gets the minimum length for the text input component.

Signature

Return Value

Type: Integer

getName()

Gets the name for the text input component.

Signature

Return Value

Type: String

getPlaceholder()

Gets the placeholder for the text input component.

Signature

Return Value

Type: String

getValue()

Gets the value for the text input component.

Signature

Return Value

Type: String

isMultiline()

Gets the multiline value for the text input component.

Signature

Return Value

Type: Boolean

setValue(value)

Sets the value for the text input component.

Signature

Return Value

Type: String

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

Return Value

Type: Slack.TestHarness.Confirm

getInitialValue()

Gets the initial value for the time picker component.

Signature

Return Value

Type: String

getName()

Gets the name for the time picker component.

Signature

Return Value

Type: String

getPlaceholder()

Gets the placeholder for the time picker component.

Signature

Return Value

Type: String

getValue()

Gets the value for the time picker component.

Signature

Return Value

Type: String

setValue(value)

Sets the value for the time picker component.

Signature

Return Value

Type: void

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

Return Value

Type: String

getName()

Gets the name for the user.

Signature

Return Value

Type: String

getTeam()

Gets the team for the user.

Signature

Return Value

Type: Slack.TestHarness.Team

getUsername()

Gets the username for the user.

Signature

Return Value

Type: String

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

Return Value

Type: void

closeModal()

Simulates closing the currently visible modal on top of the modal stack for the user session.

Signature

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

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

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

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

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

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

Return Value

Type: Slack.TestHarness.Home

getMessageCount()

Gets the message count for the user session.

Signature

Return Value

Type: Integer

getMessages()

Gets the list of messages for the user session.

Signature

Return Value

Type: List<Slack.TestHarness.Message>

getModalStack()

Gets the list of modals in stack order for the user session.

Signature

Return Value

Type: List<Slack.TestHarness.Modal>

getOpenChannel()

Gets the open channel for the user session.

Signature

Return Value

Type: Slack.TestHarness.Channel

getState()

Gets the Slack state.

Signature

Return Value

Type: Slack.TestHarness.State

getTopModal()

Gets the open modal on top of the modal stack for the user session.

Signature

Return Value

Type: Slack.TestHarness.Modal

getUser()

Gets the user for the user session.

Signature

Return Value

Type: Slack.TestHarness.User

openAppHome(slackApp)

Simulates opening the app home for a given app ID for the user session.

Signature

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

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

Parameters

message

Type: String

Return Value

Type: Slack.TestHarness.Message

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

Return Value

Type: Slack.TestHarness.Confirm

getInitialMultiselectValue()

Gets the initial value for the users select component. If the component is not a multi-select, an exception is thrown.

Signature

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

Return Value

Type: void

getMaxSelection()

Gets the resolved max selection for the users select component. Returns 1 if the component is not a multi-select.

Signature

Return Value

Type: Integer

getMultiselectValue()

Gets the value for the users select component. If the component is not a multi-select, an exception is thrown.

Signature

Return Value

Type: List<String>

getName()

Gets the name for the users select component.

Signature

Return Value

Type: String

getOptions()

Gets the list of options for the users select component.

Signature

Return Value

Type: List<Slack.TestHarness.Option>

getPlaceholder()

Gets the placeholder for the users select component.

Signature

Return Value

Type: String

getValue()

Gets the value for the users select component.

Signature

Return Value

Type: String

isMultiselect()

Gets the value for the users select component. If the component is not a multi-select, an exception is thrown.

Signature

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 is not a multi-select, an exception is thrown.

Signature

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

Parameters

identifier

Type: String

Return Value

Type: void