Initial curated itworx-knowledge-hub source from 3b1751d0d9dee551aa6994eee0093704dc334817
This commit is contained in:
commit
ad8ad252a9
825 files changed
+124216
No files matched your search
@@ -0,0 +1,65 @@
|
||||
using System.Net.Http.Json;
|
||||
using ItWorx.KnowledgeHub.Contracts.Knowledge;
|
||||
using ItWorx.KnowledgeHub.IntegrationTests.Infrastructure;
|
||||
|
||||
namespace ItWorx.KnowledgeHub.IntegrationTests.Knowledge;
|
||||
|
||||
/// <summary>Templates create valid study note, runbook, ADR and troubleshooting
|
||||
/// documents (docs/27-acceptance-matrix.md, M2-A06).</summary>
|
||||
[Collection(PostgresTestGroup.Name)]
|
||||
public sealed class TemplateTests(PostgresContainerFixture postgres) : OwnerSetupTestBase(postgres)
|
||||
{
|
||||
[Fact]
|
||||
public async Task All_four_built_in_templates_are_listed()
|
||||
{
|
||||
using var client = Factory.CreateClient();
|
||||
await SetupHelper.LoginAsync(client, OwnerEmail, OwnerPassword);
|
||||
|
||||
var templates = await client.GetFromJsonAsync<IReadOnlyList<TemplateSummary>>("/api/v1/templates");
|
||||
|
||||
Assert.NotNull(templates);
|
||||
Assert.Equal(4, templates.Count);
|
||||
Assert.Contains(templates, t => t.Key == "study-note");
|
||||
Assert.Contains(templates, t => t.Key == "runbook");
|
||||
Assert.Contains(templates, t => t.Key == "architecture-decision");
|
||||
Assert.Contains(templates, t => t.Key == "troubleshooting");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("study-note", "StudyNote", "## Kernidee")]
|
||||
[InlineData("runbook", "Runbook", "## Rollback")]
|
||||
[InlineData("architecture-decision", "ArchitectureDecision", "## Beslissing")]
|
||||
[InlineData("troubleshooting", "Troubleshooting", "## Escalatie")]
|
||||
public async Task Creating_a_page_from_a_template_produces_the_expected_structure(
|
||||
string templateKey,
|
||||
string expectedDocumentType,
|
||||
string expectedSectionHeading)
|
||||
{
|
||||
using var client = Factory.CreateClient();
|
||||
await SetupHelper.LoginAsync(client, OwnerEmail, OwnerPassword);
|
||||
|
||||
var response = await SetupHelper.PostWithCsrfAsync(
|
||||
client,
|
||||
"/api/v1/pages",
|
||||
new CreatePageRequest(null, $"Sjabloontest {templateKey}", null, null, templateKey));
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var page = await response.Content.ReadFromJsonAsync<PageDetail>();
|
||||
Assert.NotNull(page);
|
||||
Assert.Equal(expectedDocumentType, page.DocumentType);
|
||||
Assert.Contains($"# Sjabloontest {templateKey}", page.Markdown, StringComparison.Ordinal);
|
||||
Assert.Contains(expectedSectionHeading, page.Markdown, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task An_unknown_template_key_is_rejected()
|
||||
{
|
||||
using var client = Factory.CreateClient();
|
||||
await SetupHelper.LoginAsync(client, OwnerEmail, OwnerPassword);
|
||||
|
||||
var response = await SetupHelper.PostWithCsrfAsync(
|
||||
client, "/api/v1/pages", new CreatePageRequest(null, "Ongeldig sjabloon", null, null, "does-not-exist"));
|
||||
|
||||
Assert.Equal(System.Net.HttpStatusCode.UnprocessableEntity, response.StatusCode);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user