Library for testing interactive Slack applications.

Slackster

Library for testing interactive Slack applications.

  • Mock Slack API: user info, post and update message, publish view.
  • Testing Slack UI in the home tab or in message blocks (button/input/etc.). No dependency on Slack API.
  • Integration with GO testing library.

⚠️ This tool is still under heavy development! See our roadmap for help us ⚠️

Motivation

Slack has a great API for building interactive apps (https://api.slack.com/block-kit), but no tools to test it. Via Slackster you can do it.

Usage

func TestSimple(t *testing.T) {
	teamId := fmt.Sprintf("%v", time.Now().UnixNano())
	client := slackster.NewClient("http://localhost:4000/api/slack/events", "http://localhost:4000/api/slack/actions", "your_secret_key", teamId)
	if err := client.Start(":4999"); err != nil {
		panic(err)
	}

	client.RegisterUser(&slack.User{
		ID:      "first",
		Name:    "First First",
		IsAdmin: true,
	})

	client.RegisterUser(&slack.User{
		ID:      "second",
		Name:    "Second Second",
		IsAdmin: false,
	})

	user := client.User(t, "first")

	user.HomeOpen(t)
	user.ClickByText(t, "Start button", true) // true for wait modal
	user.SelectUserByText(t, "User select", "")
	user.Type(t, "Input with label", "hello man") // type input text
	user.SubmitForm()
	user.WaitHomeUpdate()

	secondUser := client.User(t, "second")

	lastMessage := secondUser.Messages().Last()
	assert.NotNil(t, lastMessage)

	lastMessage.SearchByText(t, "hello man") // search text in received messages
}

And use http://localhost:4999 for fully mock Slack API

package main

import (
	"github.com/slack-go/slack"
)

func main() {
	api := slack.New("YOUR_TOKEN_HERE", slack.OptionAPIURL("http://localhost:4999"))
}

Available methods

Method Description
ClickByText(t *testing.T, text string, waitModal bool) Find button with text and click on it. And wait modal if need be.
SearchByText(t *testing.T, text string) interface{} Find element with text, and return slack element (https://github.com/slack-go/slack)
Type(t *testing.T, searchText string, value string) interface{} Find input with text, and type value.
SubmitForm() Submit view form.
WaitHomeUpdate() Wait any home update (publish view)
ClickByActionId(t *testing.T, actionId string, value string, waitModal bool) Find button by action, and click on it.
SelectUserByText (t *testing.T, text string, user string) Find user select by text in placeholder, and select user.
SelectUsersByText (t *testing.T, text string, users []string) Find multi user select by text in placeholder, and select users.
SelectByText (t *testing.T, searchText string, value string) Find select by text in placeholder, and select option by value
Messages() Messages Get a message for the user. Any message is a page with all the above methods
Similar Resources

Golang bot that connects to slack using Socketclient to read and write messages.

Golang bot that connects to slack using Socketclient to read and write messages.

🚀 (not)simple go project 🚀 Golang bot that connects to slack using Socketclient to read and write messages. 🏆 Use 🏆 @SquidBot : Mentions your name

Aug 23, 2022

Send Slack reports of pull requests pending review

Send Slack reports of pull requests pending review

preport Born out of a desire to get pull requests reviewed faster without having to send manual reminders, preport generates reports of GitLab pull re

Nov 23, 2021

Notify Slack about KPIs test

Notify Slack about KPIs test

This action is a part of GitHub Actions Library created by rtCamp. Slack Notify - GitHub Action A GitHub Action to send a message to a Slack channel.

Jan 10, 2022

Send Linux mails to Slack with golang

LinuxMailToSlack Install go install github.com/TKMAX777/MailToSlack@latest sudo

Jul 30, 2022

Notify messages from gcs bucket objects to slack

Notify to Slack Notify message to slack from gcs storage file. Deploy $ gcloud functions deploy notify_to_slack \ --entry-point NotifyToSlack \

Oct 5, 2021

Slack Export Connection Visualizer

Slack Export Connection Visualizer Prerequisites Golang 1.16+ slack export unzipped into ./data email - department CSV located at ./data/dept.csv Run

Dec 28, 2021

Notify - Notification microservice for sending templated payloads as Slack messages

Notify Notify is a microservice that takes an event & payload from an applicatio

May 23, 2022

Snitch - a Slack bot that fetches pending review PRs built in Go

Snitch - a Slack bot that fetches pending review PRs built in Go

Snitch Snitch is a Slack bot that fetches and publish PRs with pendings reviews

Nov 29, 2022

A serverless bot which periodically checks configured BigQuery capacity commitments, reservations and assignments against actual slot consumption of running jobs and reports findings to Slack/Google Chat.

A serverless bot which periodically checks configured BigQuery capacity commitments, reservations and assignments against actual slot consumption of running jobs and reports findings to Slack/Google Chat.

Solution Guide This solution implements a ChatOps-like approach to monitoring slot utilization of Google Cloud BigQuery reservations. As an alternativ

Dec 7, 2022
REPLbot is a Slack bot that allows you to control a REPL from within Slack.
REPLbot is a Slack bot that allows you to control a REPL from within Slack.

?? REPLbot REPLbot is a Slack bot that allows you to control a REPL from within Slack. It comes with a few REPLs (Go ?? , Java, NodeJS, PHP, Python, R

Dec 31, 2022
This slack-bot collects all @gophers notifications into one slack channel

slack-bot Slack bot copying reference to a ping to notifications channel The bot is designed to listen on messages containing specific tag, copy refer

Apr 11, 2022
The original Slack library for Go created by Norberto Lopes, transferred to a Github organization
The original Slack library for Go created by Norberto Lopes, transferred to a Github organization

Slack API in Go This is the original Slack library for Go created by Norberto Lopes, transferred to a Github organization. This library supports most

Dec 8, 2021
IRC, Slack, Telegram and RocketChat bot written in go
IRC, Slack, Telegram and RocketChat bot written in go

go-bot IRC, Slack & Telegram bot written in Go using go-ircevent for IRC connectivity, nlopes/slack for Slack and Syfaro/telegram-bot-api for Telegram

Dec 20, 2022
Golang Framework for writing Slack bots

hanu - Go for Slack Bots! The Go framework hanu is your best friend to create Slack bots! hanu uses allot for easy command and request parsing (e.g. w

Oct 24, 2022
Slack Bot Framework

slacker Built on top of the Slack API github.com/slack-go/slack with the idea to simplify the Real-Time Messaging feature to easily create Slack Bots,

Dec 25, 2022
Slack bot core/framework written in Go with support for reactions to message updates/deletes
Slack bot core/framework written in Go with support for reactions to message updates/deletes

Overview Requirements Features Demo The Name Concepts Create Your Own Slackscot Assembling the Parts and Bringing Your slackscot to Life Configuration

Oct 28, 2022
Slack remind generator

slack-reminder Slack remind generator slack-reminder.mov Why Slack's /reminder is very hard to use. Required Go 1.16 ~ Installation $ go install githu

Nov 17, 2022
send current weather updates from openweathermap api to your slack profile status using github action
send current weather updates from openweathermap api to your slack profile status using github action

go-slack-weather Send current weather updates from OpenWeatherMap API to your Slack profile status using GitHub Action Contents Setup Change Update Pe

Oct 31, 2022
🦎 A slack bot for random gex quotes

?? A slack bot for random gex quotes

Jan 3, 2022