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

Fix RichText type issue with views #109

Merged
merged 2 commits into from
Feb 12, 2024
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
3 changes: 2 additions & 1 deletion blockkit/surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Header,
ImageBlock,
Input,
RichText,
Section,
)
from blockkit.components import Component
Expand All @@ -17,7 +18,7 @@

__all__ = ["Home", "Message", "Modal", "WorkflowStep"]

Block = Union[Actions, Context, Divider, Header, ImageBlock, Input, Section]
Block = Union[Actions, Context, Divider, Header, ImageBlock, Input, RichText, Section]


class View(Component):
Expand Down
20 changes: 16 additions & 4 deletions tests/test_surfaces.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from blockkit.blocks import Input, Section
from blockkit.blocks import Input, RichText, RichTextSection, Section
from blockkit.elements import Button, PlainTextInput
from blockkit.objects import MarkdownText, PlainText
from blockkit.objects import MarkdownText, PlainText, Text
from blockkit.surfaces import Home, Message, Modal, WorkflowStep
from pydantic import ValidationError

Expand Down Expand Up @@ -199,7 +199,10 @@ def test_builds_message():
Section(
text=MarkdownText(text="*markdown* text"),
accessory=Button(text=PlainText(text="button"), action_id="action_id"),
)
),
RichText(
elements=[RichTextSection(elements=[Text(text="test_rich_text")])]
),
],
).build() == {
"text": "message text",
Expand All @@ -212,7 +215,16 @@ def test_builds_message():
"text": {"type": "plain_text", "text": "button"},
"action_id": "action_id",
},
}
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [{"type": "text", "text": "test_rich_text"}],
}
],
},
],
}

Expand Down
Loading