Skip to content

Commit c2ae867

Browse files
authored
Modified testimonial (#451)
1 parent 64af47e commit c2ae867

19 files changed

+1820
-488
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"dev": "webpack server",
88
"build": "webpack",
9-
"test": "npm run update-snapshots && npx jest ",
9+
"test": "npm run update-snapshots && npx jest --runInBand",
1010
"update-snapshots": "jest --updateSnapshot",
1111
"coverage": "jest --collect-coverage --silent -u",
1212
"lint": "npx eslint src/**/*.{tsx,ts} --fix",

src/components/tests/__snapshots__/AdminTraineeDashboard.test.tsx.snap

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Array [
2828
>
2929
<form
3030
className="px-8 py-3 "
31+
onSubmit={[Function]}
3132
>
3233
<div
3334
className="flex flex-wrap items-center justify-center w-full card-title "
@@ -48,6 +49,7 @@ Array [
4849
className="w-full px-5 py-2 font-sans text-xs text-black border rounded outline-none dark:bg-dark-tertiary border-primary"
4950
name="email"
5051
onChange={[Function]}
52+
onSubmit={[Function]}
5153
placeholder="email"
5254
type="email"
5355
value=""
@@ -461,7 +463,7 @@ Array [
461463
name="date"
462464
readOnly={true}
463465
type="text"
464-
value="2024-03-26"
466+
value="2024-09-03"
465467
/>
466468
</div>
467469
<div
@@ -890,7 +892,6 @@ Array [
890892
onClick={[Function]}
891893
type="button"
892894
>
893-
894895
add
895896
+
896897

src/components/tests/__snapshots__/Header.test.tsx.snap

+12-12
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ exports[`Header Tests Should render the header with home 1`] = `
9191
>
9292
<a
9393
className=""
94-
href="/docs/org-signin"
94+
href="/docs/getting-started"
9595
onClick={[Function]}
9696
>
9797
Docs
@@ -234,7 +234,7 @@ exports[`Header Tests Should render the header with home 1`] = `
234234
className="p-2 w-full mt-2 dark:text-dark-text-fill text-primary"
235235
>
236236
<a
237-
href="/docs/org-signin"
237+
href="/docs/getting-started"
238238
onClick={[Function]}
239239
>
240240
Docs
@@ -360,7 +360,7 @@ exports[`Header Tests Should render the header with no active 1`] = `
360360
>
361361
<a
362362
className=""
363-
href="/docs/org-signin"
363+
href="/docs/getting-started"
364364
onClick={[Function]}
365365
>
366366
Docs
@@ -503,7 +503,7 @@ exports[`Header Tests Should render the header with no active 1`] = `
503503
className="p-2 w-full mt-2 dark:text-dark-text-fill text-primary"
504504
>
505505
<a
506-
href="/docs/org-signin"
506+
href="/docs/getting-started"
507507
onClick={[Function]}
508508
>
509509
Docs
@@ -619,7 +619,7 @@ exports[`Header Tests Should render the header with no active 2`] = `
619619
>
620620
<a
621621
className=""
622-
href="/docs/org-signin"
622+
href="/docs/getting-started"
623623
onClick={[Function]}
624624
>
625625
Docs
@@ -749,7 +749,7 @@ exports[`Header Tests Should render the header with no active 2`] = `
749749
className="p-2 w-full mt-2 dark:text-dark-text-fill text-primary"
750750
>
751751
<a
752-
href="/docs/org-signin"
752+
href="/docs/getting-started"
753753
onClick={[Function]}
754754
>
755755
Docs
@@ -870,7 +870,7 @@ exports[`Header Tests Should render the header with no active 3`] = `
870870
>
871871
<a
872872
className=""
873-
href="/docs/org-signin"
873+
href="/docs/getting-started"
874874
onClick={[Function]}
875875
>
876876
Docs
@@ -1013,7 +1013,7 @@ exports[`Header Tests Should render the header with no active 3`] = `
10131013
className="p-2 w-full mt-2 dark:text-dark-text-fill text-primary"
10141014
>
10151015
<a
1016-
href="/docs/org-signin"
1016+
href="/docs/getting-started"
10171017
onClick={[Function]}
10181018
>
10191019
Docs
@@ -1140,7 +1140,7 @@ exports[`Header Tests Should render the header with pricing active 1`] = `
11401140
>
11411141
<a
11421142
className=""
1143-
href="/docs/org-signin"
1143+
href="/docs/getting-started"
11441144
onClick={[Function]}
11451145
>
11461146
Docs
@@ -1283,7 +1283,7 @@ exports[`Header Tests Should render the header with pricing active 1`] = `
12831283
className="p-2 w-full mt-2 dark:text-dark-text-fill text-primary"
12841284
>
12851285
<a
1286-
href="/docs/org-signin"
1286+
href="/docs/getting-started"
12871287
onClick={[Function]}
12881288
>
12891289
Docs
@@ -1409,7 +1409,7 @@ exports[`Header Tests Should render the header with product active 1`] = `
14091409
>
14101410
<a
14111411
className=""
1412-
href="/docs/org-signin"
1412+
href="/docs/getting-started"
14131413
onClick={[Function]}
14141414
>
14151415
Docs
@@ -1552,7 +1552,7 @@ exports[`Header Tests Should render the header with product active 1`] = `
15521552
className="p-2 w-full mt-2 dark:text-dark-text-fill text-primary"
15531553
>
15541554
<a
1555-
href="/docs/org-signin"
1555+
href="/docs/getting-started"
15561556
onClick={[Function]}
15571557
>
15581558
Docs

src/containers/admin-dashBoard/Sessions.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ function AdminSission() {
327327

328328
{/* =========================== Start:: delete Session Model =============================== */}
329329
<div
330+
data-testid="delete-section"
330331
className={`min-h-full w-screen z-30 bg-black bg-opacity-30 backdrop-blur-sm absolute flex items-center justify-center px-4 ${
331332
deleteSessionModel === true ? 'block' : 'hidden'
332333
}`}
@@ -372,7 +373,7 @@ function AdminSission() {
372373

373374
{/* =========================== Start:: update Session Model =============================== */}
374375
{updateTraineeModel && sessionToEdit && (
375-
<div className="min-h-full w-screen z-30 bg-black bg-opacity-30 backdrop-blur-sm absolute flex items-center justify-center px-4">
376+
<div data-testid="update-section" className="min-h-full w-screen z-30 bg-black bg-opacity-30 backdrop-blur-sm absolute flex items-center justify-center px-4">
376377
<div className="bg-white dark:bg-dark-bg w-full sm:w-3/4 md:w-1/2 xl:w-4/12 rounded-lg p-4 pb-8">
377378
<div className="card-title w-full flex flex-wrap justify-center items-center">
378379
<h3 className="font-bold text-sm text-gray-700 dark:text-white text-center w-11/12">
@@ -385,6 +386,7 @@ function AdminSission() {
385386
<div className="input my-3 h-9">
386387
<div className="grouped-input flex items-center h-full w-full rounded-md">
387388
<input
389+
data-testid="session-name"
388390
type="text"
389391
name="Sessionname"
390392
placeholder={sessionToEdit.Sessionname}
@@ -396,6 +398,7 @@ function AdminSission() {
396398
<div className="input my-3 h-9">
397399
<div className="grouped-input flex items-center h-full w-full rounded-md">
398400
<input
401+
data-testid="description"
399402
type="text"
400403
name="description"
401404
placeholder={sessionToEdit.description}
@@ -447,6 +450,7 @@ function AdminSission() {
447450
{t('Cancel')}
448451
</Button>
449452
<Button
453+
data-testid="save"
450454
variant="primary"
451455
size="sm"
452456
style="w-[30%] md:w-1/4 text-sm font-sans"

src/containers/admin-dashBoard/tests/Sessions.test.tsx

+28-23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
3-
import '@testing-library/jest-dom/extend-expect';
3+
import '@testing-library/jest-dom';
44
import { MockedProvider } from '@apollo/client/testing';
55
import { act } from 'react-dom/test-utils';
66
import AdminSission from '../Sessions';
@@ -53,8 +53,8 @@ describe('AdminSission Component', () => {
5353
);
5454

5555
await waitFor(() => {
56-
// expect(screen.getByText('Test Session 1')).toBeInTheDocument();
57-
// expect(screen.getByText('Test Session 2')).toBeInTheDocument();
56+
expect(screen.getByText('Test Session 1')).toBeInTheDocument();
57+
expect(screen.getByText('Test Session 2')).toBeInTheDocument();
5858
});
5959
});
6060

@@ -67,7 +67,7 @@ describe('AdminSission Component', () => {
6767

6868
await waitFor(() => {
6969
fireEvent.click(screen.getByText('register +'));
70-
// expect(screen.getByText('AddSession')).toBeInTheDocument();
70+
expect(screen.getByText('AddSession')).toBeInTheDocument();
7171
});
7272
});
7373

@@ -95,13 +95,16 @@ describe('AdminSission Component', () => {
9595
</MockedProvider>,
9696
);
9797

98-
// await waitFor(() => {
99-
// fireEvent.click(screen.getByTestId('deleteIcon'));
100-
// // expect(screen.getByText('reallydeleteSession')).toBeInTheDocument();
98+
await waitFor(async () => {
99+
fireEvent.click(screen.getAllByTestId('deleteIcon')[0]);
100+
expect(screen.getByTestId('delete-section')).toBeInTheDocument();
101+
expect(screen.getByTestId('delete-section')).toHaveClass("block");
101102

102-
// fireEvent.click(screen.getByText('Delete'));
103-
// expect(screen.queryByText('reallydeleteSession')).toBeNull();
104-
// });
103+
fireEvent.click(screen.getByTestId('delete'));
104+
await waitFor(()=>{
105+
expect(screen.queryByTestId('delete-section')).toHaveClass("hidden");
106+
})
107+
});
105108
});
106109

107110
it('updates a session when the edit icon is clicked and saved', async () => {
@@ -135,20 +138,22 @@ describe('AdminSission Component', () => {
135138
</MockedProvider>,
136139
);
137140

138-
// await waitFor(() => {
139-
// fireEvent.click(screen.getByTestId('updateIcon'));
140-
// // expect(screen.getByText('UpdateSession')).toBeInTheDocument();
141+
await waitFor(async() => {
142+
fireEvent.click(screen.getAllByTestId('updateIcon')[0]);
143+
expect(screen.getByTestId('update-section')).toBeInTheDocument();
141144

142-
// // Simulate updating session details
143-
// fireEvent.change(screen.getByLabelText('Sessionname'), {
144-
// target: { value: 'Updated Session Name' },
145-
// });
146-
// fireEvent.change(screen.getByLabelText('description'), {
147-
// target: { value: 'Updated Description' },
148-
// });
145+
// Simulate updating session details
146+
fireEvent.change(screen.getByTestId('session-name'), {
147+
target: { value: 'Updated Session Name' },
148+
});
149+
fireEvent.change(screen.getByTestId('description'), {
150+
target: { value: 'Updated Description' },
151+
});
149152

150-
// fireEvent.click(screen.getByText('Save'));
151-
// expect(screen.queryByText('UpdateSession')).toBeNull();
152-
// });
153+
fireEvent.click(screen.getByTestId('save'));
154+
await waitFor(()=>{
155+
expect(screen.queryByText('update-section')).toBeNull();
156+
})
157+
});
153158
});
154159
});

0 commit comments

Comments
 (0)