+ {loginSuccess ? (
+
+
+ Hello {username}!
+
+
+ Your account was created on {new Date(createdAt).toLocaleDateString()}.
+
+
+ ) : (
+
+
+ Login
+
+ setUsername(e.target.value)}
+ />
+ setPassword(e.target.value)}
+ />
+
+
+ {error && (
+ setError('')} message={`Error: ${error}`} />
+ )}
+
+ )}
+
+ );
+};
+
+export default Login;
diff --git a/webapp/src/components/Login.test.js b/webapp/src/components/Login.test.js
new file mode 100644
index 00000000..af102dcf
--- /dev/null
+++ b/webapp/src/components/Login.test.js
@@ -0,0 +1,62 @@
+import React from 'react';
+import { render, fireEvent, screen, waitFor, act } from '@testing-library/react';
+import axios from 'axios';
+import MockAdapter from 'axios-mock-adapter';
+import Login from './Login';
+
+const mockAxios = new MockAdapter(axios);
+
+describe('Login component', () => {
+ beforeEach(() => {
+ mockAxios.reset();
+ });
+
+ it('should log in successfully', async () => {
+ render(