Skip to content
Snippets Groups Projects

CE-3625: Migrate auth components

Merged Johanna Szepanski requested to merge CE-3625-migrate-auth-components into main
4 files
+ 188
188
Compare changes
  • Side-by-side
  • Inline
Files
4
/**
/**
* Login component cypress testing
* Login component cypress testing
*/
*/
import { useState } from "react";
import { useState, ReactNode } from "react";
import { Button, Box } from "@mui/material";
import { Button, Box } from "@mui/material";
import { LoginForm, LoginDialog } from "../Login";
import { LoginForm, LoginDialog } from "../Login";
@@ -9,12 +9,16 @@ import { LoginForm, LoginDialog } from "../Login";
@@ -9,12 +9,16 @@ import { LoginForm, LoginDialog } from "../Login";
const USERNAME = "username";
const USERNAME = "username";
const PASSWORD = "password";
const PASSWORD = "password";
function LoginFormTemplate({ dialog }) {
interface LoginFormTemplateProps {
 
dialog?: ReactNode | undefined;
 
}
 
 
function LoginFormTemplate({ dialog }: LoginFormTemplateProps) {
const [loginError, setLoginError] = useState("");
const [loginError, setLoginError] = useState("");
const [loginLoading, setLoginLoading] = useState(false);
const [loginLoading, setLoginLoading] = useState(false);
const [open, setOpen] = useState(false);
const [open, setOpen] = useState(false);
const login = (username, password) => {
const login = (username: string, password: string) => {
setLoginLoading(true);
setLoginLoading(true);
if (username !== USERNAME || password !== PASSWORD) {
if (username !== USERNAME || password !== PASSWORD) {
setLoginError("Bad username/password");
setLoginError("Bad username/password");
@@ -62,15 +66,15 @@ describe("Login.spec.js", () => {
@@ -62,15 +66,15 @@ describe("Login.spec.js", () => {
it("Login should succeed", () => {
it("Login should succeed", () => {
cy.findByRole("textbox", { name: /username/i }).type("username");
cy.findByRole("textbox", { name: /username/i }).type("username");
cy.findByLabelText(/password/i).type("password");
cy.findByLabelText(/password/i).type("password");
cy.getByData("submitButton").click();
cy.get('[data-test="submitButton"]').click();
cy.getByData("progressbar").should("exist");
cy.get('[data-test="progressbar"]').should("exist");
});
});
it("Login should fail", () => {
it("Login should fail", () => {
cy.findByRole("textbox", { name: /username/i }).type("usr");
cy.findByRole("textbox", { name: /username/i }).type("usr");
cy.findByLabelText(/password/i).type("pwd");
cy.findByLabelText(/password/i).type("pwd");
cy.getByData("submitButton").click();
cy.get('[data-test="submitButton"]').click();
cy.getByData("alert").should("exist");
cy.get('[data-test="alert"]').should("exist");
});
});
});
});
@@ -80,11 +84,11 @@ describe("Login.spec.js", () => {
@@ -80,11 +84,11 @@ describe("Login.spec.js", () => {
});
});
it("Launch login dialog and login", () => {
it("Launch login dialog and login", () => {
cy.getByData("launchButton").click();
cy.get('[data-test="launchButton"]').click();
cy.findByRole("textbox", { name: /username/i }).type("username");
cy.findByRole("textbox", { name: /username/i }).type("username");
cy.findByLabelText(/password/i).type("password");
cy.findByLabelText(/password/i).type("password");
cy.get("Button[type=submit]").click();
cy.get("Button[type=submit]").click();
cy.getByData("progressbar").should("exist");
cy.get('[data-test="progressbar"]').should("exist");
});
});
});
});
});
});
Loading