forked from gongxuegit/tiku-backend.net
feat: add student video and profile experience
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Tiku.Api.Contracts;
|
||||
using Tiku.Application.Jobs;
|
||||
using Tiku.Domain.Catalog;
|
||||
using Tiku.Domain.Common;
|
||||
using Tiku.Domain.Content;
|
||||
using Tiku.Domain.Identity;
|
||||
using Tiku.Domain.Operations;
|
||||
using Tiku.Domain.QuestionBanks;
|
||||
using Tiku.Domain.Tenancy;
|
||||
using Tiku.Infrastructure.Auth;
|
||||
@@ -16,6 +19,11 @@ namespace Tiku.IntegrationTests.Api;
|
||||
|
||||
public sealed class DirectContentEndpointTests
|
||||
{
|
||||
private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web)
|
||||
{
|
||||
Converters = { new JsonStringEnumConverter() }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public async Task Tenant_admin_can_create_question_and_sync_primary_collection()
|
||||
{
|
||||
@@ -175,6 +183,44 @@ public sealed class DirectContentEndpointTests
|
||||
Assert.True(dbContext.Questions.Single(item => item.Id == questionId).HasVideoExplanation);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Tenant_admin_can_queue_content_import_and_worker_writes_import_detail()
|
||||
{
|
||||
await using var factory = new ApiTestFactory();
|
||||
var seed = await SeedAdminAsync(factory);
|
||||
using var client = factory.CreateClient();
|
||||
await LoginAsync(client, seed);
|
||||
|
||||
var queueResponse = await client.PostAsJsonAsync(
|
||||
"/api/tenant-content/imports/questions",
|
||||
new DirectImportDto
|
||||
{
|
||||
Async = true,
|
||||
Items =
|
||||
[
|
||||
JsonSerializer.SerializeToElement(new { type = "choice", content = "异步导入题" })
|
||||
]
|
||||
});
|
||||
var queuedJob = await queueResponse.Content.ReadFromJsonAsync<BackgroundJobItem>(JsonOptions);
|
||||
|
||||
using var scope = factory.CreateSystemScope();
|
||||
var jobService = scope.ServiceProvider.GetRequiredService<IBackgroundJobService>();
|
||||
var processed = await jobService.ProcessPendingAsync("content-import-test-worker", 10);
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<TikuDbContext>();
|
||||
var storedJob = dbContext.BackgroundJobs.Single(item => item.Id == queuedJob!.Id);
|
||||
var importJobId = storedJob.Result.GetProperty("importJobId").GetGuid();
|
||||
|
||||
var detailResponse = await client.GetAsync($"/api/tenant-content/imports/detail?jobId={importJobId}");
|
||||
var detail = await ReadJsonAsync(detailResponse);
|
||||
|
||||
Assert.Equal(HttpStatusCode.Accepted, queueResponse.StatusCode);
|
||||
Assert.Equal(1, processed);
|
||||
Assert.Equal(BackgroundJobStatus.Succeeded, storedJob.Status);
|
||||
Assert.Equal(HttpStatusCode.OK, detailResponse.StatusCode);
|
||||
Assert.Equal(1, detail.RootElement.GetProperty("job").GetProperty("insertedCount").GetInt32());
|
||||
Assert.Single(detail.RootElement.GetProperty("items").EnumerateArray());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Tenant_admin_can_upsert_scoreline_fields_and_records()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user