Skip to content

Commit 242008d

Browse files
committed
fix tests and display teams when cohort is selected
1 parent ebe5758 commit 242008d

8 files changed

+78
-301
lines changed

src/components/BulkRatingModal.tsx

+3-13
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ const BulkRatingModal = ({ setBulkRateModal }: {setBulkRateModal: React.Dispatch
256256
</button>
257257
</div>
258258
{
259-
formData.cohortId ?
259+
teams ?
260260
<>
261261
<hr className="mt-5 border-b" />
262262
<div className="flex flex-col gap-3 p-3 rounded-md text-sm bg-neutral-700">
@@ -265,19 +265,9 @@ const BulkRatingModal = ({ setBulkRateModal }: {setBulkRateModal: React.Dispatch
265265
<select data-testid="select-team" className="p-1 text-sm text-black dark:text-white rounded-lg bg-white dark:bg-dark border-2 border-primary" defaultValue={""} onChange={(e) => setSelectedTeam(e.target.value)}>
266266
<option data-testid="team-default-option">Choose a team</option>
267267
{
268-
teams && teams.getTeamsByCohort.length > 0 ?
268+
teams.getTeamsByCohort.length > 0 ?
269269
teams.getTeamsByCohort.map((team: any) => <option data-testid={`team-option-${team.id}`} key={team.id} value={team.id}>{team.name}</option>)
270-
: ''
271-
}
272-
{
273-
loadingTeams ?
274-
<option data-testid="team-loading-option">Loading...</option>
275-
: ''
276-
}
277-
{
278-
teamsError ?
279-
<option data-testid="team-error-option">No teams found...</option>
280-
: ''
270+
: <option data-testid="team-empty-option" value="">No teams found...</option>
281271
}
282272
</select>
283273
<button data-testid="download-button" type="button" onClick={downloadTeamFile} className="py-1 px-2 text-white rounded-lg bg-green-700 text-sm font-serif font-semibold">Download</button>

tests/components/BulkRatingModal.test.tsx

+12-8
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ afterEach(() => {
191191
})
192192

193193
describe("BulkRatingModal", () => {
194-
const setBulkRateModel = jest.fn()
194+
const setBulkRateModal: React.Dispatch<React.SetStateAction<boolean>> = jest.fn()
195195
it("displays all cohorts", async() => {
196196
render(
197197
<MockedProvider mocks={[getUserCohorts, getRatingsByCohort, getTeamsByCohort]} addTypename={false}>
198198
<BulkRatingModal
199-
setBulkRateModal={setBulkRateModel}
199+
setBulkRateModal={setBulkRateModal}
200200
></BulkRatingModal>
201201
</MockedProvider>
202202
)
@@ -209,7 +209,7 @@ describe("BulkRatingModal", () => {
209209
render(
210210
<MockedProvider mocks={[getUserCohorts, getRatingsByCohort, getTeamsByCohort]} addTypename={false}>
211211
<BulkRatingModal
212-
setBulkRateModal={setBulkRateModel}
212+
setBulkRateModal={setBulkRateModal}
213213
></BulkRatingModal>
214214
</MockedProvider>
215215
)
@@ -228,7 +228,7 @@ describe("BulkRatingModal", () => {
228228
render(
229229
<MockedProvider mocks={[getUserCohorts, getRatingsByCohort, getTeamsByCohort]} addTypename={false}>
230230
<BulkRatingModal
231-
setBulkRateModal={setBulkRateModel}
231+
setBulkRateModal={setBulkRateModal}
232232
></BulkRatingModal>
233233
</MockedProvider>
234234
)
@@ -248,7 +248,7 @@ describe("BulkRatingModal", () => {
248248
render(
249249
<MockedProvider mocks={[getUserCohorts, getRatingsByCohort, getTeamsByCohort, addRatingsByFile]} addTypename={false}>
250250
<BulkRatingModal
251-
setBulkRateModal={setBulkRateModel}
251+
setBulkRateModal={setBulkRateModal}
252252
></BulkRatingModal>
253253
</MockedProvider>
254254
)
@@ -281,19 +281,23 @@ describe("BulkRatingModal", () => {
281281
render(
282282
<MockedProvider mocks={[getUserCohorts, getRatingsByCohort, getTeamsByCohort, addRatingsByFile]} addTypename={false}>
283283
<BulkRatingModal
284-
setBulkRateModal={setBulkRateModel}
284+
setBulkRateModal={setBulkRateModal}
285285
></BulkRatingModal>
286286
</MockedProvider>
287287
)
288288
const cohortInput = screen.getByTestId("select-cohort")
289-
const teamInput = screen.getByTestId("select-team")
290-
const downloadButton = screen.getByTestId("download-button")
291289
await waitFor(()=>{
292290
fireEvent.change(cohortInput, {
293291
target: {
294292
value: "1"
295293
}
296294
})
295+
const teamInput=screen.getByTestId("select-team")
296+
const downloadButton=screen.getByTestId("download-button")
297+
expect(teamInput).toBeInTheDocument()
298+
expect(downloadButton).toBeInTheDocument()
299+
expect(screen.getByTestId("team-option-1")).toBeInTheDocument()
300+
expect(screen.getByTestId("team-option-2")).toBeInTheDocument()
297301
fireEvent.change(teamInput, {
298302
target: {
299303
value: "1"

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

+1-112
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ Array [
463463
name="date"
464464
readOnly={true}
465465
type="text"
466-
value="2024-11-19"
466+
value="2024-11-21"
467467
/>
468468
</div>
469469
<div
@@ -925,117 +925,6 @@ Array [
925925
</div>
926926
</div>
927927
</div>,
928-
<div
929-
className="hidden h-screen w-screen z-20 bg-black bg-opacity-30 backdrop-blur-sm fixed top-0 left-0 flex items-center justify-center px-4"
930-
>
931-
<div
932-
className="w-full p-4 pb-8 bg-indigo-100 rounded-lg dark:bg-dark-bg sm:w-3/4 xl:w-4/12"
933-
>
934-
<div
935-
className="flex flex-wrap items-center justify-center w-full card-title"
936-
>
937-
<h3
938-
className="w-11/12 text-sm font-bold text-center dark:text-white"
939-
>
940-
Bulk Rating
941-
</h3>
942-
<hr
943-
className="w-full my-3 border-b bg-primary"
944-
/>
945-
</div>
946-
<div>
947-
<form
948-
className="flex flex-col gap-5"
949-
data-testid="bulk-rating-form"
950-
onSubmit={[Function]}
951-
>
952-
<div
953-
className="flex flex-col gap-1"
954-
>
955-
<label>
956-
Choose a cohort
957-
</label>
958-
<select
959-
className="p-2 text-black dark:text-white rounded-lg bg-white dark:bg-dark border-2 border-primary"
960-
data-testid="select-cohort"
961-
defaultValue=""
962-
onChange={[Function]}
963-
>
964-
<option>
965-
Choose a cohort
966-
</option>
967-
</select>
968-
<label>
969-
Choose a sprint
970-
</label>
971-
<select
972-
className="p-2 text-black dark:text-white rounded-lg bg-white dark:bg-dark border-2 border-primary"
973-
data-testid="select-sprint"
974-
defaultValue=""
975-
onChange={[Function]}
976-
>
977-
<option>
978-
Choose a sprint
979-
</option>
980-
</select>
981-
</div>
982-
<div
983-
className="flex items-center justify-between"
984-
>
985-
<input
986-
accept=".xlsx, .xls"
987-
className="w-1/2 h-full bg-gray-600 rounded-md"
988-
data-testid="file-input"
989-
onChange={[Function]}
990-
type="file"
991-
/>
992-
<div
993-
className="flex gap-2"
994-
>
995-
<select
996-
className="p-2 text-sm text-black dark:text-white rounded-lg bg-white dark:bg-dark border-2 border-primary"
997-
data-testid="select-team"
998-
defaultValue=""
999-
onChange={[Function]}
1000-
>
1001-
<option
1002-
data-testid="team-default-option"
1003-
>
1004-
Choose a team
1005-
</option>
1006-
</select>
1007-
<button
1008-
className="p-3 text-white rounded-lg bg-green-500 text-sm font-serif font-semibold"
1009-
data-testid="download-button"
1010-
onClick={[Function]}
1011-
type="button"
1012-
>
1013-
Download
1014-
</button>
1015-
</div>
1016-
</div>
1017-
<div />
1018-
<div
1019-
className="flex justify-between w-full"
1020-
>
1021-
<button
1022-
className="w-[40%] md:w-1/4 p-3 text-white rounded-lg bg-primary text-sm font-serif font-semibold"
1023-
onClick={[Function]}
1024-
type="button"
1025-
>
1026-
Cancel
1027-
</button>
1028-
<button
1029-
className="w-[40%] md:w-1/4 p-3 text-white rounded-lg bg-primary text-sm font-serif font-semibold"
1030-
type="submit"
1031-
>
1032-
Save
1033-
</button>
1034-
</div>
1035-
</form>
1036-
</div>
1037-
</div>
1038-
</div>,
1039928
<div
1040929
className="flex flex-col"
1041930
>

tests/pages/__snapshots__/AdminTraineeDashboard.test.tsx.snap

+1-112
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ Array [
463463
name="date"
464464
readOnly={true}
465465
type="text"
466-
value="2024-11-19"
466+
value="2024-11-21"
467467
/>
468468
</div>
469469
<div
@@ -925,117 +925,6 @@ Array [
925925
</div>
926926
</div>
927927
</div>,
928-
<div
929-
className="hidden h-screen w-screen z-20 bg-black bg-opacity-30 backdrop-blur-sm fixed top-0 left-0 flex items-center justify-center px-4"
930-
>
931-
<div
932-
className="w-full p-4 pb-8 bg-indigo-100 rounded-lg dark:bg-dark-bg sm:w-3/4 xl:w-4/12"
933-
>
934-
<div
935-
className="flex flex-wrap items-center justify-center w-full card-title"
936-
>
937-
<h3
938-
className="w-11/12 text-sm font-bold text-center dark:text-white"
939-
>
940-
Bulk Rating
941-
</h3>
942-
<hr
943-
className="w-full my-3 border-b bg-primary"
944-
/>
945-
</div>
946-
<div>
947-
<form
948-
className="flex flex-col gap-5"
949-
data-testid="bulk-rating-form"
950-
onSubmit={[Function]}
951-
>
952-
<div
953-
className="flex flex-col gap-1"
954-
>
955-
<label>
956-
Choose a cohort
957-
</label>
958-
<select
959-
className="p-2 text-black dark:text-white rounded-lg bg-white dark:bg-dark border-2 border-primary"
960-
data-testid="select-cohort"
961-
defaultValue=""
962-
onChange={[Function]}
963-
>
964-
<option>
965-
Choose a cohort
966-
</option>
967-
</select>
968-
<label>
969-
Choose a sprint
970-
</label>
971-
<select
972-
className="p-2 text-black dark:text-white rounded-lg bg-white dark:bg-dark border-2 border-primary"
973-
data-testid="select-sprint"
974-
defaultValue=""
975-
onChange={[Function]}
976-
>
977-
<option>
978-
Choose a sprint
979-
</option>
980-
</select>
981-
</div>
982-
<div
983-
className="flex items-center justify-between"
984-
>
985-
<input
986-
accept=".xlsx, .xls"
987-
className="w-1/2 h-full bg-gray-600 rounded-md"
988-
data-testid="file-input"
989-
onChange={[Function]}
990-
type="file"
991-
/>
992-
<div
993-
className="flex gap-2"
994-
>
995-
<select
996-
className="p-2 text-sm text-black dark:text-white rounded-lg bg-white dark:bg-dark border-2 border-primary"
997-
data-testid="select-team"
998-
defaultValue=""
999-
onChange={[Function]}
1000-
>
1001-
<option
1002-
data-testid="team-default-option"
1003-
>
1004-
Choose a team
1005-
</option>
1006-
</select>
1007-
<button
1008-
className="p-3 text-white rounded-lg bg-green-500 text-sm font-serif font-semibold"
1009-
data-testid="download-button"
1010-
onClick={[Function]}
1011-
type="button"
1012-
>
1013-
Download
1014-
</button>
1015-
</div>
1016-
</div>
1017-
<div />
1018-
<div
1019-
className="flex justify-between w-full"
1020-
>
1021-
<button
1022-
className="w-[40%] md:w-1/4 p-3 text-white rounded-lg bg-primary text-sm font-serif font-semibold"
1023-
onClick={[Function]}
1024-
type="button"
1025-
>
1026-
Cancel
1027-
</button>
1028-
<button
1029-
className="w-[40%] md:w-1/4 p-3 text-white rounded-lg bg-primary text-sm font-serif font-semibold"
1030-
type="submit"
1031-
>
1032-
Save
1033-
</button>
1034-
</div>
1035-
</form>
1036-
</div>
1037-
</div>
1038-
</div>,
1039928
<div
1040929
className="flex flex-col"
1041930
>

0 commit comments

Comments
 (0)