feat: import leftover student fields into notes and show them on the roster
Store leftover CSV columns on hidden student notes, move catalog import to /events/import, and persist Students index columns from Chapter Settings. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using Core.Services;
|
||||
|
||||
namespace Tests.Services;
|
||||
|
||||
[TestFixture]
|
||||
public class NoteNamingService_Tests
|
||||
{
|
||||
private readonly NoteNamingService _service = new();
|
||||
|
||||
[Test]
|
||||
public void GetStudentNoteTitle_UsesStablePrefix()
|
||||
{
|
||||
Assert.That(_service.GetStudentNoteTitle(42), Is.EqualTo("#Student:42"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsStudentNote_AndParseId()
|
||||
{
|
||||
Assert.That(_service.IsStudentNote("#Student:12"), Is.True);
|
||||
Assert.That(_service.IsStudentNote("#Students"), Is.False);
|
||||
Assert.That(_service.TryParseStudentNoteId("#Student:12", out var id), Is.True);
|
||||
Assert.That(id, Is.EqualTo(12));
|
||||
Assert.That(_service.TryParseStudentNoteId("#Event Ranking", out _), Is.False);
|
||||
Assert.That(_service.IsStudentNote(null), Is.False);
|
||||
Assert.That(_service.TryParseStudentNoteId("#Student:", out _), Is.False);
|
||||
Assert.That(_service.IsPageNote("#Student:12"), Is.True);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using Core.Models;
|
||||
using Core.Notes;
|
||||
using Core.Services;
|
||||
using Tests.Builders;
|
||||
|
||||
namespace Tests.Services;
|
||||
|
||||
[TestFixture]
|
||||
public class StudentNotesImportPlan_Tests
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
BuilderExtensions.ResetAllBuilders();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Create_SkipsUnchanged_CreatesAndUpdatesChanged()
|
||||
{
|
||||
var aria = StudentBuilder.Create("Aria", "Chittenden").Build();
|
||||
var blake = StudentBuilder.Create("Blake", "Nguyen").Build();
|
||||
var casey = StudentBuilder.Create("Casey", "Ortiz").Build();
|
||||
|
||||
var firstWrite = ImportedFieldsTable.Merge(null, [new ImportedField("Application", "Yes")]);
|
||||
var unchanged = ImportedFieldsTable.Merge(firstWrite.Markdown, [new ImportedField("Application", "Yes")]);
|
||||
var created = ImportedFieldsTable.Merge(null, [new ImportedField("Interview Time", "3:20-3:35")]);
|
||||
var updated = ImportedFieldsTable.Merge(
|
||||
ImportedFieldsTable.Merge(null, [new ImportedField("Application", "Yes")]).Markdown,
|
||||
[new ImportedField("Application", "")]);
|
||||
|
||||
var parseResult = new StudentNotesImportResult
|
||||
{
|
||||
Matches =
|
||||
[
|
||||
Match(aria, unchanged),
|
||||
Match(blake, created),
|
||||
Match(casey, updated)
|
||||
]
|
||||
};
|
||||
|
||||
HashSet<int> existingNoteIds = [casey.Id];
|
||||
var actions = StudentNotesImportPlan.Create(parseResult, existingNoteIds);
|
||||
|
||||
Assert.That(actions, Has.Count.EqualTo(2));
|
||||
Assert.That(actions.Any(a => a.StudentId == aria.Id), Is.False);
|
||||
Assert.That(actions.Single(a => a.StudentId == blake.Id).Kind, Is.EqualTo(StudentNotePersistKind.Create));
|
||||
Assert.That(actions.Single(a => a.StudentId == casey.Id).Kind, Is.EqualTo(StudentNotePersistKind.Update));
|
||||
Assert.That(actions.Single(a => a.StudentId == casey.Id).Markdown, Is.EqualTo(updated.Markdown));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Create_EmptyMatches_ReturnsNoActions()
|
||||
{
|
||||
var actions = StudentNotesImportPlan.Create(new StudentNotesImportResult(), new HashSet<int>());
|
||||
Assert.That(actions, Is.Empty);
|
||||
}
|
||||
|
||||
private static StudentNotesImportMatch Match(Core.Entities.Student student, ImportedFieldsMergeResult merge) =>
|
||||
new()
|
||||
{
|
||||
Student = student,
|
||||
Merge = merge
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user