Skip to content

Commit

Permalink
Test stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielchalmers committed Apr 1, 2024
1 parent 3cc7c93 commit ca376c3
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 7 deletions.
19 changes: 13 additions & 6 deletions JournalApp.Tests/CalendarTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public async Task CalendarViewMoodBlockCount()
cut.FindAll(".calendar-view .mood-block-container > .mood-block-filled").Count.Should().Be(0);
}

[Fact(Skip = "Stub")]
public async Task CannotSeeIntoFuture() { }

[Fact]
public void CalendarViewRespectsFirstDay()
{
Expand All @@ -101,24 +104,28 @@ public void CalendarViewRespectsFirstDay()
weekHeaders[6].TextContent.Should().Be("Tu");
}

[Fact(Skip = "MoodPalettePreference uses Preferences internally which is not set up")]
[Fact(Skip = "Can't find dialog")]
public void ChangePalette()
{
var cut = RenderComponent<CalendarPage>(p =>
p.Add(x => x.OpenToDateString, "20230101")
);

cut.Find(".pick-palette").Click();

cut.Find(".color-picker");
var preferenceService = Services.GetService<PreferenceService>();
var initialColor = preferenceService.PrimaryColor;

var overlay = cut.Find(".color-picker .mud-dialog-content .mud-picker-color-overlay-black .mud-picker-color-overlay");
cut.Find(".pick-palette").Click();

// Click a color.
var overlay = cut.WaitForElement(".color-picker .mud-dialog-content .mud-picker-color-overlay-black .mud-picker-color-overlay");
overlay.Click(new MouseEventArgs { OffsetX = 235, OffsetY = 18 });

// Close dialog.
cut.Find(".mud-dialog-container .mud-overlay-dialog").Click();
cut.FindAll(".mud-overlay-dialog").Count.Should().Be(0);

//cut.Instance.PrimaryColor.Should().Be("#3ad9ec");
// Color should have changed.
preferenceService.PrimaryColor.Should().NotBe(initialColor);
}

[Fact]
Expand Down
53 changes: 53 additions & 0 deletions JournalApp.Tests/EditCategoryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
namespace JournalApp.Tests;

public class EditCategoryTests : JaTestContext
{
public override async Task InitializeAsync()
{
await base.InitializeAsync();

AddDbContext();
}

[Fact(Skip = "Stub")]
public async Task EditExistingCategory()
{
var category = new DataPointCategory
{
Guid = Guid.NewGuid(),
Type = PointType.Note,
Name = "My note",

};

var dialogService = Services.GetService<IDialogService>();
var cut = RenderComponent<MudDialogProvider>();

//var parameters = new DialogParameters<EditCategoryDialog> { { x => x.Group, category.Group }, { x => x.Category, category } };
//var result = await DialogService.Show<EditCategoryDialog>(parameters).Result;

IDialogReference dialogReference = null;
await cut.InvokeAsync(() => dialogReference = dialogService?.Show<EditCategoryDialog>());
}

[Fact(Skip = "Stub")]
public async Task EditNewCategory() { }

[Fact(Skip = "Stub")]
public async Task EditExistingMedication() { }

[Fact(Skip = "Stub")]
public async Task EditNewMedication() { }

[Fact(Skip = "Stub")]
public async Task DeleteCategory() { }

[Fact(Skip = "Stub")]
public async Task BackButtonSaves() { }

[Fact(Skip = "Stub")]
public async Task SaveButtonSaves() { }

[Fact(Skip = "Stub")]
public async Task CancelButtonCancels() { }
}
17 changes: 17 additions & 0 deletions JournalApp.Tests/ImportExportTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace JournalApp.Tests;

public class ImportExportTests : JaTestContext
{
public override async Task InitializeAsync()
{
await base.InitializeAsync();

AddDbContext();
}

[Fact(Skip = "Stub")]
public async Task EverythingInBackupIsImported() { }

[Fact(Skip = "Stub")]
public async Task ExportFormatHasNotChanged() { }
}
26 changes: 26 additions & 0 deletions JournalApp.Tests/IndexTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace JournalApp.Tests;

public class IndexTests : JaTestContext
{
public override async Task InitializeAsync()
{
await base.InitializeAsync();

AddDbContext();
}

[Fact(Skip = "Stub")]
public async Task CanSwitchDays() { }

Check warning on line 13 in JournalApp.Tests/IndexTests.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

[Fact(Skip = "Stub")]
public async Task SwitchDaysPersistsData() { }

Check warning on line 16 in JournalApp.Tests/IndexTests.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

[Fact(Skip = "Stub")]
public async Task CannotGoIntoFuture() { }

Check warning on line 19 in JournalApp.Tests/IndexTests.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

[Fact(Skip = "Stub")]
public async Task OpenCalendar() { }

Check warning on line 22 in JournalApp.Tests/IndexTests.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

[Fact(Skip = "Stub")]
public async Task HideTodaysNotes() { }

Check warning on line 25 in JournalApp.Tests/IndexTests.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
}
26 changes: 26 additions & 0 deletions JournalApp.Tests/ManageCategoriesTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace JournalApp.Tests;

public class ManageCategoriesTests : JaTestContext
{
public override async Task InitializeAsync()
{
await base.InitializeAsync();

AddDbContext();
}

[Fact(Skip = "Stub")]
public async Task ClickCategoryOpensEditorAndUpdatesList() { }

Check warning on line 13 in JournalApp.Tests/ManageCategoriesTests.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

[Fact(Skip = "Stub")]
public async Task ClickPlusOpensEditorAndAddsNewCategoryToList() { }

Check warning on line 16 in JournalApp.Tests/ManageCategoriesTests.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

[Fact(Skip = "Stub")]
public async Task ClickCategoryOpensEditor() { }

Check warning on line 19 in JournalApp.Tests/ManageCategoriesTests.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

[Fact(Skip = "Stub")]
public async Task CannotEditReadOnlyCategories() { }

Check warning on line 22 in JournalApp.Tests/ManageCategoriesTests.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

[Fact(Skip = "Stub")]
public async Task Reorder() { }

Check warning on line 25 in JournalApp.Tests/ManageCategoriesTests.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
}
21 changes: 20 additions & 1 deletion JournalApp.Tests/SafetyPlanTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,26 @@
public class SafetyPlanTests : JaTestContext
{
[Fact]
public void Persists()
[Description("The plan must actually load from preferences")]
public void PlanIsLoaded()
{
var preferenceService = Services.GetService<PreferenceService>();

preferenceService.SafetyPlan = new()
{
Purpose = "My purpose is to finish these tests",
};

var cut = RenderComponent<SafetyPlanPage>();

// Assert state.
cut.Instance.Plan.Purpose.Should().Be("My purpose is to finish these tests");
cut.Find(".safety-plan-item-purpose textarea").TextContent.Should().Be("My purpose is to finish these tests");
}

[Fact]
[Description("The safety plan must save changes and load them back next time")]
public void PlanPersists()
{
var preferenceService = Services.GetService<PreferenceService>();

Expand Down

0 comments on commit ca376c3

Please sign in to comment.