Skip to content
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

Fixing /joinSpace and /addToSpace commands #6941

Merged
merged 1 commit into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6844.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes /addToSpace and /joinSpace commands showing invalid syntax warnings
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,15 @@ class CommandParser @Inject constructor() {
}
}
Command.ADD_TO_SPACE.matches(slashCommand) -> {
if (messageParts.size == 1) {
ParsedCommand.AddToSpace(spaceId = message)
if (messageParts.size == 2) {
ParsedCommand.AddToSpace(spaceId = messageParts.last())
} else {
ParsedCommand.ErrorSyntax(Command.ADD_TO_SPACE)
}
}
Command.JOIN_SPACE.matches(slashCommand) -> {
if (messageParts.size == 1) {
ParsedCommand.JoinSpace(spaceIdOrAlias = message)
if (messageParts.size == 2) {
ParsedCommand.JoinSpace(spaceIdOrAlias = messageParts.last())
} else {
ParsedCommand.ErrorSyntax(Command.JOIN_SPACE)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package im.vector.app.features.command
import org.amshove.kluent.shouldBeEqualTo
import org.junit.Test

private const val A_SPACE_ID = "!my-space-id"

class CommandParserTest {
@Test
fun parseSlashCommandEmpty() {
Expand All @@ -31,6 +33,15 @@ class CommandParserTest {
test("/unknown with param", ParsedCommand.ErrorUnknownSlashCommand("/unknown"))
}

@Test
fun parseSlashAddToSpaceCommand() {
test("/addToSpace $A_SPACE_ID", ParsedCommand.AddToSpace(A_SPACE_ID))
}
@Test
fun parseSlashJoinSpaceCommand() {
test("/joinSpace $A_SPACE_ID", ParsedCommand.JoinSpace(A_SPACE_ID))
}

@Test
fun parseSlashCommandNotACommand() {
test("", ParsedCommand.ErrorNotACommand)
Expand Down