|
24 | 24 | import java.util.Arrays; |
25 | 25 | import java.util.List; |
26 | 26 |
|
| 27 | +import static org.hamcrest.CoreMatchers.containsString; |
27 | 28 | import static org.hamcrest.CoreMatchers.is; |
| 29 | +import static org.hamcrest.CoreMatchers.notNullValue; |
28 | 30 | import static org.hamcrest.CoreMatchers.nullValue; |
29 | 31 | import static org.hamcrest.MatcherAssert.assertThat; |
30 | 32 |
|
@@ -160,4 +162,46 @@ public void standalone_canvases_error() throws Exception { |
160 | 162 | ); |
161 | 163 | assertThat(creation.getError(), is("invalid_arguments")); |
162 | 164 | } |
| 165 | + |
| 166 | + @Test |
| 167 | + public void error_detail() throws Exception { |
| 168 | + MethodsClient client = slack.methods(botToken); |
| 169 | + |
| 170 | + ConversationsCreateResponse newChannel = client.conversationsCreate(r1 -> r1.name("test-" + System.currentTimeMillis())); |
| 171 | + assertThat(newChannel.getError(), is(nullValue())); |
| 172 | + String channelId = newChannel.getChannel().getId(); |
| 173 | + |
| 174 | + Thread.sleep(500L); // To avoid occasional 500 errors |
| 175 | + |
| 176 | + String invalidCanvasContent = "1. Text\n * Nested"; // mixing of ordered and unordered lists is not supported |
| 177 | + ConversationsCanvasesCreateResponse failedCreation = client.conversationsCanvasesCreate(r -> r |
| 178 | + .channelId(channelId) |
| 179 | + .documentContent(CanvasDocumentContent.builder() |
| 180 | + .markdown(invalidCanvasContent) |
| 181 | + .build()) |
| 182 | + ); |
| 183 | + assertThat(failedCreation.isOk(), is(false)); |
| 184 | + assertThat(failedCreation.getError(), is("canvas_creation_failed")); |
| 185 | + assertThat(failedCreation.getDetail(), containsString("Unsupported list type")); |
| 186 | + |
| 187 | + ConversationsCanvasesCreateResponse successfulCreation = client.conversationsCanvasesCreate(r -> r |
| 188 | + .channelId(channelId) |
| 189 | + .documentContent(CanvasDocumentContent.builder() |
| 190 | + .markdown("Correct MD") |
| 191 | + .build() |
| 192 | + ) |
| 193 | + ); |
| 194 | + assertThat(successfulCreation.getCanvasId(), is(notNullValue())); |
| 195 | + |
| 196 | + CanvasesEditResponse editFailingResponse = client.canvasesEdit(r -> r |
| 197 | + .canvasId(successfulCreation.getCanvasId()) |
| 198 | + .changes(Arrays.asList(CanvasDocumentChange.builder() |
| 199 | + .operation(CanvasEditOperation.REPLACE) |
| 200 | + .documentContent(CanvasDocumentContent.builder().markdown(invalidCanvasContent).build()) |
| 201 | + .build())) |
| 202 | + ); |
| 203 | + assertThat(editFailingResponse.isOk(), is(false)); |
| 204 | + assertThat(editFailingResponse.getError(), is("canvas_editing_failed")); |
| 205 | + assertThat(editFailingResponse.getDetail(), containsString("Unsupported list type")); |
| 206 | + } |
163 | 207 | } |
0 commit comments