feat: phase 2 api parity endpoints for extension

This commit is contained in:
Dwindi Ramadhana
2026-02-03 22:06:08 +07:00
parent dcec38ba94
commit 8816522ddd
11 changed files with 497 additions and 5 deletions

View File

@@ -0,0 +1,57 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
class ApiV1EndpointsTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
config()->set('dewemoji.data_path', base_path('tests/Fixtures/emojis.fixture.json'));
}
public function test_categories_endpoint_returns_category_map(): void
{
$response = $this->getJson('/v1/categories');
$response
->assertOk()
->assertHeader('X-Dewemoji-Tier', 'free')
->assertJsonPath('Smileys & Emotion.0', 'face-smiling')
->assertJsonPath('People & Body.0', 'hand-fingers-closed');
}
public function test_emojis_endpoint_supports_both_q_and_query_params(): void
{
$byQ = $this->getJson('/v1/emojis?q=grinning');
$byQuery = $this->getJson('/v1/emojis?query=grinning');
$byQ->assertOk()->assertJsonPath('total', 1);
$byQuery->assertOk()->assertJsonPath('total', 1);
$byQ->assertJsonPath('items.0.slug', 'grinning-face');
$byQuery->assertJsonPath('items.0.slug', 'grinning-face');
}
public function test_license_verify_returns_ok_when_accept_all_is_enabled(): void
{
config()->set('dewemoji.license.accept_all', true);
$response = $this->postJson('/v1/license/verify', [
'key' => 'dummy-key',
'account_id' => 'acct_123',
'version' => '1.0.0',
]);
$response
->assertOk()
->assertHeader('X-Dewemoji-Tier', 'pro')
->assertJson([
'ok' => true,
'tier' => 'pro',
]);
}
}

View File

@@ -0,0 +1,39 @@
{
"emojis": [
{
"emoji": "😀",
"name": "grinning face",
"slug": "grinning-face",
"category": "Smileys & Emotion",
"subcategory": "face-smiling",
"supports_skin_tone": false,
"description": "A happy smiling face.",
"unified": "U+1F600",
"codepoints": ["1F600"],
"shortcodes": [":grinning_face:"],
"aliases": ["grin face"],
"keywords_en": ["happy", "smile"],
"keywords_id": ["senang", "senyum"],
"related": ["😃"],
"intent_tags": ["happiness"]
},
{
"emoji": "👍",
"name": "thumbs up",
"slug": "thumbs-up",
"category": "People & Body",
"subcategory": "hand-fingers-closed",
"supports_skin_tone": true,
"description": "A thumbs up gesture.",
"unified": "U+1F44D",
"codepoints": ["1F44D"],
"shortcodes": [":thumbsup:"],
"aliases": ["like"],
"keywords_en": ["ok", "good"],
"keywords_id": ["bagus"],
"related": ["👎"],
"intent_tags": ["approval"]
}
]
}