-
Notifications
You must be signed in to change notification settings - Fork 21
[CHAT-530] Feature/snooze message reminder #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
38a649d
360a574
0af4c8e
496839b
637c3e0
dd4e71d
ce5bd49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
STREAM_KEY ?= NOT_EXIST | ||
STREAM_SECRET ?= NOT_EXIST | ||
RUBY_VERSION ?= 3.0 | ||
STREAM_CHAT_URL ?= https://chat.stream-io-api.com | ||
|
||
# These targets are not files | ||
.PHONY: help check test lint lint-fix test_with_docker lint_with_docker lint-fix_with_docker | ||
|
||
help: ## Display this help message | ||
@echo "Please use \`make <target>\` where <target> is one of" | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; \ | ||
{printf "\033[36m%-40s\033[0m %s\n", $$1, $$2}' | ||
|
||
lint: ## Run linters | ||
bundle exec rubocop | ||
|
||
lint-fix: ## Fix linting issues | ||
bundle exec rubocop -a | ||
|
||
test: ## Run tests | ||
STREAM_KEY=$(STREAM_KEY) STREAM_SECRET=$(STREAM_SECRET) bundle exec rspec | ||
|
||
check: lint test ## Run linters + tests | ||
|
||
console: ## Start a console with the gem loaded | ||
bundle exec rake console | ||
|
||
lint_with_docker: ## Run linters in Docker (set RUBY_VERSION to change Ruby version) | ||
docker run -t -i -w /code -v $(PWD):/code ruby:$(RUBY_VERSION) sh -c "gem install bundler && bundle install && bundle exec rubocop" | ||
|
||
lint-fix_with_docker: ## Fix linting issues in Docker (set RUBY_VERSION to change Ruby version) | ||
docker run -t -i -w /code -v $(PWD):/code ruby:$(RUBY_VERSION) sh -c "gem install bundler && bundle install && bundle exec rubocop -a" | ||
|
||
test_with_docker: ## Run tests in Docker (set RUBY_VERSION to change Ruby version) | ||
docker run -t -i -w /code -v $(PWD):/code --add-host=host.docker.internal:host-gateway -e STREAM_KEY=$(STREAM_KEY) -e STREAM_SECRET=$(STREAM_SECRET) -e "STREAM_CHAT_URL=http://host.docker.internal:3030" ruby:$(RUBY_VERSION) sh -c "gem install bundler && bundle install && bundle exec rspec" | ||
|
||
check_with_docker: lint_with_docker test_with_docker ## Run linters + tests in Docker (set RUBY_VERSION to change Ruby version) | ||
|
||
sorbet: ## Run Sorbet type checker | ||
bundle exec srb tc | ||
|
||
sorbet_with_docker: ## Run Sorbet type checker in Docker (set RUBY_VERSION to change Ruby version) | ||
docker run -t -i -w /code -v $(PWD):/code ruby:$(RUBY_VERSION) sh -c "gem install bundler && bundle install && bundle exec srb tc" | ||
|
||
coverage: ## Generate test coverage report | ||
COVERAGE=true bundle exec rspec | ||
@echo "Coverage report available at ./coverage/index.html" | ||
|
||
reviewdog: ## Run reviewdog for CI | ||
bundle exec rubocop --format json | reviewdog -f=rubocop -name=rubocop -reporter=github-pr-review |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1020,4 +1020,103 @@ def loop_times(times) | |||||||||||||
expect(response['threads'].length).to be >= 1 | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
describe 'reminders' do | ||||||||||||||
before do | ||||||||||||||
@client = StreamChat::Client.from_env | ||||||||||||||
@channel_id = SecureRandom.uuid | ||||||||||||||
@channel = @client.channel('messaging', channel_id: @channel_id) | ||||||||||||||
@channel.create('john') | ||||||||||||||
@channel.update_partial({config_overrides: {user_message_reminders: true}}) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 [rubocop] <Layout/SpaceInsideHashLiteralBraces> reported by reviewdog 🐶
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 [rubocop] <Layout/SpaceInsideHashLiteralBraces> reported by reviewdog 🐶
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 [rubocop] <Layout/SpaceInsideHashLiteralBraces> reported by reviewdog 🐶
Suggested change
|
||||||||||||||
@message = @channel.send_message({ 'text' => 'Hello world' }, 'john') | ||||||||||||||
@message_id = @message['message']['id'] | ||||||||||||||
@user_id = 'john' | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
describe 'create_reminder' do | ||||||||||||||
it 'create reminder' do | ||||||||||||||
remind_at = DateTime.now + 1 | ||||||||||||||
response = @client.create_reminder(@message_id, @user_id, remind_at) | ||||||||||||||
|
||||||||||||||
expect(response).to include('reminder') | ||||||||||||||
expect(response['reminder']).to include('message_id', 'user_id', 'remind_at') | ||||||||||||||
expect(response['reminder']['message_id']).to eq(@message_id) | ||||||||||||||
expect(response['reminder']['user_id']).to eq(@user_id) | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
it 'create reminder without remind_at' do | ||||||||||||||
response = @client.create_reminder(@message_id, @user_id) | ||||||||||||||
|
||||||||||||||
expect(response).to include('reminder') | ||||||||||||||
expect(response['reminder']).to include('message_id', 'user_id') | ||||||||||||||
expect(response['reminder']['message_id']).to eq(@message_id) | ||||||||||||||
expect(response['reminder']['user_id']).to eq(@user_id) | ||||||||||||||
expect(response['reminder']['remind_at']).to be_nil | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
describe 'update_reminder' do | ||||||||||||||
before do | ||||||||||||||
@client.create_reminder(@message_id, @user_id) | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
it 'update reminder' do | ||||||||||||||
new_remind_at = DateTime.now + 2 | ||||||||||||||
response = @client.update_reminder(@message_id, @user_id, new_remind_at) | ||||||||||||||
|
||||||||||||||
expect(response).to include('reminder') | ||||||||||||||
expect(response['reminder']).to include('message_id', 'user_id', 'remind_at') | ||||||||||||||
expect(response['reminder']['message_id']).to eq(@message_id) | ||||||||||||||
expect(response['reminder']['user_id']).to eq(@user_id) | ||||||||||||||
expect(DateTime.parse(response['reminder']['remind_at'])).to be_within(1).of(new_remind_at) | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
describe 'delete_reminder' do | ||||||||||||||
before do | ||||||||||||||
@client.create_reminder(@message_id, @user_id) | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
it 'delete reminder' do | ||||||||||||||
response = @client.delete_reminder(@message_id, @user_id) | ||||||||||||||
expect(response).to be_a(Hash) | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
describe 'query_reminders' do | ||||||||||||||
before do | ||||||||||||||
remind_at = DateTime.now + 1 | ||||||||||||||
@client.create_reminder(@message_id, @user_id, remind_at) | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
it 'query reminders' do | ||||||||||||||
# Query reminders for the user | ||||||||||||||
response = @client.query_reminders(@user_id) | ||||||||||||||
|
||||||||||||||
expect(response).to include('reminders') | ||||||||||||||
expect(response['reminders']).to be_an(Array) | ||||||||||||||
expect(response['reminders'].length).to be >= 1 | ||||||||||||||
|
||||||||||||||
# Find our reminder | ||||||||||||||
reminder = response['reminders'].find { |r| r['message_id'] == @message_id } | ||||||||||||||
expect(reminder).not_to be_nil | ||||||||||||||
expect(reminder['user_id']).to eq(@user_id) | ||||||||||||||
end | ||||||||||||||
|
||||||||||||||
it 'query reminders with channel filter' do | ||||||||||||||
# Query reminders for the user in a specific channel | ||||||||||||||
filter = { 'channel_cid' => @channel.cid } | ||||||||||||||
response = @client.query_reminders(@user_id, filter) | ||||||||||||||
|
||||||||||||||
expect(response).to include('reminders') | ||||||||||||||
expect(response['reminders']).to be_an(Array) | ||||||||||||||
expect(response['reminders'].length).to be >= 1 | ||||||||||||||
|
||||||||||||||
# All reminders should have a channel_cid | ||||||||||||||
response['reminders'].each do |reminder| | ||||||||||||||
expect(reminder).to include('channel_cid') | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
end | ||||||||||||||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 [rubocop] <Layout/SpaceInsideHashLiteralBraces> reported by reviewdog 🐶
Space inside { missing.