diff --git a/Chirp/test/PlaywrightTests/UITests/GeneralTests.cs b/Chirp/test/PlaywrightTests/UITests/GeneralTests.cs index 6075bbcb..1ef40f65 100644 --- a/Chirp/test/PlaywrightTests/UITests/GeneralTests.cs +++ b/Chirp/test/PlaywrightTests/UITests/GeneralTests.cs @@ -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."); } @@ -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()