Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop #52

Merged
merged 8 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions src/Chrono.Tests/E2E/04_Notes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System.Text.RegularExpressions;
using Microsoft.Playwright;
using NUnit.Framework;

namespace Chrono.Tests.E2E;

public partial class E2ETests
{
[Test]
public async Task Add_Edit_Pin_Unpin_Delete_Notes()
{
await _page.GotoAsync(_config["WebAppUrl"]!);

// Add first note
await _page.GetByText("Notes").ClickAsync();
await _page.GetByRole(AriaRole.Button, new PageGetByRoleOptions { Name = "Add Note" }).ClickAsync();

await _page.GetByPlaceholder("Title").ClickAsync();
await _page.GetByPlaceholder("Title").FillAsync("Test Note");

await _page.GetByPlaceholder("Content").ClickAsync();
await _page.GetByPlaceholder("Content").FillAsync("This is a test note.\n- A\n- B\n- C");

await _page.GetByText("Preview").ClickAsync();
await Expect(_page.GetByText("A", new PageGetByTextOptions { Exact = true })).ToBeVisibleAsync();
await Expect(_page.GetByText("B", new PageGetByTextOptions { Exact = true })).ToBeVisibleAsync();
await Expect(_page.GetByText("C", new PageGetByTextOptions { Exact = true })).ToBeVisibleAsync();

await _page.GetByText("Write").ClickAsync();

await _page.GetByRole(AriaRole.Button, new PageGetByRoleOptions { Name = "Save" }).ClickAsync();
await _page.GetByRole(AriaRole.Listbox).ClickAsync();
await _page.GetByRole(AriaRole.Option, new PageGetByRoleOptions { Name = "Save & Close" }).ClickAsync();

await Expect(_page.GetByRole(AriaRole.Link, new PageGetByRoleOptions { Name = "Test Note" }))
.ToBeVisibleAsync();

// Add second note
await _page.GetByRole(AriaRole.Button, new PageGetByRoleOptions { Name = "Add Note" }).ClickAsync();

await _page.GetByPlaceholder("Title").ClickAsync();
await _page.GetByPlaceholder("Title").FillAsync("Test Note 2");

await _page.GetByPlaceholder("Content").ClickAsync();
await _page.GetByPlaceholder("Content").FillAsync("#2");

await _page.GetByRole(AriaRole.Button, new PageGetByRoleOptions { Name = "Save" }).ClickAsync();
await _page.GetByRole(AriaRole.Listbox).ClickAsync();
await _page.GetByText("Save & Close").ClickAsync();

await Expect(_page.GetByRole(AriaRole.Link, new PageGetByRoleOptions { Name = "Test Note 2" }))
.ToBeVisibleAsync();

await _page.Locator("div").Filter(new LocatorFilterOptions { HasTextRegex = new Regex("^Test Note$") })
.Locator("i")
.ClickAsync();

await Expect(_page.GetByTitle("Unpin")).ToBeVisibleAsync();

await _page.GetByTitle("Unpin").ClickAsync();

// Delete second note
await _page.GetByRole(AriaRole.Link, new PageGetByRoleOptions { Name = "Test Note 2" }).ClickAsync();
await _page.GetByRole(AriaRole.Listbox).ClickAsync();
await _page.GetByRole(AriaRole.Option, new PageGetByRoleOptions { Name = "Delete note" }).ClickAsync();
await _page.GetByRole(AriaRole.Button, new PageGetByRoleOptions { Name = "OK" }).ClickAsync();

// Delete first note
await _page.GetByRole(AriaRole.Link, new PageGetByRoleOptions { Name = "Test Note" }).ClickAsync();
await _page.GetByRole(AriaRole.Listbox).ClickAsync();
await _page.GetByText("Delete note").ClickAsync();
await _page.GetByRole(AriaRole.Button, new PageGetByRoleOptions { Name = "OK" }).ClickAsync();
}
}
6 changes: 3 additions & 3 deletions src/Chrono.Tests/Helper/FakePolicyEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

namespace Chrono.Tests.Helper;

public class FakePolicyEvaluator : IPolicyEvaluator
public sealed class FakePolicyEvaluator : IPolicyEvaluator
{
public virtual async Task<AuthenticateResult> AuthenticateAsync(AuthorizationPolicy policy, HttpContext context)
public async Task<AuthenticateResult> AuthenticateAsync(AuthorizationPolicy policy, HttpContext context)
{
var principal = new ClaimsPrincipal();
principal.AddIdentity(new ClaimsIdentity(Array.Empty<Claim>(), "FakeScheme"));
Expand All @@ -17,7 +17,7 @@ public virtual async Task<AuthenticateResult> AuthenticateAsync(AuthorizationPol
new AuthenticationProperties(), "FakeScheme")));
}

public virtual async Task<PolicyAuthorizationResult> AuthorizeAsync(AuthorizationPolicy policy,
public async Task<PolicyAuthorizationResult> AuthorizeAsync(AuthorizationPolicy policy,
AuthenticateResult authenticationResult, HttpContext context, object resource)
{
return await Task.FromResult(PolicyAuthorizationResult.Success());
Expand Down
7 changes: 1 addition & 6 deletions src/Chrono/Chrono.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@
</AssemblyAttribute>
</ItemGroup>

<ItemGroup>
<_ContentIncludedByDefault Remove="Pages\Error.cshtml"/>
<_ContentIncludedByDefault Remove="Pages\_ViewImports.cshtml"/>
</ItemGroup>

<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
<!-- Ensure Node.js is installed -->
<Exec Command="node --version" ContinueOnError="true">
Expand All @@ -62,7 +57,7 @@
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install"/>
</Target>

<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<Target Name="PublishRunVite" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install"/>
<Exec WorkingDirectory="$(SpaRoot)" Command="npm run build"/>
Expand Down
Loading
Loading