40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { expect } from "@wdio/globals";
|
|
import LoginPage from "../pageobjects/LoginPage";
|
|
import HomePage from "../pageobjects/HomePage";
|
|
import { testConfig } from "../helpers/testConfig";
|
|
|
|
describe("Navigation", () => {
|
|
it("should redirect unauthenticated users to login", async () => {
|
|
// App should automatically redirect to login when not authenticated
|
|
await LoginPage.waitForLoginPage();
|
|
|
|
expect(await LoginPage.isOnServerStep()).toBe(true);
|
|
});
|
|
|
|
it("should prevent direct access to protected routes", async () => {
|
|
// Try to navigate to a protected route
|
|
await browser.url("http://localhost:4444/session/fake-session-id/url");
|
|
await browser.pause(1000);
|
|
|
|
// Should redirect back to login
|
|
await LoginPage.waitForLoginPage(5000);
|
|
expect(await LoginPage.isOnServerStep()).toBe(true);
|
|
});
|
|
|
|
// This test requires valid authentication - configure e2e/.env to enable
|
|
it.skip("should allow navigation after login", async () => {
|
|
// Login first
|
|
await LoginPage.fullLoginFlow(
|
|
testConfig.serverUrl,
|
|
testConfig.username,
|
|
testConfig.password
|
|
);
|
|
|
|
// Wait for home page
|
|
await HomePage.waitForHomePageLoad();
|
|
|
|
// Should be able to navigate
|
|
expect(await HomePage.hasContent()).toBe(true);
|
|
});
|
|
});
|