Skip to content

Commit 496337e

Browse files
committed
♻️ - refactor: used factories in storybook
1 parent e9a1fd0 commit 496337e

File tree

4 files changed

+50
-50
lines changed

4 files changed

+50
-50
lines changed

frontend/src/fixtures/selectieLijstKlasseChoices.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const FIXTURE_SELECTIELIJSTKLASSE_CHOICES: Option[] = [
4646
},
4747
];
4848

49-
export const FIXTURE_SELECTIELIJSTKLASSE_CHOICES_MAP = zakenFactory().reduce(
49+
const FIXTURE_SELECTIELIJSTKLASSE_CHOICES_MAP = zakenFactory().reduce(
5050
(acc, val) => ({
5151
...acc,
5252
[val.url as string]: FIXTURE_SELECTIELIJSTKLASSE_CHOICES,
@@ -58,4 +58,4 @@ const selectieLijstKlasseFactory = createArrayFactory<Option>(
5858
FIXTURE_SELECTIELIJSTKLASSE_CHOICES,
5959
);
6060

61-
export { selectieLijstKlasseFactory };
61+
export { FIXTURE_SELECTIELIJSTKLASSE_CHOICES_MAP, selectieLijstKlasseFactory };

frontend/src/pages/destructionlist/create/DestructionListCreate.stories.tsx

+11-11
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import {
66
assertCheckboxSelection,
77
assertColumnSelection,
88
} from "../../../../.storybook/playFunctions";
9-
import { FIXTURE_PAGINATED_ZAKEN } from "../../../fixtures/paginatedZaken";
9+
import { paginatedZakenFactory } from "../../../fixtures/paginatedZaken";
1010
import {
11-
FIXTURE_BEOORDELAAR,
12-
FIXTURE_PROCES_EIGENAAR,
13-
FIXTURE_RECORD_MANAGER,
14-
FIXTURE_USERS,
11+
beoordelaarFactory,
12+
procesEigenaarFactory,
13+
recordManagerFactory,
14+
usersFactory,
1515
} from "../../../fixtures/user";
1616
import {
1717
DestructionListCreateContext,
@@ -45,8 +45,8 @@ export default meta;
4545
type Story = StoryObj<typeof meta>;
4646

4747
const FIXTURE: DestructionListCreateContext = {
48-
reviewers: FIXTURE_USERS,
49-
zaken: FIXTURE_PAGINATED_ZAKEN,
48+
reviewers: usersFactory(),
49+
zaken: paginatedZakenFactory(),
5050
selectedZaken: [],
5151
};
5252

@@ -76,7 +76,7 @@ export const DestructionListCreatePageStory: Story = {
7676
const inputName = await within(modal).findByLabelText("Naam");
7777
await userEvent.type(
7878
inputName,
79-
[FIXTURE_RECORD_MANAGER.firstName, FIXTURE_RECORD_MANAGER.lastName].join(
79+
[recordManagerFactory().firstName, recordManagerFactory().lastName].join(
8080
" ",
8181
),
8282
{ delay: 10 },
@@ -89,7 +89,7 @@ export const DestructionListCreatePageStory: Story = {
8989
const selectFirstReviewerBeoordelaarOption = await within(
9090
modal,
9191
).findAllByText(
92-
[FIXTURE_BEOORDELAAR.firstName, FIXTURE_BEOORDELAAR.lastName].join(" "),
92+
[beoordelaarFactory().firstName, beoordelaarFactory().lastName].join(" "),
9393
);
9494
await userEvent.click(selectFirstReviewerBeoordelaarOption[0], {
9595
delay: 10,
@@ -103,8 +103,8 @@ export const DestructionListCreatePageStory: Story = {
103103
modal,
104104
).findAllByText(
105105
[
106-
FIXTURE_PROCES_EIGENAAR.firstName,
107-
FIXTURE_PROCES_EIGENAAR.lastName,
106+
procesEigenaarFactory().firstName,
107+
procesEigenaarFactory().lastName,
108108
].join(" "),
109109
);
110110
await userEvent.click(selectSecondReviewerBeoordelaarOption[0], {

frontend/src/pages/destructionlist/detail/DestructionListDetail.stories.tsx

+31-31
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import {
1111
fillCheckboxConfirmationForm,
1212
fillForm,
1313
} from "../../../../.storybook/playFunctions";
14-
import { FIXTURE_DESTRUCTION_LIST } from "../../../fixtures/destructionList";
15-
import { FIXTURE_PAGINATED_ZAKEN } from "../../../fixtures/paginatedZaken";
16-
import { FIXTURE_REVIEW } from "../../../fixtures/review";
17-
import { FIXTURE_REVIEW_ITEMS } from "../../../fixtures/reviewItem";
14+
import { destructionListFactory } from "../../../fixtures/destructionList";
15+
import { paginatedZakenFactory } from "../../../fixtures/paginatedZaken";
16+
import { reviewFactory } from "../../../fixtures/review";
17+
import { reviewItemsFactory } from "../../../fixtures/reviewItem";
1818
import {
19-
FIXTURE_SELECTIELIJSTKLASSE_CHOICES,
2019
FIXTURE_SELECTIELIJSTKLASSE_CHOICES_MAP,
20+
selectieLijstKlasseFactory,
2121
} from "../../../fixtures/selectieLijstKlasseChoices";
22-
import { FIXTURE_USERS } from "../../../fixtures/user";
22+
import { usersFactory } from "../../../fixtures/user";
2323
import {
2424
clearZaakSelection,
2525
getZaakSelection,
@@ -119,12 +119,12 @@ const assertReassignDestructionList: PlayFunction<ReactRenderer> = async (
119119

120120
const FIXTURE_EDIT: DestructionListDetailContext = {
121121
storageKey: "storybook-storage-key",
122-
destructionList: FIXTURE_DESTRUCTION_LIST,
123-
reviewers: FIXTURE_USERS,
124-
archivists: FIXTURE_USERS,
125-
user: FIXTURE_USERS[0],
126-
zaken: FIXTURE_PAGINATED_ZAKEN,
127-
selectableZaken: FIXTURE_PAGINATED_ZAKEN,
122+
destructionList: destructionListFactory(),
123+
reviewers: usersFactory(),
124+
archivists: usersFactory(),
125+
user: usersFactory()[0],
126+
zaken: paginatedZakenFactory(),
127+
selectableZaken: paginatedZakenFactory(),
128128
zaakSelection: {},
129129
review: null,
130130
reviewItems: null,
@@ -160,20 +160,20 @@ export const EditDestructionList: Story = {
160160

161161
const FIXTURE_PROCESS_REVIEW: DestructionListDetailContext = {
162162
storageKey: `storybook-storage-key!${meta.title}:ProcessReview`,
163-
destructionList: { ...FIXTURE_DESTRUCTION_LIST, status: "changes_requested" },
164-
reviewers: FIXTURE_USERS,
165-
archivists: FIXTURE_USERS,
166-
user: FIXTURE_USERS[0],
163+
destructionList: { ...destructionListFactory(), status: "changes_requested" },
164+
reviewers: usersFactory(),
165+
archivists: usersFactory(),
166+
user: usersFactory()[0],
167167
zaken: {
168-
count: FIXTURE_REVIEW_ITEMS.length,
168+
count: reviewItemsFactory().length,
169169
next: null,
170170
previous: null,
171171
results: [],
172172
},
173-
selectableZaken: FIXTURE_PAGINATED_ZAKEN,
173+
selectableZaken: paginatedZakenFactory(),
174174
zaakSelection: {},
175-
review: FIXTURE_REVIEW,
176-
reviewItems: FIXTURE_REVIEW_ITEMS,
175+
review: reviewFactory(),
176+
reviewItems: reviewItemsFactory(),
177177
selectieLijstKlasseChoicesMap: FIXTURE_SELECTIELIJSTKLASSE_CHOICES_MAP,
178178
};
179179

@@ -201,7 +201,7 @@ export const ProcessReview: Story = {
201201
elementIndex: 0,
202202
formValues: {
203203
"Aanpassen van selectielijstklasse": true,
204-
Selectielijstklasse: FIXTURE_SELECTIELIJSTKLASSE_CHOICES[0].label,
204+
Selectielijstklasse: selectieLijstKlasseFactory()[0].label,
205205
Reden: "omdat het moet",
206206
},
207207
},
@@ -213,7 +213,7 @@ export const ProcessReview: Story = {
213213
elementIndex: 1,
214214
formValues: {
215215
"Aanpassen van selectielijstklasse": true,
216-
Selectielijstklasse: FIXTURE_SELECTIELIJSTKLASSE_CHOICES[1].label,
216+
Selectielijstklasse: selectieLijstKlasseFactory()[1].label,
217217
Reden: "omdat het kan",
218218
},
219219
},
@@ -225,7 +225,7 @@ export const ProcessReview: Story = {
225225
elementIndex: 2,
226226
formValues: {
227227
"Aanpassen van selectielijstklasse": true,
228-
Selectielijstklasse: FIXTURE_SELECTIELIJSTKLASSE_CHOICES[2].label,
228+
Selectielijstklasse: selectieLijstKlasseFactory()[2].label,
229229
Reden: "Waarom niet",
230230
},
231231
},
@@ -268,22 +268,22 @@ export const ProcessReview: Story = {
268268
const FIXTURE_FINAL_DESTRUCTION: DestructionListDetailContext = {
269269
storageKey: `storybook-storage-key!${meta.title}:FinalDestruction`,
270270
destructionList: {
271-
...FIXTURE_DESTRUCTION_LIST,
271+
...destructionListFactory(),
272272
status: "internally_reviewed",
273273
},
274-
reviewers: FIXTURE_USERS,
275-
archivists: FIXTURE_USERS,
276-
user: FIXTURE_USERS[0],
274+
reviewers: usersFactory(),
275+
archivists: usersFactory(),
276+
user: usersFactory()[0],
277277
zaken: {
278-
count: FIXTURE_REVIEW_ITEMS.length,
278+
count: reviewItemsFactory().length,
279279
next: null,
280280
previous: null,
281281
results: [],
282282
},
283-
selectableZaken: FIXTURE_PAGINATED_ZAKEN,
283+
selectableZaken: paginatedZakenFactory(),
284284
zaakSelection: {},
285-
review: FIXTURE_REVIEW,
286-
reviewItems: FIXTURE_REVIEW_ITEMS,
285+
review: reviewFactory(),
286+
reviewItems: reviewItemsFactory(),
287287
selectieLijstKlasseChoicesMap: FIXTURE_SELECTIELIJSTKLASSE_CHOICES_MAP,
288288
};
289289

frontend/src/pages/destructionlist/review/DestructionListReview.stories.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import type { Meta, StoryObj } from "@storybook/react";
22

33
import { ReactRouterDecorator } from "../../../../.storybook/decorators";
44
import { assertColumnSelection } from "../../../../.storybook/playFunctions";
5-
import { FIXTURE_DESTRUCTION_LIST } from "../../../fixtures/destructionList";
6-
import { FIXTURE_PAGINATED_ZAKEN } from "../../../fixtures/paginatedZaken";
7-
import { FIXTURE_USERS } from "../../../fixtures/user";
5+
import { destructionListFactory } from "../../../fixtures/destructionList";
6+
import { paginatedZakenFactory } from "../../../fixtures/paginatedZaken";
7+
import { usersFactory } from "../../../fixtures/user";
88
import { DestructionListReviewPage } from "./DestructionListReview";
99
import { DestructionListReviewContext } from "./DestructionListReview.loader";
1010

@@ -35,11 +35,11 @@ export default meta;
3535
type Story = StoryObj<typeof meta>;
3636

3737
const FIXTURE: DestructionListReviewContext = {
38-
reviewers: FIXTURE_USERS,
39-
zaken: FIXTURE_PAGINATED_ZAKEN,
38+
reviewers: usersFactory(),
39+
zaken: paginatedZakenFactory(),
4040
selectedZaken: [],
4141
uuid: "00000000-0000-0000-0000-000000000000",
42-
destructionList: FIXTURE_DESTRUCTION_LIST,
42+
destructionList: destructionListFactory(),
4343
};
4444

4545
export const ReviewDestructionList: Story = {

0 commit comments

Comments
 (0)