From c6ce85f4cd2b43ad4ab0fa6a9eaf587b583c6269 Mon Sep 17 00:00:00 2001 From: Stephan Schneider Date: Mon, 30 Aug 2021 16:45:00 +0200 Subject: [PATCH] :bug: Fix preview url for home and modal surfaces --- src/methods/other-methods.ts | 2 +- tests/surfaces/surface.spec.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/methods/other-methods.ts b/src/methods/other-methods.ts index 52a3911..e06cc60 100644 --- a/src/methods/other-methods.ts +++ b/src/methods/other-methods.ts @@ -73,7 +73,7 @@ export abstract class GetPreviewUrl extends Builder { const result = this.build(); const baseUri = 'https://app.slack.com/block-kit-builder/#'; - const stringifiedBlocks = this.props.type + const stringifiedBlocks = result.type ? JSON.stringify(result) : JSON.stringify({ blocks: result.blocks, attachments: result.attachments }); diff --git a/tests/surfaces/surface.spec.ts b/tests/surfaces/surface.spec.ts index abd5962..184ef22 100644 --- a/tests/surfaces/surface.spec.ts +++ b/tests/surfaces/surface.spec.ts @@ -31,16 +31,16 @@ describe('Surfaces', () => { const result = modal.getPreviewUrl(); - expect(result).toEqual('https://app.slack.com/block-kit-builder/#%7B%22blocks%22:%5B%7B%22type%22:%22divider%22%7D%5D%7D'); + expect(result).toEqual('https://app.slack.com/block-kit-builder/#%7B%22blocks%22:%5B%7B%22type%22:%22divider%22%7D%5D,%22type%22:%22home%22%7D'); }); test('Calling \'getPreviewUrl()\' for Modal returns the URL as a string.', () => { - const message = Modal() + const message = Modal({ submit: 'Start' }) .blocks(Blocks.Divider()); const result = message.getPreviewUrl(); - expect(result).toEqual('https://app.slack.com/block-kit-builder/#%7B%22blocks%22:%5B%7B%22type%22:%22divider%22%7D%5D%7D'); + expect(result).toEqual('https://app.slack.com/block-kit-builder/#%7B%22submit%22:%7B%22type%22:%22plain_text%22,%22text%22:%22Start%22%7D,%22blocks%22:%5B%7B%22type%22:%22divider%22%7D%5D,%22type%22:%22modal%22%7D'); }); test('Calling \'printPreviewUrl()\' for HomeTab logs the URL to the console.', () => {