Skip to content

Commit 86cd90b

Browse files
committed
Simplifies UI tests and configures backend URLs
Updates the UI tests to directly wait for the URL after button clicks, removing the need for explicit wait states and forced clicks. Changes the way the backend URL is configured in the AppHost to use environment variables that are more standard and easier to configure. This change makes the application more flexible and easier to deploy in different environments.
1 parent 0aa5c03 commit 86cd90b

9 files changed

Lines changed: 7 additions & 4709 deletions

File tree

ReactApp.AppHost/AppHost.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
.WithHttpEndpoint(env: "PORT")
5454
.WithExternalHttpEndpoints()
5555
.WithDependency(backend)
56-
.WithEnvironment("services__ReactApp-backend__http__0", backend.GetEndpoint("http"))
57-
.WithEnvironment("services__ReactApp-backend__https__0", backend.GetEndpoint("https"));
56+
.WithEnvironment("REACTAPP_BACKEND_HTTP", backend.GetEndpoint("http"))
57+
.WithEnvironment("REACTAPP_BACKEND_HTTPS", backend.GetEndpoint("https"));
5858

5959
if (builder.ExecutionContext.IsPublishMode)
6060
{

ReactApp.UITests/PageObjects/LoginPage.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,8 @@ public async Task LoginAsync(string email, string password)
1818
await EmailInput.FillAsync(email);
1919
await PasswordInput.FillAsync(password);
2020

21-
// Ensure the button is ready (React might still be attaching event handlers)
22-
await LoginButton.WaitForAsync(new LocatorWaitForOptions
23-
{
24-
State = WaitForSelectorState.Visible,
25-
Timeout = 5000
26-
});
27-
28-
// Wait for navigation to my-rooms after submitting the form
29-
// Use force: true to bypass actionability checks that may fail on Linux
30-
await Page.RunAndWaitForNavigationAsync(async () =>
31-
{
32-
await LoginButton.ClickAsync(new LocatorClickOptions { Force = true });
33-
}, new PageRunAndWaitForNavigationOptions
34-
{
35-
UrlString = "**/my-rooms",
36-
Timeout = 30000,
37-
WaitUntil = WaitUntilState.Load // Use Load instead of NetworkIdle for better Linux compatibility
38-
});
21+
await LoginButton.ClickAsync();
22+
await Page.WaitForURLAsync("**/my-rooms", new PageWaitForURLOptions { Timeout = 30000 });
3923
}
4024

4125
public async Task<bool> IsLoggedInAsync()

ReactApp.UITests/PageObjects/RegisterPage.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,8 @@ public async Task RegisterAsync(string email, string password)
2020
await PasswordInput.FillAsync(password);
2121
await ConfirmPasswordInput.FillAsync(password);
2222

23-
// Ensure the button is ready (React might still be attaching event handlers)
24-
await RegisterButton.WaitForAsync(new LocatorWaitForOptions
25-
{
26-
State = WaitForSelectorState.Visible,
27-
Timeout = 5000
28-
});
29-
30-
// Wait for navigation to my-rooms after submitting the form
31-
// Use force: true to bypass actionability checks that may fail on Linux
32-
await Page.RunAndWaitForNavigationAsync(async () =>
33-
{
34-
await RegisterButton.ClickAsync(new LocatorClickOptions { Force = true });
35-
}, new PageRunAndWaitForNavigationOptions
36-
{
37-
UrlString = "**/my-rooms",
38-
Timeout = 30000,
39-
WaitUntil = WaitUntilState.Load // Use Load instead of NetworkIdle for better Linux compatibility
40-
});
23+
await RegisterButton.ClickAsync();
24+
await Page.WaitForURLAsync("**/my-rooms", new PageWaitForURLOptions { Timeout = 30000 });
4125
}
4226

4327
public async Task<bool> IsConfirmationMessageVisibleAsync()

ReactApp.Web/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ lerna-debug.log*
1010
node_modules
1111
dist
1212
dist-ssr
13+
dev-dist
1314
*.local
1415

1516
# Editor directories and files

ReactApp.Web/dev-dist/registerSW.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

ReactApp.Web/dev-dist/sw.js

Lines changed: 0 additions & 111 deletions
This file was deleted.

ReactApp.Web/dev-dist/sw.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)