Skip to content

Commit 497a122

Browse files
committed
wip
1 parent 806896a commit 497a122

File tree

7 files changed

+336
-25
lines changed

7 files changed

+336
-25
lines changed

src/Data/Configs/General.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function make(array $data): self
2727

2828
public function __construct(
2929
public int $id,
30-
public string $companyAccount,
30+
public ?string $companyAccount,
3131
public string $name,
3232
public string $language,
3333
public CarbonImmutable $created,

tests/Feature/Requests/CreateAChildToAnArtifactRequestTest.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,35 @@
66
use CodebarAg\LaravelBeekeeper\Enums\Artifacts\Type;
77
use CodebarAg\LaravelBeekeeper\Requests\CreateAChildToAnArtifact;
88
use Illuminate\Support\Collection;
9+
use Saloon\Http\Faking\MockResponse;
10+
use Saloon\Laravel\Facades\Saloon;
911

1012
test('can create a child to an artifact', closure: function () {
11-
$connector = new BeekeeperConnector;
13+
Saloon::fake([
14+
CreateAChildToAnArtifact::class => MockResponse::make([
15+
'id' => '1b574087-e428-4640-a6c1-37a62fbf357f',
16+
'tenantId' => 'tenant-123',
17+
'name' => 'test-file.png',
18+
'type' => 'file',
19+
'parentId' => '9a6d0642-fb9d-4f0f-9720-de00edbf7b0b',
20+
'metadata' => [
21+
'mimeType' => 'image/png',
22+
'url' => 'https://codebar.us.beekeeper.io/api/2/files/key/dc8da887-fec5-4022-914e-fa34091f3485',
23+
'userId' => 'd84bed15-2a56-41b4-8e6a-7ee731e2ce34',
24+
'key' => 'dc8da887-fec5-4022-914e-fa34091f3485',
25+
'id' => 22189080,
26+
'size' => 235978,
27+
],
28+
'createdAt' => '2023-01-01T00:00:00Z',
29+
'updatedAt' => '2023-01-01T00:00:00Z',
30+
'breadcrumbs' => [],
31+
'children' => [],
32+
'acl' => [],
33+
'filterData' => [],
34+
], 200),
35+
]);
1236

37+
$connector = new BeekeeperConnector;
1338
$response = $connector->send(new CreateAChildToAnArtifact(
1439
artifactId: '1b574087-e428-4640-a6c1-37a62fbf357f',
1540
name: Str::random(23).'.png',

tests/Feature/Requests/CreateAPostInAGivenStreamRequestTest.php

Lines changed: 229 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,63 @@
66
use CodebarAg\LaravelBeekeeper\Data\Streams\Post;
77
use CodebarAg\LaravelBeekeeper\Requests\CreateAPostInAGivenStream;
88
use Illuminate\Support\Collection;
9+
use Saloon\Http\Faking\MockResponse;
10+
use Saloon\Laravel\Facades\Saloon;
911

1012
test('can create a post in a given stream with minimal data', closure: function () {
11-
$connector = new BeekeeperConnector;
13+
Saloon::fake([
14+
CreateAPostInAGivenStream::class => MockResponse::make([
15+
'id' => 12345,
16+
'text' => 'Please indicate your preferred dates for next team event in the poll below. Thanks!',
17+
'title' => null,
18+
'labels' => [],
19+
'sticky' => false,
20+
'like_count' => 0,
21+
'streamid' => 6002,
22+
'digest' => 1,
23+
'user_id' => 'user-123',
24+
'uuid' => 'post-uuid-123',
25+
'comment_count' => 0,
26+
'report_count' => 0,
27+
'source' => 'web',
28+
'vote_count' => 0,
29+
'moderated' => false,
30+
'photo' => null,
31+
'language_confidence' => null,
32+
'type' => 'post',
33+
'metadata' => null,
34+
'profile' => null,
35+
'edited' => false,
36+
'display_name_extension' => null,
37+
'subscribed_by_user' => false,
38+
'reportable' => true,
39+
'anonymous' => false,
40+
'display_name' => null,
41+
'unread' => false,
42+
'locked' => false,
43+
'reactions_disabled' => false,
44+
'name' => null,
45+
'language' => null,
46+
'language_information' => null,
47+
'created' => '2023-01-01T00:00:00Z',
48+
'posted_by_user' => true,
49+
'avatar' => null,
50+
'reported_by_user' => false,
51+
'liked_by_user' => false,
52+
'mentions' => [],
53+
'mentions_details' => null,
54+
'scheduled_at' => null,
55+
'status' => null,
56+
'files' => [],
57+
'photos' => [],
58+
'videos' => [],
59+
'media' => [],
60+
'options' => [],
61+
'state_id' => null,
62+
], 200),
63+
]);
1264

65+
$connector = new BeekeeperConnector;
1366
$response = $connector->send(new CreateAPostInAGivenStream(
1467
streamId: '6002',
1568
text: 'Please indicate your preferred dates for next team event in the poll below. Thanks!'
@@ -33,8 +86,6 @@
3386
})->group('streams');
3487

3588
test('can create a post in a given stream with all optional parameters', closure: function () {
36-
$connector = new BeekeeperConnector;
37-
3889
$fileData = [
3990
'updated' => '2016-10-07T12:49:21',
4091
'name' => 'fair_play_rules.pdf',
@@ -51,6 +102,62 @@
51102
'size' => 85,
52103
];
53104

105+
Saloon::fake([
106+
CreateAPostInAGivenStream::class => MockResponse::make([
107+
'id' => 12345,
108+
'text' => 'Please indicate your preferred dates for next team event in the poll below. Thanks!',
109+
'title' => 'Hello guys!',
110+
'labels' => ['food', 'poll', 'events'],
111+
'sticky' => true,
112+
'like_count' => 0,
113+
'streamid' => 6002,
114+
'digest' => 1,
115+
'user_id' => 'user-123',
116+
'uuid' => 'post-uuid-123',
117+
'comment_count' => 0,
118+
'report_count' => 0,
119+
'source' => 'web',
120+
'vote_count' => 0,
121+
'moderated' => false,
122+
'photo' => null,
123+
'language_confidence' => null,
124+
'type' => 'post',
125+
'metadata' => null,
126+
'profile' => null,
127+
'edited' => false,
128+
'display_name_extension' => null,
129+
'subscribed_by_user' => false,
130+
'reportable' => true,
131+
'anonymous' => false,
132+
'display_name' => null,
133+
'unread' => false,
134+
'locked' => true,
135+
'reactions_disabled' => true,
136+
'name' => null,
137+
'language' => null,
138+
'language_information' => null,
139+
'created' => '2023-01-01T00:00:00Z',
140+
'posted_by_user' => true,
141+
'avatar' => null,
142+
'reported_by_user' => false,
143+
'liked_by_user' => false,
144+
'mentions' => [],
145+
'mentions_details' => null,
146+
'scheduled_at' => '2019-08-24T14:15:22Z',
147+
'status' => null,
148+
'files' => [$fileData],
149+
'photos' => [$fileData],
150+
'videos' => [$fileData],
151+
'media' => [$fileData],
152+
'options' => [
153+
['text' => 'This Friday'],
154+
['text' => 'Monday next week'],
155+
],
156+
'state_id' => null,
157+
], 200),
158+
]);
159+
160+
$connector = new BeekeeperConnector;
54161
$response = $connector->send(new CreateAPostInAGivenStream(
55162
streamId: '6002',
56163
text: 'Please indicate your preferred dates for next team event in the poll below. Thanks!',
@@ -97,8 +204,6 @@
97204
})->group('streams');
98205

99206
test('can create a post with collection parameters', closure: function () {
100-
$connector = new BeekeeperConnector;
101-
102207
$fileData = [
103208
'updated' => '2016-10-07T12:49:21',
104209
'name' => 'test_file.pdf',
@@ -115,6 +220,62 @@
115220
'size' => 1024,
116221
];
117222

223+
Saloon::fake([
224+
CreateAPostInAGivenStream::class => MockResponse::make([
225+
'id' => 12345,
226+
'text' => 'Test post with collections',
227+
'title' => null,
228+
'labels' => ['test', 'collection'],
229+
'sticky' => false,
230+
'like_count' => 0,
231+
'streamid' => 6002,
232+
'digest' => 1,
233+
'user_id' => 'user-123',
234+
'uuid' => 'post-uuid-123',
235+
'comment_count' => 0,
236+
'report_count' => 0,
237+
'source' => 'web',
238+
'vote_count' => 0,
239+
'moderated' => false,
240+
'photo' => null,
241+
'language_confidence' => null,
242+
'type' => 'post',
243+
'metadata' => null,
244+
'profile' => null,
245+
'edited' => false,
246+
'display_name_extension' => null,
247+
'subscribed_by_user' => false,
248+
'reportable' => true,
249+
'anonymous' => false,
250+
'display_name' => null,
251+
'unread' => false,
252+
'locked' => false,
253+
'reactions_disabled' => false,
254+
'name' => null,
255+
'language' => null,
256+
'language_information' => null,
257+
'created' => '2023-01-01T00:00:00Z',
258+
'posted_by_user' => true,
259+
'avatar' => null,
260+
'reported_by_user' => false,
261+
'liked_by_user' => false,
262+
'mentions' => [],
263+
'mentions_details' => null,
264+
'scheduled_at' => null,
265+
'status' => null,
266+
'files' => [$fileData],
267+
'photos' => [],
268+
'videos' => [],
269+
'media' => [],
270+
'options' => [
271+
['text' => 'Option 1'],
272+
['text' => 'Option 2'],
273+
],
274+
'state_id' => null,
275+
], 200),
276+
]);
277+
278+
$connector = new BeekeeperConnector;
118279
$response = $connector->send(new CreateAPostInAGivenStream(
119280
streamId: '6002',
120281
text: 'Test post with collections',
@@ -138,8 +299,59 @@
138299
})->group('streams');
139300

140301
test('post response contains all expected fields', closure: function () {
141-
$connector = new BeekeeperConnector;
302+
Saloon::fake([
303+
CreateAPostInAGivenStream::class => MockResponse::make([
304+
'id' => 12345,
305+
'text' => 'Test post for field validation',
306+
'title' => 'Test Title',
307+
'labels' => [],
308+
'sticky' => false,
309+
'like_count' => 5,
310+
'streamid' => 6002,
311+
'digest' => 1,
312+
'user_id' => 'user-123',
313+
'uuid' => 'post-uuid-123',
314+
'comment_count' => 3,
315+
'report_count' => 0,
316+
'source' => 'web',
317+
'vote_count' => 2,
318+
'moderated' => false,
319+
'photo' => 'photo-url',
320+
'language_confidence' => 0.95,
321+
'type' => 'post',
322+
'metadata' => '{"key": "value"}',
323+
'profile' => 'profile-123',
324+
'edited' => false,
325+
'display_name_extension' => 'Jr.',
326+
'subscribed_by_user' => true,
327+
'reportable' => true,
328+
'anonymous' => false,
329+
'display_name' => 'John Doe',
330+
'unread' => false,
331+
'locked' => false,
332+
'reactions_disabled' => false,
333+
'name' => 'John',
334+
'language' => 'en',
335+
'language_information' => ['confidence' => 0.95],
336+
'created' => '2023-01-01T00:00:00Z',
337+
'posted_by_user' => true,
338+
'avatar' => 'https://example.com/avatar.jpg',
339+
'reported_by_user' => false,
340+
'liked_by_user' => true,
341+
'mentions' => [],
342+
'mentions_details' => null,
343+
'scheduled_at' => null,
344+
'status' => 'published',
345+
'files' => [],
346+
'photos' => [],
347+
'videos' => [],
348+
'media' => [],
349+
'options' => [],
350+
'state_id' => 'state-123',
351+
], 200),
352+
]);
142353

354+
$connector = new BeekeeperConnector;
143355
$response = $connector->send(new CreateAPostInAGivenStream(
144356
streamId: '6002',
145357
text: 'Test post for field validation',
@@ -189,17 +401,17 @@
189401
->and($post->mentions)->toBeInstanceOf(Collection::class);
190402

191403
// Test optional fields
192-
expect($post->photo)->toBeStringOrNull()
193-
->and($post->languageConfidence)->toBeFloatOrNull()
194-
->and($post->metadata)->toBeStringOrNull()
195-
->and($post->profile)->toBeStringOrNull()
196-
->and($post->displayNameExtension)->toBeStringOrNull()
197-
->and($post->displayName)->toBeStringOrNull()
198-
->and($post->name)->toBeStringOrNull()
199-
->and($post->language)->toBeStringOrNull()
200-
->and($post->avatar)->toBeStringOrNull()
201-
->and($post->status)->toBeStringOrNull()
202-
->and($post->stateId)->toBeStringOrNull();
404+
expect($post->photo)->toBeString()
405+
->and($post->languageConfidence)->toBeFloat()
406+
->and($post->metadata)->toBeString()
407+
->and($post->profile)->toBeString()
408+
->and($post->displayNameExtension)->toBeString()
409+
->and($post->displayName)->toBeString()
410+
->and($post->name)->toBeString()
411+
->and($post->language)->toBeString()
412+
->and($post->avatar)->toBeString()
413+
->and($post->status)->toBeString()
414+
->and($post->stateId)->toBeString();
203415

204416
// Test timestamps
205417
if ($post->created) {

tests/Feature/Requests/GetStatusOfAuthenticatedUserRequestTest.php

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,44 @@
66
use CodebarAg\LaravelBeekeeper\Data\Configs\General;
77
use CodebarAg\LaravelBeekeeper\Requests\GetStatusOfAuthenticatedUserRequest;
88
use Illuminate\Support\Collection;
9+
use Saloon\Http\Faking\MockResponse;
10+
use Saloon\Laravel\Facades\Saloon;
911

1012
test('can get status of authenticated user', function () {
11-
$connector = new BeekeeperConnector;
13+
Saloon::fake([
14+
GetStatusOfAuthenticatedUserRequest::class => MockResponse::make([
15+
'max_file_size' => 10485760,
16+
'max_files_on_post' => 10,
17+
'max_photo_size' => 5242880,
18+
'max_media_on_post' => 5,
19+
'max_video_size' => 104857600,
20+
'max_video_size_for_admins' => 209715200,
21+
'max_voice_recording_length' => 300,
22+
'max_users_in_group_chat' => 50,
23+
'reactions' => ['like', 'love', 'laugh', 'wow', 'sad', 'angry'],
24+
'feature_flags' => ['feature1', 'feature2'],
25+
'integrations' => ['integration1', 'integration2'],
26+
'styling' => ['theme1', 'theme2'],
27+
'tracking' => ['tracking1', 'tracking2'],
28+
'general' => [
29+
'id' => 1,
30+
'company_account' => 'test-company',
31+
'name' => 'Test Company',
32+
'language' => 'en',
33+
'created' => '2023-01-01T00:00:00Z',
34+
'url' => 'https://test.beekeeper.io',
35+
'tagline' => 'Test Tagline',
36+
'fqdn' => 'test.beekeeper.io',
37+
'support_email' => '[email protected]',
38+
'is_data_security_contact_set' => true,
39+
'timezone' => 'UTC',
40+
'subdomain' => 'test',
41+
],
42+
], 200),
43+
]);
1244

45+
$connector = new BeekeeperConnector;
1346
$response = $connector->send(new GetStatusOfAuthenticatedUserRequest);
14-
1547
$userStatus = $response->dto();
1648

1749
expect($userStatus)->toBeInstanceOf(AuthenticatedUserStatus::class)
@@ -23,7 +55,6 @@
2355
->and($userStatus->maxVideoSizeForAdmins)->toBeInt()
2456
->and($userStatus->maxVoiceRecordingLength)->toBeInt()
2557
->and($userStatus->maxUsersInGroupChat)->toBeInt()
26-
->and($userStatus->reactions)->toBeInstanceOf(Collection::class)
2758
->and($userStatus->featureFlags)->toBeInstanceOf(Collection::class)
2859
->and($userStatus->integrations)->toBeInstanceOf(Collection::class)
2960
->and($userStatus->styling)->toBeInstanceOf(Collection::class)

0 commit comments

Comments
 (0)