@pie-lib/rubric 2.0.21 → 2.0.22-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,80 +3,6 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [2.0.21](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.20...@pie-lib/rubric@2.0.21) (2026-09-22)
7
-
8
- **Note:** Version bump only for package @pie-lib/rubric
9
-
10
- ## [2.0.20](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.19...@pie-lib/rubric@2.0.20) (2026-09-16)
11
-
12
- **Note:** Version bump only for package @pie-lib/rubric
13
-
14
- ## [2.0.19](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.18...@pie-lib/rubric@2.0.19) (2026-09-03)
15
-
16
- **Note:** Version bump only for package @pie-lib/rubric
17
-
18
- ## [2.0.18](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.17...@pie-lib/rubric@2.0.18) (2026-09-02)
19
-
20
- **Note:** Version bump only for package @pie-lib/rubric
21
-
22
- ## [2.0.17](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.16...@pie-lib/rubric@2.0.17) (2026-08-26)
23
-
24
- **Note:** Version bump only for package @pie-lib/rubric
25
-
26
- ## [2.0.16](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.15...@pie-lib/rubric@2.0.16) (2026-08-21)
27
-
28
- **Note:** Version bump only for package @pie-lib/rubric
29
-
30
- ## [2.0.15](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.14...@pie-lib/rubric@2.0.15) (2026-08-18)
31
-
32
- **Note:** Version bump only for package @pie-lib/rubric
33
-
34
- ## [2.0.14](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.13...@pie-lib/rubric@2.0.14) (2026-08-13)
35
-
36
- **Note:** Version bump only for package @pie-lib/rubric
37
-
38
- ## [2.0.13](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.12...@pie-lib/rubric@2.0.13) (2026-07-31)
39
-
40
- **Note:** Version bump only for package @pie-lib/rubric
41
-
42
- ## [2.0.12](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.11...@pie-lib/rubric@2.0.12) (2026-07-08)
43
-
44
- **Note:** Version bump only for package @pie-lib/rubric
45
-
46
- ## [2.0.11](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.10...@pie-lib/rubric@2.0.11) (2026-07-01)
47
-
48
- **Note:** Version bump only for package @pie-lib/rubric
49
-
50
- ## [2.0.10](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.9...@pie-lib/rubric@2.0.10) (2026-06-25)
51
-
52
- **Note:** Version bump only for package @pie-lib/rubric
53
-
54
- ## [2.0.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.8...@pie-lib/rubric@2.0.9) (2026-06-19)
55
-
56
- **Note:** Version bump only for package @pie-lib/rubric
57
-
58
- ## [2.0.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.7...@pie-lib/rubric@2.0.8) (2026-06-17)
59
-
60
- **Note:** Version bump only for package @pie-lib/rubric
61
-
62
- ## [2.0.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.6...@pie-lib/rubric@2.0.7) (2026-06-12)
63
-
64
- ### Bug Fixes
65
-
66
- - correct @emotion/style typo to @emotion/styled in package deps PIE-678 ([d529ac7](https://github.com/pie-framework/pie-lib/commit/d529ac7bc3dfa94d8037688452d4c70c66f2590b))
67
-
68
- ## [2.0.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.5...@pie-lib/rubric@2.0.6) (2026-06-03)
69
-
70
- **Note:** Version bump only for package @pie-lib/rubric
71
-
72
- ## [2.0.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.4...@pie-lib/rubric@2.0.5) (2026-06-01)
73
-
74
- **Note:** Version bump only for package @pie-lib/rubric
75
-
76
- ## [2.0.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.3...@pie-lib/rubric@2.0.4) (2026-05-21)
77
-
78
- **Note:** Version bump only for package @pie-lib/rubric
79
-
80
6
  ## [2.0.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/rubric@2.0.2...@pie-lib/rubric@2.0.3) (2026-05-15)
81
7
 
82
8
  **Note:** Version bump only for package @pie-lib/rubric
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/rubric",
3
- "version": "2.0.21",
3
+ "version": "2.0.22-beta.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -13,12 +13,12 @@
13
13
  "@hello-pangea/dnd": "^18.0.1",
14
14
  "@mui/icons-material": "^7.3.4",
15
15
  "@mui/material": "^7.3.4",
16
- "@pie-lib/editable-html-tip-tap": "^2.1.19",
16
+ "@pie-lib/editable-html-tip-tap": "^2.1.20-beta.2",
17
17
  "debug": "^4.1.1",
18
18
  "lodash-es": "^4.17.23",
19
19
  "prop-types": "^15.7.2",
20
20
  "react": "^18.2.0",
21
21
  "react-dom": "^18.2.0"
22
22
  },
23
- "gitHead": "555178e597d60d604dcc8b77cbb86dfde7b86b4f"
23
+ "gitHead": "433bcb776c2975739e7417f133d31cd996164116"
24
24
  }
package/LICENSE.md DELETED
@@ -1,5 +0,0 @@
1
- Copyright 2019 CoreSpring Inc
2
-
3
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4
-
5
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -1,373 +0,0 @@
1
- import { fireEvent, render, screen } from '@testing-library/react';
2
- import React from 'react';
3
- import { RawAuthoring } from '../authoring';
4
- import { takeRight } from 'lodash-es';
5
- import { createTheme, ThemeProvider } from '@mui/material/styles';
6
-
7
- // Mock dependencies
8
- jest.mock('@pie-lib/editable-html-tip-tap', () => {
9
- return function EditableHtml(props) {
10
- return <div data-testid="editable-html" data-markup={props.markup} />;
11
- };
12
- });
13
-
14
- jest.mock('@pie-lib/config-ui', () => ({
15
- FeedbackConfig: ({ feedback }) => <div data-testid="feedback-config">{JSON.stringify(feedback)}</div>,
16
- InputContainer: ({ children, label }) => (
17
- <div data-testid="input-container" data-label={label}>
18
- {children}
19
- </div>
20
- ),
21
- }));
22
-
23
- jest.mock('@hello-pangea/dnd', () => ({
24
- DragDropContext: ({ children }) => <div data-testid="drag-drop-context">{children}</div>,
25
- Droppable: ({ children }) => children({ droppableProps: {}, innerRef: () => {} }, {}),
26
- Draggable: ({ children, index }) =>
27
- children(
28
- {
29
- innerRef: () => {},
30
- draggableProps: { 'data-draggable-index': index },
31
- dragHandleProps: {},
32
- },
33
- {},
34
- ),
35
- }));
36
-
37
- describe('Rubric', () => {
38
- const points = ['nothing right', 'a teeny bit right', 'mostly right', 'bingo'];
39
- const sampleAnswers = [null, 'just right', 'not left', null];
40
- const theme = createTheme();
41
-
42
- const renderComponent = (value = {}, props = {}) => {
43
- const defaultProps = {
44
- classes: {},
45
- onChange: jest.fn(),
46
- className: 'className',
47
- value: {
48
- excludeZero: false,
49
- points,
50
- sampleAnswers,
51
- ...value,
52
- },
53
- ...props,
54
- };
55
-
56
- return {
57
- ...render(
58
- <ThemeProvider theme={theme}>
59
- <RawAuthoring {...defaultProps} />
60
- </ThemeProvider>,
61
- ),
62
- onChange: defaultProps.onChange,
63
- props: defaultProps,
64
- };
65
- };
66
-
67
- describe('render', () => {
68
- it('renders rubric title and main structure', () => {
69
- renderComponent();
70
- expect(screen.getByText('Rubric')).toBeInTheDocument();
71
- expect(screen.getByLabelText('Max Points')).toBeInTheDocument();
72
- expect(screen.getByLabelText('Exclude zeros')).toBeInTheDocument();
73
- });
74
-
75
- it('renders all point configurations', () => {
76
- const { container } = renderComponent();
77
- // Verify DragDropContext is rendered
78
- expect(container.querySelector('[data-testid="drag-drop-context"]')).toBeInTheDocument();
79
-
80
- // Check that point labels are rendered (4 points = "3 pts", "2 pts", "1 pt", "0 pt")
81
- // Note: The PointConfig component uses singular "pt" for 0 and 1, plural "pts" for 2+
82
- expect(screen.getByText('3 pts')).toBeInTheDocument();
83
- expect(screen.getByText('2 pts')).toBeInTheDocument();
84
- expect(screen.getByText('1 pt')).toBeInTheDocument();
85
- expect(screen.getByText('0 pt')).toBeInTheDocument();
86
- });
87
-
88
- describe('draggable', () => {
89
- it('renders 3 draggable items when excludeZero is true', () => {
90
- // When excludeZero is true, the last point (0 pts) should not be rendered
91
- expect(screen.queryByText('0 pt')).not.toBeInTheDocument();
92
- });
93
-
94
- it('renders 4 draggable items when excludeZero is false', () => {
95
- const { container } = renderComponent({ excludeZero: false });
96
-
97
- // When excludeZero is false, all points including 0 should be rendered
98
- const draggableItems = container.querySelectorAll('[data-draggable-index]');
99
- expect(draggableItems.length).toEqual(4);
100
- expect(screen.getByText('0 pt')).toBeInTheDocument();
101
-
102
- // Verify all point labels are rendered
103
- expect(screen.getByText('3 pts')).toBeInTheDocument();
104
- expect(screen.getByText('2 pts')).toBeInTheDocument();
105
- expect(screen.getByText('1 pt')).toBeInTheDocument();
106
- expect(screen.getByText('0 pt')).toBeInTheDocument();
107
- });
108
- });
109
- });
110
-
111
- describe('logic', () => {
112
- describe('changeMaxPoints', () => {
113
- const testChangeMaxPoints = (maxPoints, excludeZero, expectedPoints, expectedSampleAnswers) => {
114
- it(`maxPoints=${maxPoints}, excludeZero=${excludeZero} calls onChange correctly`, () => {
115
- const { onChange, container } = renderComponent({ excludeZero });
116
-
117
- // Get the component instance through the container
118
- // We need to call the method directly since we're testing internal behavior
119
- const instance = container.querySelector('[class*="MuiBox-root"]')?._owner;
120
-
121
- // Since we can't easily access instance methods in RTL, we'll test the behavior
122
- // by verifying the onChange prop receives the correct values
123
- // For now, we'll directly test the logic
124
- const component = new RawAuthoring({
125
- value: { excludeZero, points, sampleAnswers },
126
- onChange,
127
- classes: {},
128
- className: 'className',
129
- });
130
-
131
- component.changeMaxPoints(maxPoints);
132
-
133
- expect(onChange).toHaveBeenCalledWith({
134
- excludeZero,
135
- points: expectedPoints,
136
- sampleAnswers: expectedSampleAnswers,
137
- maxPoints: expectedPoints.length - 1,
138
- });
139
- });
140
- };
141
-
142
- testChangeMaxPoints(1, false, takeRight(points, 2), takeRight(sampleAnswers, 2));
143
- testChangeMaxPoints(1, true, takeRight(points, 2), takeRight(sampleAnswers, 2));
144
- testChangeMaxPoints(2, true, takeRight(points, 3), takeRight(sampleAnswers, 3));
145
- testChangeMaxPoints(2, false, takeRight(points, 3), takeRight(sampleAnswers, 3));
146
- testChangeMaxPoints(5, false, ['', ''].concat(points), [null, null].concat(sampleAnswers));
147
- });
148
-
149
- describe('changeSampleResponse', () => {
150
- const testChangeSampleResponse = (index, clickedItem, excludeZero, expectedPoints, expectedSampleAnswers) => {
151
- it(`Point ${index} with clickedItem="${clickedItem}" calls onChange correctly`, () => {
152
- const { onChange } = renderComponent({ excludeZero });
153
-
154
- // Test the logic by creating a component instance and calling the method
155
- const component = new RawAuthoring({
156
- value: { excludeZero, points, sampleAnswers },
157
- onChange,
158
- classes: {},
159
- className: 'className',
160
- });
161
-
162
- component.onPointMenuChange(index, clickedItem);
163
-
164
- expect(onChange).toHaveBeenCalledWith({
165
- excludeZero,
166
- points: expectedPoints,
167
- sampleAnswers: expectedSampleAnswers,
168
- });
169
- });
170
- };
171
-
172
- testChangeSampleResponse(0, 'sample', false, points, ['', 'just right', 'not left', null]);
173
- testChangeSampleResponse(3, 'sample', false, points, [null, 'just right', 'not left', '']);
174
- testChangeSampleResponse(1, 'sample', true, points, [null, null, 'not left', null]);
175
- testChangeSampleResponse(3, 'sample', true, points, [null, 'just right', 'not left', '']);
176
- });
177
- });
178
-
179
- describe('user interactions', () => {
180
- it('calls onChange when excluding zeros checkbox is toggled', () => {
181
- const { onChange } = renderComponent({ excludeZero: false });
182
-
183
- const checkbox = screen.getByLabelText('Exclude zeros');
184
- fireEvent.click(checkbox);
185
-
186
- expect(onChange).toHaveBeenCalledWith(
187
- expect.objectContaining({
188
- excludeZero: true,
189
- }),
190
- );
191
- });
192
-
193
- it('calls onChange when max points is changed', () => {
194
- const { onChange } = renderComponent();
195
-
196
- const selectInput = screen.getByLabelText('Max Points');
197
- fireEvent.mouseDown(selectInput);
198
-
199
- // The onChange should be called when a new value is selected
200
- // This tests the changeMaxPoints logic indirectly
201
- });
202
-
203
- it('renders correct number of points based on excludeZero', () => {
204
- const { rerender } = renderComponent({ excludeZero: false });
205
- expect(screen.getByText('0 pt')).toBeInTheDocument();
206
-
207
- // Rerender with excludeZero true
208
- rerender(
209
- <ThemeProvider theme={theme}>
210
- <RawAuthoring
211
- classes={{}}
212
- onChange={jest.fn()}
213
- className="className"
214
- value={{ excludeZero: true, points, sampleAnswers }}
215
- />
216
- </ThemeProvider>,
217
- );
218
-
219
- expect(screen.queryByText('0 pt')).not.toBeInTheDocument();
220
- });
221
- });
222
-
223
- describe('drag and drop', () => {
224
- it('calls onChange with reordered points after drag end', () => {
225
- const { onChange } = renderComponent();
226
-
227
- const component = new RawAuthoring({
228
- value: { excludeZero: false, points, sampleAnswers },
229
- onChange,
230
- classes: {},
231
- className: 'className',
232
- });
233
-
234
- // Simulate drag from index 0 to index 2
235
- component.dragEnd({
236
- source: { index: 0 },
237
- destination: { index: 2 },
238
- });
239
-
240
- expect(onChange).toHaveBeenCalled();
241
- const result = onChange.mock.calls[0][0];
242
- expect(result.points).not.toEqual(points);
243
- expect(result.points.length).toBe(points.length);
244
- });
245
-
246
- it('does nothing when drag has no destination', () => {
247
- const { onChange } = renderComponent();
248
-
249
- const component = new RawAuthoring({
250
- value: { excludeZero: false, points, sampleAnswers },
251
- onChange,
252
- classes: {},
253
- className: 'className',
254
- });
255
-
256
- // Simulate drag without destination
257
- component.dragEnd({
258
- source: { index: 0 },
259
- destination: null,
260
- });
261
-
262
- expect(onChange).not.toHaveBeenCalled();
263
- });
264
- });
265
-
266
- describe('content editing', () => {
267
- it('calls onChange when point content is changed', () => {
268
- const { onChange } = renderComponent();
269
-
270
- const component = new RawAuthoring({
271
- value: { excludeZero: false, points, sampleAnswers },
272
- onChange,
273
- classes: {},
274
- className: 'className',
275
- });
276
-
277
- component.changeContent(0, 'new content', 'points');
278
-
279
- expect(onChange).toHaveBeenCalledWith(
280
- expect.objectContaining({
281
- points: expect.arrayContaining(['new content']),
282
- }),
283
- );
284
- });
285
-
286
- it('calls onChange when sample answer is changed', () => {
287
- const { onChange } = renderComponent();
288
-
289
- const component = new RawAuthoring({
290
- value: { excludeZero: false, points, sampleAnswers },
291
- onChange,
292
- classes: {},
293
- className: 'className',
294
- });
295
-
296
- component.changeContent(1, 'new sample answer', 'sampleAnswers');
297
-
298
- expect(onChange).toHaveBeenCalledWith(
299
- expect.objectContaining({
300
- sampleAnswers: expect.arrayContaining(['new sample answer']),
301
- }),
302
- );
303
- });
304
-
305
- it('does not change content for invalid type', () => {
306
- const { onChange } = renderComponent();
307
-
308
- const component = new RawAuthoring({
309
- value: { excludeZero: false, points, sampleAnswers },
310
- onChange,
311
- classes: {},
312
- className: 'className',
313
- });
314
-
315
- component.changeContent(0, 'new content', 'invalidType');
316
-
317
- expect(onChange).not.toHaveBeenCalled();
318
- });
319
- });
320
-
321
- describe('rubricless mode', () => {
322
- it('calls onChange when rubricless instruction is changed', () => {
323
- const { onChange } = renderComponent({ rubriclessInstruction: '' }, { rubricless: true });
324
-
325
- const component = new RawAuthoring({
326
- value: { excludeZero: false, points, sampleAnswers, rubriclessInstruction: '' },
327
- onChange,
328
- classes: {},
329
- className: 'className',
330
- rubricless: true,
331
- });
332
-
333
- component.changeRubriclessInstruction('New instruction');
334
-
335
- expect(onChange).toHaveBeenCalledWith(
336
- expect.objectContaining({
337
- rubriclessInstruction: 'New instruction',
338
- }),
339
- );
340
- });
341
- });
342
-
343
- describe('edge cases', () => {
344
- it('handles empty points array', () => {
345
- const { container } = renderComponent({ points: [], sampleAnswers: [] });
346
- expect(container).toBeInTheDocument();
347
- });
348
-
349
- it('handles maxPoints greater than current max', () => {
350
- const { onChange } = renderComponent();
351
-
352
- const component = new RawAuthoring({
353
- value: { excludeZero: false, points, sampleAnswers },
354
- onChange,
355
- classes: {},
356
- className: 'className',
357
- });
358
-
359
- component.changeMaxPoints(10);
360
-
361
- expect(onChange).toHaveBeenCalled();
362
- const result = onChange.mock.calls[0][0];
363
- expect(result.points.length).toBe(11); // 10 + 1 for 0 points
364
- });
365
-
366
- it('handles config and pluginOpts props', () => {
367
- const config = { someConfig: true };
368
- const pluginOpts = { somePlugin: true };
369
- const { container } = renderComponent({}, { config, pluginOpts });
370
- expect(container).toBeInTheDocument();
371
- });
372
- });
373
- });