From db8ff22eaa8e1d28e5c8ba7e55dbb6310c3a64e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fern=C3=A1ndez=20Noriega?= Date: Thu, 25 Apr 2024 17:13:29 +0200 Subject: [PATCH] AddUser test now includes error snackbar --- gatewayservice/gateway-service.test.js | 2 +- webapp/src/components/AddUser.test.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gatewayservice/gateway-service.test.js b/gatewayservice/gateway-service.test.js index 26a1cf8..9a1ba0c 100644 --- a/gatewayservice/gateway-service.test.js +++ b/gatewayservice/gateway-service.test.js @@ -283,7 +283,7 @@ it('should forward get Foods request to question service', async () => { }); // Test /ranking/user - it('should inform that the health is OK if the service is operative', async () => { + it('should respond with the ranking info of the given user', async () => { // Send POST request to gateway endpoint const response = await request(app) diff --git a/webapp/src/components/AddUser.test.js b/webapp/src/components/AddUser.test.js index e6e6817..1c82124 100644 --- a/webapp/src/components/AddUser.test.js +++ b/webapp/src/components/AddUser.test.js @@ -1,5 +1,5 @@ import React from 'react'; -import { fireEvent, screen, waitFor } from '@testing-library/react'; +import { fireEvent, act, screen, waitFor } from '@testing-library/react'; import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import AddUser from './AddUser'; @@ -108,5 +108,15 @@ describe('AddUser component', () => { await waitFor(() => { expect(screen.getByText("Error: Passwords do not match")).toBeInTheDocument(); }); + + //Close the snackbar by clicking outside + await act(async ()=>{ + fireEvent.click(screen.getAllByText("Username")[1]) + }) + + //Snackbar has to have been closed + await waitFor(() => { + expect(screen.queryByText("Error: Passwords do not match")).not.toBeInTheDocument(); + }); }); });