Skip to content

Commit

Permalink
Created test for multipel users with the same email
Browse files Browse the repository at this point in the history
  • Loading branch information
stoftot committed Dec 18, 2024
1 parent 509d6fc commit e26374c
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions Chirp/test/PlaywrightTests/UITests/GeneralTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,7 @@ public async Task CantCreateUserThatAlreadyExists()

await Page.GotoAsync("/");
await Page.GetByRole(AriaRole.Link, new() { Name = "register" }).ClickAsync();
await Page.GetByPlaceholder("name", new() { Exact = true }).ClickAsync();
await Page.GetByPlaceholder("name", new() { Exact = true }).FillAsync(testAuthor.UserName!);
await Page.GetByPlaceholder("name@example.com").ClickAsync();
await Page.GetByPlaceholder("name@example.com").FillAsync("test@test.test");
await Page.GetByLabel("Password", new() { Exact = true }).ClickAsync();
await Page.GetByLabel("Password", new() { Exact = true }).FillAsync("Password123!");
await Page.GetByLabel("Confirm Password").ClickAsync();
await Page.GetByLabel("Confirm Password").FillAsync("Password123!");
await Page.GetByRole(AriaRole.Button, new() { Name = "Register" }).ClickAsync();
await RazorPageUtils.Register(testAuthor);
await Expect(Page.GetByRole(AriaRole.Listitem)).ToContainTextAsync($"Username '{testAuthor.UserName}' is already taken.");
}

Expand All @@ -78,6 +70,31 @@ public async Task CreateUserWithMissingInfo()
await Expect(Page.Locator("#registerForm")).ToContainTextAsync("The Email field is required.");
await Expect(Page.Locator("#registerForm")).ToContainTextAsync("The Password field is required.");
}

[Test]
public async Task CreateMultipelUsersWithTheSameEmail()
{
var testAuthor = new TestAuthorBuilder(RazorFactory.GetUserManager())
.WithUsername("test1")
.WithEmail("test@test.com")
.Create();

var testAuthor2 = new TestAuthorBuilder(RazorFactory.GetUserManager())
.WithUsername("test2")
.WithEmail("test@test.com")
.GetTestAuthor();

await Page.GotoAsync("/");
await Page.GetByRole(AriaRole.Link, new() { Name = "register" }).ClickAsync();
await RazorPageUtils.Register(testAuthor2);
await RazorPageUtils.Logout(testAuthor2);
await Page.GetByRole(AriaRole.Link, new() { Name = "register" }).ClickAsync();
await RazorPageUtils.Login(testAuthor);
await RazorPageUtils.Logout(testAuthor);
await Page.GetByRole(AriaRole.Link, new() { Name = "register" }).ClickAsync();
await RazorPageUtils.Login(testAuthor2);
await RazorPageUtils.Logout(testAuthor2);
}

[Test]
public async Task CantLoginUserThatDosentExists()
Expand Down

0 comments on commit e26374c

Please sign in to comment.