Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

Builder and Dashboard unit tests: fine tuning of assertions related to toast/notification

gianantoniopini74335a177193
diff --git a/src/pages/app/__tests__/builder.test.js b/src/pages/app/__tests__/builder.test.js
index 4615e5aa5..dea1dfc4d 100644
--- a/src/pages/app/__tests__/builder.test.js
+++ b/src/pages/app/__tests__/builder.test.js
@@ -2,6 +2,7 @@ import { navigate as mockNavigateFunction } from 'gatsby';
import React from 'react';
import {
fireEvent,
+ getByText,
render,
screen,
waitFor,
@@ -117,9 +118,13 @@ describe('Builder', () => {
);
expect(mockNavigateFunction).toHaveBeenCalledWith('/app/dashboard');
- await waitFor(() => {
- expect(screen.getByRole('alert')).toBeInTheDocument();
- });
+ const notification = await screen.findByRole('alert');
+ expect(
+ getByText(
+ notification,
+ /The resume you were looking for does not exist anymore/i,
+ ),
+ ).toBeInTheDocument();
await waitFor(() =>
expect(
diff --git a/src/pages/app/__tests__/dashboard.test.js b/src/pages/app/__tests__/dashboard.test.js
index 26b8bccc1..9a6b25231 100644
--- a/src/pages/app/__tests__/dashboard.test.js
+++ b/src/pages/app/__tests__/dashboard.test.js
@@ -1,6 +1,7 @@
import React from 'react';
import {
fireEvent,
+ getByText,
queryByText,
render,
screen,
@@ -160,9 +161,13 @@ describe('Dashboard', () => {
});
it('displays notification', async () => {
- await waitFor(() => {
- expect(screen.getByRole('alert')).toBeInTheDocument();
- });
+ const notification = await screen.findByRole('alert');
+ expect(
+ getByText(
+ notification,
+ new RegExp(`${resumeToDelete.name} was deleted successfully`, 'i'),
+ ),
+ ).toBeInTheDocument();
await waitForDatabaseRemoveToHaveCompleted();
});