Wave/Wave.Tests/Data/ApplicationDbContextTest.cs
Mia Rose Winter 1d55ab23f0
Implemented client side article editor (#6)
* started implementing article API, missing lots of tests to validate feature

* made tests more pretty

* re-structured tests

* refactored dto contracts

* tested and fixed updating categories

* added permission tests, fixed bug in Permissions system

* added data validation tests for update article

* refactored repository interface

* Added ArticleView dto, fixed bug in requesting articles over repository

* updated dependencies

* optimized program.cs, added repo service

* Removed all interactivity from ArticleEditor, merged files

* added vite, tailwind working, dev server is not, js is not yet

* added fontsource for font management using vite's bundling

* moved vite output to wwwroot/dist
reorganized stuff that will never need processing or needs to be at site root

* fixed heading font weight not being 700 anymore

* implemented react in ArticleEditor

* added article status steps to react component
noticed I need to figure out client side localization

* fixed vite dev server thingies, tailwind and react refresh works now

* added article form skeletton to react

* more editor implementations

* minor typescript fixes

* implemented proper editor functions

* added all missing toolbar buttons

* fixed error, made open article work

* improved article editor structure

* implemented article editor taking id from the url

* Implemented categories endpoint

* implemented categories in article editor

* fixed minor TS issues

* implemented localization in article editor

* completed localization

* implemented loading selected categories

* minor code improvements and maybe a regex fix

* fixed bug with not getting unpublished articles

* implemented form state

* fixed validation issues

* implemented saving (missing creation)

* fixed minor bug with status display

* organized models

* added live markdown preview (incomplete)

* fixed issues in article create api endpoint

* improved article saving, implemented creating

* fixed publish date not being set correctly when creating article

* fixed slugs once more

* added run config for production (without vite dev)

* removed unused code

* updated dockerfile to build Assets

* fixed slug generation

* updated tests to validate new slug generator

* savsdSACAVSD

* fixed validation issues and tests
2024-06-18 09:09:47 +02:00

46 lines
1.4 KiB
C#

using Microsoft.EntityFrameworkCore;
using Wave.Data;
using Wave.Tests.TestUtilities;
namespace Wave.Tests.Data;
[TestFixture, FixtureLifeCycle(LifeCycle.InstancePerTestCase)]
[TestOf(typeof(ApplicationDbContext))]
public class ApplicationDbContextTest : DbContextTest {
[Test]
public async Task Migration() {
await using var context = GetContext();
Assert.DoesNotThrowAsync(() => context.Database.MigrateAsync());
}
[Test]
public async Task CreateArticle() {
await using var context = GetContext();
await context.Database.EnsureCreatedAsync();
var author = new ApplicationUser {
FullName = "Test User"
};
Article article = new() {
Title = "Testing Article",
Body = "This is a *test* Article",
Author = author
};
article.UpdateSlug(null);
article.UpdateBody();
await context.AddAsync(article);
Assert.DoesNotThrowAsync(() => context.SaveChangesAsync());
var dbArticle = await context.Set<Article>()
.IgnoreQueryFilters().FirstOrDefaultAsync();
Assert.That(dbArticle, Is.Not.Null);
Assert.That(dbArticle.Title, Is.EqualTo("Testing Article"));
Assert.That(dbArticle.Slug, Is.EqualTo("testing-article"));
Assert.That(dbArticle.Body, Is.EqualTo("This is a *test* Article"));
Assert.That(dbArticle.BodyPlain, Is.EqualTo("This is a test Article"));
Assert.That(dbArticle.BodyHtml, Is.EqualTo("<p>This is a <em>test</em> Article</p>"));
}
}