Wave/Wave.Tests/Data/ArticleTest.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

104 lines
3.8 KiB
C#

using Wave.Data;
namespace Wave.Tests.Data;
[TestFixture, FixtureLifeCycle(LifeCycle.InstancePerTestCase)]
[TestOf(typeof(Article))]
public class ArticleTest {
private Article Article { get; } = new() {
Author = null!,
Title = null!,
Body = null!
};
[Test]
public void SlugWithAscii() {
Article.Title = "Testing Article";
Article.UpdateSlug();
Assert.That(Article.Slug, Is.EqualTo("testing-article"));
}
[Test]
public void SlugWithSpecialCharacters() {
Article.Title = "Title with, special characters?";
Article.UpdateSlug();
Assert.That(Article.Slug, Is.EqualTo("title-with-special-characters"));
}
[Test]
public void SlugFromTitleLongerThan64Characters() {
Article.Title = "Article Title that is longer than the sixty four character limit and should be truncated";
Article.UpdateSlug();
Assert.That(Article.Slug, Is.EqualTo("article-title-that-is-longer-than-the-sixty-four-character-limit"));
}
[Test]
public void SlugFromTitleLongerThan64CharacterWithSpecialCharacterEscapeSize3AtPosition55() {
Article.Title = "Auto generating slugs was a mistake I hate this ______ €";
Article.UpdateSlug();
Assert.That(Article.Slug, Is.EqualTo("auto-generating-slugs-was-a-mistake-i-hate-this-______-"));
}
[Test]
public void SlugFromTitleLongerThan64CharacterWithSpecialCharacterEscapeSize2AtPosition56() {
Article.Title = "Auto generating slugs was a mistake I hate this _______ üa";
Article.UpdateSlug();
Assert.That(Article.Slug, Is.EqualTo("auto-generating-slugs-was-a-mistake-i-hate-this-_______-a"));
}
[Test]
public void SlugFromTitleLongerThan64CharacterWithSpecialCharacterEscapeSize3AtPosition56() {
Article.Title = "Auto generating slugs was a mistake I hate this _______ €";
Article.UpdateSlug();
Assert.That(Article.Slug, Is.EqualTo("auto-generating-slugs-was-a-mistake-i-hate-this-_______-"));
}
[Test]
public void SlugFromTitleLongerThan64CharacterWithSpecialCharacterEscapeSize2AtPosition57() {
Article.Title = "Auto generating slugs was a mistake I hate this ________ üa";
Article.UpdateSlug();
Assert.That(Article.Slug, Is.EqualTo("auto-generating-slugs-was-a-mistake-i-hate-this-________-a"));
}
[Test]
public void SlugFromTitleLongerThan64CharacterWithSpecialCharacterEscapeSize3AtPosition57() {
Article.Title = "Auto generating slugs was a mistake I hate this ________ €";
Article.UpdateSlug();
Assert.That(Article.Slug, Is.EqualTo("auto-generating-slugs-was-a-mistake-i-hate-this-________-"));
}
[Test]
public void SlugFromTitleLongerThan64CharacterWithSpecialCharacterAtPosition61() {
Article.Title = "Article that ends with a special character and need special cäre";
Article.UpdateSlug();
Assert.That(Article.Slug, Is.EqualTo("article-that-ends-with-a-special-character-and-need-special-cre"));
}
[Test]
public void SlugFromTitleLongerThan64CharacterWithSpecialCharacterAtPosition62() {
Article.Title = "Article that ends with a special character and needs special cäre";
Article.UpdateSlug();
Assert.That(Article.Slug, Is.EqualTo("article-that-ends-with-a-special-character-and-needs-special-cre"));
}
[Test]
public void SlugFromTitleLongerThan64CharacterWithSpecialCharacterAtPosition63() {
Article.Title = "Article that ends with a special character and needs special caäre";
Article.UpdateSlug();
Assert.That(Article.Slug, Is.EqualTo("article-that-ends-with-a-special-character-and-needs-special-car"));
}
[Test]
public void SlugProvidedValidUri() {
Article.Title = "Testing providing a slug";
Article.UpdateSlug("test-slug");
Assert.That(Article.Slug, Is.EqualTo("test-slug"));
}
[Test]
public void SlugProvidedNeedsEscaping() {
Article.Title = "Testing providing a slug";
Article.UpdateSlug("test slug");
Assert.That(Article.Slug, Is.EqualTo("test-slug"));
}
}