diff --git a/cypress/e2e/login.cy.js b/cypress/e2e/login.cy.js index c2fbb3a..98ff26c 100644 --- a/cypress/e2e/login.cy.js +++ b/cypress/e2e/login.cy.js @@ -1,2 +1,14 @@ describe('Login Component', () => { -}) \ No newline at end of file + it('should log in successfully and show Welcome page', () => { + cy.visit('http://localhost:3000'); + + cy.get('input[name="name"]').type('arjun'); + cy.get('input[name="password"]').type('password123'); + + cy.get('form').submit(); + + // Confirm welcome page is shown + cy.contains('Welcome, arjun!').should('exist'); + }); + }); + \ No newline at end of file diff --git a/src/components/LoginForm.js b/src/components/LoginForm.js index 26c8cc3..6e7b9ce 100644 --- a/src/components/LoginForm.js +++ b/src/components/LoginForm.js @@ -15,9 +15,14 @@ function LoginForm({ onLogin }) { })); }; + const handleSubmit= (e)=>{ + e.preventDefault(); + onLogin(formData); // this triggers login and updates state in App + }; + return (