95 lines
2.9 KiB
JavaScript
95 lines
2.9 KiB
JavaScript
// The Lucia project.
|
|
// Copyright 2026-2026 DSP, inc. All rights reserved.
|
|
// Authors:
|
|
// imacat.yang@dsp.im (imacat), 2026/03/05
|
|
|
|
import { loginWithFixtures } from "../support/intercept";
|
|
|
|
describe("Edge Cases", () => {
|
|
describe("Empty states", () => {
|
|
it("files page handles empty file list", () => {
|
|
loginWithFixtures();
|
|
// Override files intercept with empty array
|
|
cy.intercept("GET", "/api/files", {
|
|
statusCode: 200,
|
|
body: [],
|
|
}).as("getEmptyFiles");
|
|
cy.visit("/files");
|
|
cy.wait("@getEmptyFiles");
|
|
// Table should exist but have no file data
|
|
cy.get("table").should("exist");
|
|
cy.contains("sample-process.xes").should("not.exist");
|
|
});
|
|
|
|
it("account admin handles empty user list", () => {
|
|
loginWithFixtures();
|
|
cy.intercept("GET", "/api/users", {
|
|
statusCode: 200,
|
|
body: [],
|
|
}).as("getEmptyUsers");
|
|
cy.visit("/account-admin");
|
|
cy.wait("@getEmptyUsers");
|
|
// Create New button should still work
|
|
cy.get("#create_new_acct_btn").should("exist");
|
|
});
|
|
});
|
|
|
|
describe("Authentication guard", () => {
|
|
it("unauthenticated user is redirected to login", () => {
|
|
// No loginWithFixtures - not logged in
|
|
cy.visit("/files");
|
|
cy.url().should("include", "/login");
|
|
});
|
|
|
|
it("unauthenticated user cannot access account-admin", () => {
|
|
cy.visit("/account-admin");
|
|
cy.url().should("include", "/login");
|
|
});
|
|
|
|
it("unauthenticated user cannot access my-account", () => {
|
|
cy.visit("/my-account");
|
|
cy.url().should("include", "/login");
|
|
});
|
|
});
|
|
|
|
describe("Login validation", () => {
|
|
it("shows error on failed login", () => {
|
|
cy.intercept("POST", "/api/oauth/token", {
|
|
statusCode: 401,
|
|
body: { detail: "Invalid credentials" },
|
|
}).as("failedLogin");
|
|
cy.visit("/login");
|
|
cy.get("#account").type("wrong");
|
|
cy.get("#password").type("wrong");
|
|
cy.get("form").submit();
|
|
cy.wait("@failedLogin");
|
|
// Should stay on login page
|
|
cy.url().should("include", "/login");
|
|
});
|
|
});
|
|
|
|
describe("Account creation validation", () => {
|
|
beforeEach(() => {
|
|
loginWithFixtures();
|
|
cy.visit("/account-admin");
|
|
cy.wait("@getUsers");
|
|
cy.get("#create_new_acct_btn").click();
|
|
});
|
|
|
|
it("confirm stays disabled with only account field filled", () => {
|
|
cy.get("#input_account_field").type("newuser");
|
|
cy.get(".confirm-btn").should("be.disabled");
|
|
});
|
|
|
|
it("confirm stays disabled with only name field filled", () => {
|
|
cy.get("#input_name_field").type("New User");
|
|
cy.get(".confirm-btn").should("be.disabled");
|
|
});
|
|
|
|
it("confirm stays disabled with only password field filled", () => {
|
|
cy.get("#input_first_pwd").type("password1234");
|
|
cy.get(".confirm-btn").should("be.disabled");
|
|
});
|
|
});
|
|
});
|