-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
// SPDX-FileCopyrightText: 2024 Shota FUJI <pockawoooh@gmail.com>
// SPDX-License-Identifier: AGPL-3.0-only
import { create } from "@bufbuild/protobuf";
import { WorkspaceSchema } from "@yamori/proto/yamori/workspace/v1/workspace_pb.js";
import type { Meta, StoryObj } from "@storybook/react";
import { withMockedBackend } from "../../../../.storybook/decorators/withMockedBackend.tsx";
import { withInmemoryRouter } from "../../../../.storybook/decorators/withInmemoryRouter.tsx";
import {
Get,
DeleteLeaveDefinition,
} from "../../../mocks/yamori/workspace/v1/workspace_service.ts";
import { Page } from "./page.tsx";
const workspace = create(WorkspaceSchema, {
id: { value: "ws-foo" },
});
const success = create(WorkspaceSchema, {
leaveDefinitions: [
{
id: { value: "lv-foo" },
displayName: "なにかの休業",
isWorkerDeemedToBeWorked: true,
updateKey: { key: new Uint8Array([]) },
deletionKey: { key: new Uint8Array([]) },
currentRevision: {
revisionId: { value: "lr-bar" },
startAt: { year: 2000, month: 1, day: 2 },
snapshot: { isWorkerDeemedToBeWorked: true },
},
revisions: [
{
revisionId: { value: "lr-foo" },
startAt: { year: 1999, month: 4, day: 1 },
snapshot: { isWorkerDeemedToBeWorked: false },
},
{
revisionId: { value: "lr-bar" },
startAt: { year: 2000, month: 1, day: 2 },
snapshot: { isWorkerDeemedToBeWorked: true },
},
{
revisionId: { value: "lr-baz" },
startAt: { year: 3000, month: 9, day: 9 },
snapshot: { isWorkerDeemedToBeWorked: false },
},
],
},
{
id: { value: "lv-bar" },
displayName: "なにかの休暇",
isWorkerDeemedToBeWorked: false,
currentRevision: {
revisionId: { value: "lr-qux" },
startAt: { year: 2020, month: 2, day: 29 },
snapshot: { isWorkerDeemedToBeWorked: false },
},
revisions: [
{
revisionId: { value: "lr-qux" },
startAt: { year: 2020, month: 2, day: 29 },
snapshot: { isWorkerDeemedToBeWorked: false },
},
],
},
],
});
export default {
component: Page,
parameters: {
layout: "fullscreen",
},
args: {
workspace,
},
decorators: [
withInmemoryRouter({ initialURL: "/ws-foo/leave-definitions" }),
withMockedBackend([
Get({
workspace: success,
}),
DeleteLeaveDefinition(),
]),
],
} satisfies Meta<typeof Page>;
type Story = StoryObj<typeof Page>;
export const Success: Story = {};
export const SlowLoad: Story = {
decorators: [
withMockedBackend([
Get({
workspace: success,
delayMs: 3_000,
}),
DeleteLeaveDefinition({
delayMs: 1_000,
}),
]),
],
};
export const NoDefinitions: Story = {
decorators: [
withMockedBackend([
Get({
workspace: {},
}),
DeleteLeaveDefinition(),
]),
],
};
export const LoadError: Story = {
decorators: [
withMockedBackend([
Get({
workspace: success,
failureRate: 1,
}),
]),
],
};
export const Flaky: Story = {
decorators: [
withMockedBackend([
Get({
workspace: success,
failureRate: 0.5,
}),
DeleteLeaveDefinition({
failureRate: 0.5,
}),
]),
],
};
export const DeleteError: Story = {
decorators: [
withMockedBackend([
Get(),
DeleteLeaveDefinition({
delayMs: 1_000,
failureRate: 1,
}),
]),
],
};