feat(ads/seo/release): v1.2.0 with live Google Ads, isolated ad profile, ads.txt, and SEO/AEO/GEO optimization
This commit is contained in:
parent
a88aafa1e5
commit
0e568f1f0a
975 changed files with 130593 additions and 16783 deletions
93
tests/Paca.Tests/Server/WorkspaceRemoteApiTests.cs
Normal file
93
tests/Paca.Tests/Server/WorkspaceRemoteApiTests.cs
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
using System.Net;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using Paca.Server;
|
||||
using Xunit;
|
||||
|
||||
namespace Paca.Tests.Server;
|
||||
|
||||
public class WorkspaceRemoteApiTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task GetWorkspace_ReturnsCurrentAndWorkspacesList()
|
||||
{
|
||||
string currentWs = "작업";
|
||||
var allWs = new List<string> { "작업", "개인", "학습" };
|
||||
|
||||
await using var server = await ServerHost.StartAsync(new ServerOptions
|
||||
{
|
||||
Port = 0,
|
||||
Token = "ws-test-token",
|
||||
WorkspaceProvider = () => new WorkspaceInfoDto(currentWs, allWs)
|
||||
});
|
||||
|
||||
using var client = new HttpClient();
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "ws-test-token");
|
||||
|
||||
var response = await client.GetAsync($"http://127.0.0.1:{server.Port}/api/workspace");
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
|
||||
var dto = await response.Content.ReadFromJsonAsync<WorkspaceInfoDto>();
|
||||
Assert.NotNull(dto);
|
||||
Assert.Equal("작업", dto.Current);
|
||||
Assert.Equal(3, dto.Workspaces.Count);
|
||||
Assert.Contains("작업", dto.Workspaces);
|
||||
Assert.Contains("개인", dto.Workspaces);
|
||||
Assert.Contains("학습", dto.Workspaces);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PostWorkspaceSwitch_SwitchesWorkspaceAndReturnsOk()
|
||||
{
|
||||
string currentWs = "작업";
|
||||
string? switchedTo = null;
|
||||
var allWs = new List<string> { "작업", "개인", "학습" };
|
||||
|
||||
await using var server = await ServerHost.StartAsync(new ServerOptions
|
||||
{
|
||||
Port = 0,
|
||||
Token = "ws-test-token",
|
||||
WorkspaceProvider = () => new WorkspaceInfoDto(currentWs, allWs),
|
||||
WorkspaceSwitcher = name =>
|
||||
{
|
||||
switchedTo = name;
|
||||
currentWs = name;
|
||||
}
|
||||
});
|
||||
|
||||
using var client = new HttpClient();
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "ws-test-token");
|
||||
|
||||
var response = await client.PostAsJsonAsync($"http://127.0.0.1:{server.Port}/api/workspace/switch", new
|
||||
{
|
||||
name = "개인"
|
||||
});
|
||||
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Equal("개인", switchedTo);
|
||||
Assert.Equal("개인", currentWs);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PostWorkspaceSwitch_RejectsCorruptedName_WithBadRequest()
|
||||
{
|
||||
await using var server = await ServerHost.StartAsync(new ServerOptions
|
||||
{
|
||||
Port = 0,
|
||||
Token = "ws-test-token",
|
||||
WorkspaceProvider = () => new WorkspaceInfoDto("작업", new[] { "작업" }),
|
||||
WorkspaceSwitcher = _ => { }
|
||||
});
|
||||
|
||||
using var client = new HttpClient();
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "ws-test-token");
|
||||
|
||||
// Attempting to switch to a corrupted unicode replacement string
|
||||
var response = await client.PostAsJsonAsync($"http://127.0.0.1:{server.Port}/api/workspace/switch", new
|
||||
{
|
||||
name = "\uFFFD\u06FE\uFFFD"
|
||||
});
|
||||
|
||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue