@@ -328,7 +328,7 @@ class ManageSuggestions extends Page implements HasTable
|
|||||||
/**
|
/**
|
||||||
* Polls a sync job's status (wire:poll.2s, see the view). On "finished",
|
* Polls a sync job's status (wire:poll.2s, see the view). On "finished",
|
||||||
* chains a reload-index call — same two-step flow shweai_backend's admin
|
* chains a reload-index call — same two-step flow shweai_backend's admin
|
||||||
* JS does (POST sync-chroma → poll → POST reload-index) — and refreshes
|
* JS does (POST sync → poll → POST reload-index) — and refreshes
|
||||||
* the table. On "failed", notifies and stops polling.
|
* the table. On "failed", notifies and stops polling.
|
||||||
*/
|
*/
|
||||||
public function pollSyncStatus(): void
|
public function pollSyncStatus(): void
|
||||||
|
|||||||
@@ -122,8 +122,8 @@ test('deleteSelected bulk action calls batchDeleteSuggestions with just the sele
|
|||||||
|
|
||||||
test('sync sets job state and polling chains a reload-index call on finished', function () {
|
test('sync sets job state and polling chains a reload-index call on finished', function () {
|
||||||
Http::fake(['bnfexpress.test/*' => fn (Request $request) => match (true) {
|
Http::fake(['bnfexpress.test/*' => fn (Request $request) => match (true) {
|
||||||
str_contains($request->url(), '/sync-chroma/job-1') => Http::response(['status' => 'finished', 'result' => ['synced' => 3]]),
|
str_contains($request->url(), '/sync/job-1') => Http::response(['status' => 'finished', 'result' => ['synced' => 3]]),
|
||||||
str_contains($request->url(), '/sync-chroma') => Http::response(['job_id' => 'job-1'], 202),
|
str_contains($request->url(), '/sync') => Http::response(['job_id' => 'job-1'], 202),
|
||||||
str_contains($request->url(), '/reload-index') => Http::response(['trie_rebuilt' => true]),
|
str_contains($request->url(), '/reload-index') => Http::response(['trie_rebuilt' => true]),
|
||||||
default => Http::response([]),
|
default => Http::response([]),
|
||||||
}]);
|
}]);
|
||||||
@@ -144,8 +144,8 @@ test('sync sets job state and polling chains a reload-index call on finished', f
|
|||||||
|
|
||||||
test('a failed sync job notifies danger and stops polling', function () {
|
test('a failed sync job notifies danger and stops polling', function () {
|
||||||
Http::fake(['bnfexpress.test/*' => fn (Request $request) => match (true) {
|
Http::fake(['bnfexpress.test/*' => fn (Request $request) => match (true) {
|
||||||
str_contains($request->url(), '/sync-chroma/job-1') => Http::response(['status' => 'failed', 'result' => null]),
|
str_contains($request->url(), '/sync/job-1') => Http::response(['status' => 'failed', 'result' => null]),
|
||||||
str_contains($request->url(), '/sync-chroma') => Http::response(['job_id' => 'job-1'], 202),
|
str_contains($request->url(), '/sync') => Http::response(['job_id' => 'job-1'], 202),
|
||||||
default => Http::response([]),
|
default => Http::response([]),
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
@@ -182,6 +182,6 @@ test('syncEmbedding and deleteEmbedding row actions call the right per-id endpoi
|
|||||||
$test->callTableAction('syncEmbedding', 1)->assertNotified('Embedding synced');
|
$test->callTableAction('syncEmbedding', 1)->assertNotified('Embedding synced');
|
||||||
$test->callTableAction('deleteEmbedding', 1)->assertNotified('Embedding deleted');
|
$test->callTableAction('deleteEmbedding', 1)->assertNotified('Embedding deleted');
|
||||||
|
|
||||||
Http::assertSent(fn (Request $request) => str_contains($request->url(), '/admin/suggestions/1/sync-chroma') && $request->method() === 'POST');
|
Http::assertSent(fn (Request $request) => str_contains($request->url(), '/admin/suggestions/1/sync') && $request->method() === 'POST');
|
||||||
Http::assertSent(fn (Request $request) => str_contains($request->url(), '/admin/suggestions/1/chroma') && $request->method() === 'DELETE');
|
Http::assertSent(fn (Request $request) => str_contains($request->url(), '/admin/suggestions/1/embedding') && $request->method() === 'DELETE');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ class BnfexpressAdminClient
|
|||||||
*/
|
*/
|
||||||
public function syncSuggestions(): array
|
public function syncSuggestions(): array
|
||||||
{
|
{
|
||||||
return $this->request('POST', '/admin/suggestions/sync-chroma');
|
return $this->request('POST', '/admin/suggestions/sync');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -290,7 +290,7 @@ class BnfexpressAdminClient
|
|||||||
*/
|
*/
|
||||||
public function getSuggestionSyncStatus(string $jobId): array
|
public function getSuggestionSyncStatus(string $jobId): array
|
||||||
{
|
{
|
||||||
return $this->request('GET', "/admin/suggestions/sync-chroma/{$jobId}");
|
return $this->request('GET', "/admin/suggestions/sync/{$jobId}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -298,7 +298,7 @@ class BnfexpressAdminClient
|
|||||||
*/
|
*/
|
||||||
public function syncOneSuggestion(int|string $id): array
|
public function syncOneSuggestion(int|string $id): array
|
||||||
{
|
{
|
||||||
return $this->request('POST', "/admin/suggestions/{$id}/sync-chroma");
|
return $this->request('POST', "/admin/suggestions/{$id}/sync");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -314,7 +314,7 @@ class BnfexpressAdminClient
|
|||||||
*/
|
*/
|
||||||
public function deleteSuggestionEmbedding(int|string $id): array
|
public function deleteSuggestionEmbedding(int|string $id): array
|
||||||
{
|
{
|
||||||
return $this->request('DELETE', "/admin/suggestions/{$id}/chroma");
|
return $this->request('DELETE', "/admin/suggestions/{$id}/embedding");
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Request plumbing ------------------------------------------------
|
// --- Request plumbing ------------------------------------------------
|
||||||
|
|||||||
@@ -175,13 +175,13 @@ test('promoteSuggestionMisses posts miss_ids with an optional lang/intent overri
|
|||||||
&& $request->body() === json_encode(['miss_ids' => [1, 2], 'lang' => 'my']));
|
&& $request->body() === json_encode(['miss_ids' => [1, 2], 'lang' => 'my']));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('syncSuggestions triggers a sync-chroma job and returns the job id', function () use ($config) {
|
test('syncSuggestions triggers a sync job and returns the job id', function () use ($config) {
|
||||||
Http::fake(['bnfexpress.test/*' => Http::response(['job_id' => 'abc-123'], 202)]);
|
Http::fake(['bnfexpress.test/*' => Http::response(['job_id' => 'abc-123'], 202)]);
|
||||||
|
|
||||||
$result = (new BnfexpressAdminClient($config))->syncSuggestions();
|
$result = (new BnfexpressAdminClient($config))->syncSuggestions();
|
||||||
|
|
||||||
expect($result)->toBe(['job_id' => 'abc-123']);
|
expect($result)->toBe(['job_id' => 'abc-123']);
|
||||||
Http::assertSent(fn ($request) => $request->url() === 'https://bnfexpress.test/admin/suggestions/sync-chroma'
|
Http::assertSent(fn ($request) => $request->url() === 'https://bnfexpress.test/admin/suggestions/sync'
|
||||||
&& $request->method() === 'POST');
|
&& $request->method() === 'POST');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ test('getSuggestionSyncStatus polls the job status endpoint', function () use ($
|
|||||||
$result = (new BnfexpressAdminClient($config))->getSuggestionSyncStatus('abc-123');
|
$result = (new BnfexpressAdminClient($config))->getSuggestionSyncStatus('abc-123');
|
||||||
|
|
||||||
expect($result)->toBe(['status' => 'finished', 'result' => ['synced' => 3]]);
|
expect($result)->toBe(['status' => 'finished', 'result' => ['synced' => 3]]);
|
||||||
Http::assertSent(fn ($request) => $request->url() === 'https://bnfexpress.test/admin/suggestions/sync-chroma/abc-123'
|
Http::assertSent(fn ($request) => $request->url() === 'https://bnfexpress.test/admin/suggestions/sync/abc-123'
|
||||||
&& $request->method() === 'GET');
|
&& $request->method() === 'GET');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -201,8 +201,8 @@ test('deleteSuggestionEmbedding signs a bodyless DELETE request', function () us
|
|||||||
(new BnfexpressAdminClient($config))->deleteSuggestionEmbedding(5);
|
(new BnfexpressAdminClient($config))->deleteSuggestionEmbedding(5);
|
||||||
|
|
||||||
Http::assertSent(function ($request) use ($config) {
|
Http::assertSent(function ($request) use ($config) {
|
||||||
return $request->url() === 'https://bnfexpress.test/admin/suggestions/5/chroma'
|
return $request->url() === 'https://bnfexpress.test/admin/suggestions/5/embedding'
|
||||||
&& $request->method() === 'DELETE'
|
&& $request->method() === 'DELETE'
|
||||||
&& assertSignedCorrectly($request, 'DELETE', '/admin/suggestions/5/chroma', '', $config['client_secret']);
|
&& assertSignedCorrectly($request, 'DELETE', '/admin/suggestions/5/embedding', '', $config['client_secret']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user