@dcrackel/hematournamentui 1.0.712 → 1.0.713

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.
Files changed (99) hide show
  1. package/.prettierignore +7 -7
  2. package/.storybook/main.js +3 -1
  3. package/README.md +30 -0
  4. package/package.json +96 -96
  5. package/prettier.config.js +16 -16
  6. package/src/main.js +1 -1
  7. package/src/mocks/getDEBouts-TableOf128.js +37 -37
  8. package/src/mocks/getDEBouts-TableOf64.js +35 -35
  9. package/src/stories/Atoms/Input/BaseInput.test.js +97 -97
  10. package/src/stories/Atoms/Input/BaseInput.vue +149 -149
  11. package/src/stories/Molecules/Indicators/MissingHemaRatingsId/MissingHemaRatingsId.stories.js +23 -23
  12. package/src/stories/Molecules/Indicators/MissingHemaRatingsId/MissingHemaRatingsId.vue +35 -35
  13. package/src/stories/Molecules/Indicators/RegistrationStatus/RegistrationStatus.vue +30 -30
  14. package/src/stories/Molecules/Menus/HoverActions/HoverActions.test.js +138 -0
  15. package/src/stories/Molecules/Menus/HoverActions/HoverActions.vue +212 -0
  16. package/src/stories/Molecules/Modals/DirectorModal/DirectorModal.stories.js +6 -0
  17. package/src/stories/Molecules/Modals/DirectorModal/DirectorModal.test.js +18 -18
  18. package/src/stories/Molecules/Modals/DirectorModal/DirectorModal.vue +1 -1
  19. package/src/stories/Organisms/Cards/BoutCard/BoutCard.vue +5 -1
  20. package/src/stories/Organisms/Cards/BoutCard/Variants/BoutCardActive/BoutCardActive.vue +19 -10
  21. package/src/stories/Organisms/Cards/BoutCard/Variants/BoutCardInactive/BoutCardInactive.vue +11 -7
  22. package/src/stories/Organisms/Cards/BracketDirectorAssignmentCard/BracketDirectorAssignmentCard.stories.js +33 -33
  23. package/src/stories/Organisms/Cards/BracketDirectorAssignmentCard/BracketDirectorAssignmentCard.test.js +45 -45
  24. package/src/stories/Organisms/Cards/BracketDirectorAssignmentCard/BracketDirectorAssignmentCard.vue +103 -103
  25. package/src/stories/Organisms/Cards/Director/DirectorCard.test.js +82 -0
  26. package/src/stories/Organisms/Cards/Director/DirectorCard.vue +32 -51
  27. package/src/stories/Organisms/Cards/EditBout/EditBout.test.js +51 -51
  28. package/src/stories/Organisms/Cards/EventCard/EventCard.test.js +106 -106
  29. package/src/stories/Organisms/Cards/FencerCard/FencerCard.vue +298 -298
  30. package/src/stories/Organisms/Cards/TableauBoutCard/TableauBoutCard.stories.js +77 -60
  31. package/src/stories/Organisms/Cards/TableauBoutCard/TableauBoutCard.test.js +144 -143
  32. package/src/stories/Organisms/Cards/TableauBoutCard/TableauBoutCard.vue +289 -256
  33. package/src/stories/Organisms/Cards/TableauFencerCard/TableauFencerCard.stories.js +69 -69
  34. package/src/stories/Organisms/Cards/TableauFencerCard/TableauFencerCard.vue +80 -80
  35. package/src/stories/Organisms/Cards/WaitlistFencerCard/WaitlistFencerCard.vue +153 -153
  36. package/src/stories/Organisms/ComplexInputs/DropDown/DropDownMenu.vue +4 -0
  37. package/src/stories/Organisms/ComplexInputs/ImageCropper/ImageCropper.stories.js +31 -31
  38. package/src/stories/Organisms/ComplexInputs/ImageCropper/ImageCropper.test.js +109 -109
  39. package/src/stories/Organisms/ComplexInputs/ImageCropper/ImageCropper.vue +192 -192
  40. package/src/stories/Organisms/Containers/Tableau/Tableau.stories.js +1 -0
  41. package/src/stories/Organisms/Containers/Tableau/Tableau.test.js +247 -204
  42. package/src/stories/Organisms/Containers/Tableau/Tableau.vue +89 -15
  43. package/src/stories/Organisms/Containers/Tableau/components/BracketDirectorAssignmentPanel.test.js +29 -29
  44. package/src/stories/Organisms/Containers/Tableau/components/BracketDirectorAssignmentPanel.vue +46 -46
  45. package/src/stories/Organisms/Containers/Tableau/components/TableauSvgOverlay.test.js +21 -21
  46. package/src/stories/Organisms/Containers/Tableau/components/TableauSvgOverlay.vue +39 -39
  47. package/src/stories/Organisms/Containers/Tableau/layout/TableauLayoutEngine.js +145 -145
  48. package/src/stories/Organisms/Containers/Tableau/layout/TableauLayoutEngine.test.js +64 -64
  49. package/src/stories/Organisms/Containers/Tableau/plannedAssignments.js +36 -57
  50. package/src/stories/Organisms/Containers/Tableau/plannedAssignments.test.js +101 -65
  51. package/src/stories/Organisms/Containers/TableauColumn/TableauColumn.vue +14 -1
  52. package/src/stories/Organisms/Wizards/EditEventWizard/BasicEventInfo/BasicEventInfo.stories.js +52 -52
  53. package/src/stories/Organisms/Wizards/EditEventWizard/BasicEventInfo/BasicEventInfo.vue +10 -3
  54. package/src/stories/Organisms/Wizards/EditEventWizard/DirectElimination/DirectElimination.vue +226 -226
  55. package/src/stories/Organisms/Wizards/EditEventWizard/DirectEliminationPromotion/DirectEliminationPromotion.vue +204 -204
  56. package/src/stories/Organisms/Wizards/EditEventWizard/EditEventWizard.stories.js +137 -137
  57. package/src/stories/Organisms/Wizards/EditEventWizard/EventCustomization/EventCustomization.vue +172 -172
  58. package/src/stories/Organisms/Wizards/EditEventWizard/PoolConfiguration/PoolConfiguration.vue +216 -216
  59. package/src/stories/Organisms/Wizards/EditEventWizard/PriceFields.test.js +79 -79
  60. package/src/stories/Organisms/Wizards/EditEventWizard/RuleSerialization.test.js +29 -29
  61. package/src/stories/Organisms/Wizards/EditEventWizard/WeaponSelection.test.js +138 -0
  62. package/src/stories/Templates/EventManagement/Bracket/Bracket.stories.js +123 -12
  63. package/src/stories/Templates/EventManagement/Bracket/Bracket.test.js +178 -166
  64. package/src/stories/Templates/EventManagement/Bracket/Bracket.vue +35 -7
  65. package/src/stories/Templates/EventManagement/Bracket/BracketDirectorAssignment.test.js +242 -0
  66. package/src/stories/Templates/EventManagement/Bracket/BracketMobile.test.js +131 -0
  67. package/src/stories/Templates/EventManagement/Bracket/BracketPlannedSuggestions.js +42 -39
  68. package/src/stories/Templates/EventManagement/Bracket/BracketStories.test.js +80 -0
  69. package/src/stories/Templates/EventManagement/Bracket/BracketStoryAssignments.js +93 -0
  70. package/src/stories/Templates/EventManagement/Bracket/BracketStoryAssignments.test.js +152 -0
  71. package/src/stories/Templates/EventManagement/Bracket/BracketStoryHarness.js +39 -39
  72. package/src/stories/Templates/EventManagement/Bracket/BracketStoryHarness.test.js +79 -79
  73. package/src/stories/Templates/EventManagement/EditEventInfo/EditEventInfo.stories.js +93 -93
  74. package/src/stories/Templates/EventManagement/EditEventInfo/EditEventInfo.vue +91 -91
  75. package/src/stories/Templates/EventManagement/PoolLive/PoolLive.test.js +121 -121
  76. package/src/stories/Templates/Menus/EditEventsTopMenu/EditEventsTopMenu.stories.js +9 -2
  77. package/src/stories/Templates/Menus/EditEventsTopMenu/EditEventsTopMenu.vue +5 -4
  78. package/src/stories/Templates/PersonManagement/Admin/Administration/Administration.stories.js +81 -81
  79. package/src/stories/Templates/PersonManagement/Admin/Administration/Administration.test.js +39 -39
  80. package/src/stories/Templates/PersonManagement/Admin/Administration/Administration.vue +101 -101
  81. package/src/stories/Templates/PersonManagement/Admin/FencerAdmin/FencerAdmin.stories.js +71 -71
  82. package/src/stories/Templates/PersonManagement/Admin/FencerAdmin/FencerAdmin.vue +86 -86
  83. package/src/stories/Templates/PersonManagement/Admin/MergeAccounts/MergeAccounts.stories.js +86 -86
  84. package/src/stories/Templates/PersonManagement/Admin/MergeAccounts/MergeAccounts.vue +247 -247
  85. package/src/stories/Templates/PersonManagement/Basic/BasicEdit.vue +170 -170
  86. package/src/stories/Templates/PersonManagement/PersonManagement.stories.js +156 -156
  87. package/src/stories/Templates/PersonManagement/PersonManagement.test.js +329 -329
  88. package/src/stories/Templates/PersonManagement/PersonManagement.vue +329 -329
  89. package/src/stories/Templates/PersonManagement/PersonManagementDraft.js +42 -42
  90. package/src/stories/Templates/TournamentManagement/TournamentManagement.stories.js +84 -84
  91. package/src/stories/Templates/TournamentManagement/TournamentManagement.test.js +114 -114
  92. package/src/stories/Templates/TournamentManagement/TournamentManagement.vue +363 -363
  93. package/src/stories/Templates/TournamentManagement/TournamentPageOne/TournamentPageOne.stories.js +116 -116
  94. package/src/stories/Templates/TournamentManagement/TournamentPageOne/TournamentPageOne.vue +307 -307
  95. package/src/stories/Util/Validations/PersonManagementValidations.js +45 -45
  96. package/src/stories/Util/Validations/PriceValidation.js +6 -6
  97. package/src/stories/Util/boutDirectorAssignment.js +46 -0
  98. package/src/stories/Util/registrationStatus.js +11 -11
  99. package/src/stories/Util/tabs.js +19 -47
@@ -0,0 +1,152 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { activateStoryBout, canStoryDirectorDirectBout } from './BracketStoryHarness.js';
3
+ import { distributeStoryAssignments } from './BracketStoryAssignments.js';
4
+
5
+ const stations = Array.from({ length: 6 }, (_, index) => ({ RingId: index + 1, Director: { PersonId: index + 101 } }));
6
+ const createPerson = PersonId => ({ PersonId, DisplayName: PersonId ? 'Fencer ' + PersonId : 'BYE' });
7
+ const createBracket = () => {
8
+ const bouts = [];
9
+ for (let size = 64; size >= 2; size /= 2) {
10
+ for (let index = 0; index < size / 2; index++) {
11
+ const id = bouts.length + 1;
12
+ bouts.push({
13
+ BoutId: id + 1000,
14
+ DEBoutId: id,
15
+ RoundLabel: size >= 8 ? 'Table of ' + size : { 4: 'Semifinal', 2: 'Final' }[size],
16
+ Status: 'Scheduled',
17
+ Person1: createPerson(size === 64 ? index * 2 + 1 : 0),
18
+ Person2: createPerson(size === 64 ? index * 2 + 2 : 0)
19
+ });
20
+ }
21
+ }
22
+ return bouts;
23
+ };
24
+ const getRingIds = (assignments, bouts) => {
25
+ const ringByBout = new Map(assignments.map(assignment => [assignment.DEBoutId, assignment.RingId]));
26
+ return bouts.map(bout => ringByBout.get(bout.DEBoutId));
27
+ };
28
+ const countAssignments = (assignments, count) =>
29
+ stations
30
+ .slice(0, count)
31
+ .map(station => assignments.filter(assignment => assignment.RingId === station.RingId).length);
32
+
33
+ describe('Bracket story section coverage', () => {
34
+ it.each([2, 4])('keeps exact early bracket sections and includes semifinals with %i directors', count => {
35
+ const bouts = createBracket();
36
+ const original = structuredClone(bouts);
37
+ const assignments = distributeStoryAssignments({ bouts, stations: stations.slice(0, count) });
38
+ expect(assignments).toHaveLength(62);
39
+ for (const size of [64, 32, 16, 8]) {
40
+ const round = bouts.filter(bout => bout.RoundLabel === 'Table of ' + size);
41
+ expect(getRingIds(assignments, round)).toEqual(
42
+ round.map((_, index) => Math.floor(index / (round.length / count)) + 1)
43
+ );
44
+ }
45
+ expect(bouts).toEqual(original);
46
+ });
47
+
48
+ it.each([
49
+ [3, [11, 11, 10]],
50
+ [5, [7, 7, 6, 6, 6]],
51
+ [6, [6, 6, 5, 5, 5, 5]]
52
+ ])('balances contiguous groups and total workload with %i directors', (count, openingCounts) => {
53
+ const bouts = createBracket();
54
+ const assignments = distributeStoryAssignments({ bouts, stations: stations.slice(0, count) });
55
+ expect(
56
+ countAssignments(
57
+ assignments.filter(assignment => assignment.DEBoutId <= 32),
58
+ count
59
+ )
60
+ ).toEqual(openingCounts);
61
+ const totals = countAssignments(assignments, count);
62
+ expect(totals.reduce((sum, total) => sum + total, 0)).toBe(62);
63
+ expect(Math.max(...totals) - Math.min(...totals)).toBeLessThanOrEqual(1);
64
+ for (const size of [64, 32, 16, 8]) {
65
+ const ringIds = getRingIds(
66
+ assignments,
67
+ bouts.filter(bout => bout.RoundLabel === 'Table of ' + size)
68
+ );
69
+ expect(ringIds).toEqual([...ringIds].sort((first, second) => first - second));
70
+ }
71
+ });
72
+
73
+ it('ignores opening BYEs as work while planning unresolved later bouts', () => {
74
+ const bouts = createBracket();
75
+ for (const index of [0, 7, 18]) bouts[index].Person2 = createPerson(0);
76
+ const assignments = distributeStoryAssignments({ bouts, stations: stations.slice(0, 3) });
77
+ expect(assignments).toHaveLength(59);
78
+ expect(
79
+ countAssignments(
80
+ assignments.filter(assignment => assignment.DEBoutId <= 32),
81
+ 3
82
+ )
83
+ ).toEqual([10, 10, 9]);
84
+ expect(countAssignments(assignments, 3)).toEqual([20, 20, 19]);
85
+ expect(getRingIds(assignments, [bouts[0], bouts[7], bouts[18]])).toEqual([undefined, undefined, undefined]);
86
+ expect(
87
+ getRingIds(
88
+ assignments,
89
+ bouts.filter(bout => bout.RoundLabel === 'Table of 8')
90
+ )
91
+ ).not.toContain(undefined);
92
+ });
93
+
94
+ it('keeps halves and quarters aligned even when opening BYEs make workloads uneven', () => {
95
+ const bouts = createBracket();
96
+ bouts[0].Person2 = createPerson(0);
97
+ bouts[1].Person2 = createPerson(0);
98
+ const assignments = distributeStoryAssignments({ bouts, stations: stations.slice(0, 2) });
99
+ expect(getRingIds(assignments, [bouts[15], bouts[16]])).toEqual([1, 2]);
100
+ expect(countAssignments(assignments, 2)).toEqual([29, 31]);
101
+ });
102
+
103
+ it('assigns semifinals while leaving finals, placement, and consolation shared', () => {
104
+ const bouts = createBracket();
105
+ bouts.push(
106
+ ...['Third Place', 'Consolation Round 8', 'Grand Final'].map((RoundLabel, index) => ({
107
+ ...bouts.at(-1),
108
+ BoutId: 2000 + index,
109
+ DEBoutId: 100 + index,
110
+ RoundLabel
111
+ }))
112
+ );
113
+ const assignments = distributeStoryAssignments({ bouts, stations });
114
+ const shared = bouts.filter(bout => !bout.RoundLabel.startsWith('Table of') && bout.RoundLabel !== 'Semifinal');
115
+ expect(
116
+ getRingIds(
117
+ assignments,
118
+ bouts.filter(bout => bout.RoundLabel === 'Semifinal')
119
+ )
120
+ ).not.toContain(undefined);
121
+ expect(getRingIds(assignments, shared)).toEqual(shared.map(() => undefined));
122
+ const final = {
123
+ ...bouts.find(bout => bout.RoundLabel === 'Final'),
124
+ Person1: createPerson(1),
125
+ Person2: createPerson(2)
126
+ };
127
+ const freshDirector = { Director: { PersonId: 999, DisplayName: 'Fresh Director' } };
128
+ expect(canStoryDirectorDirectBout(final, 999)).toBe(true);
129
+ expect(activateStoryBout(final, freshDirector)).toMatchObject({
130
+ RefereeId: 999,
131
+ RefName: 'Fresh Director',
132
+ Status: 'Active'
133
+ });
134
+ });
135
+
136
+ it('redistributes scheduled coverage after adding a director while preserving active and completed plans', () => {
137
+ const bouts = createBracket();
138
+ const previousAssignments = distributeStoryAssignments({ bouts, stations: stations.slice(0, 2) });
139
+ bouts[14].Status = 'Active';
140
+ bouts[15].Status = 'Completed';
141
+ const assignments = distributeStoryAssignments({ bouts, stations: stations.slice(0, 4), previousAssignments });
142
+ expect(getRingIds(assignments, [bouts[14], bouts[15]])).toEqual([1, 1]);
143
+ expect(getRingIds(assignments, [bouts[8], bouts[16], bouts[24]])).toEqual([2, 3, 4]);
144
+ expect(new Set(assignments.map(assignment => assignment.DEBoutId)).size).toBe(assignments.length);
145
+ });
146
+
147
+ it('handles no bouts, no stations, and invalid stations without creating assignments', () => {
148
+ expect(distributeStoryAssignments()).toEqual([]);
149
+ expect(distributeStoryAssignments({ bouts: createBracket(), stations: [null, {}, { RingId: 1 }] })).toEqual([]);
150
+ expect(distributeStoryAssignments({ bouts: [], stations })).toEqual([]);
151
+ });
152
+ });
@@ -1,39 +1,39 @@
1
- const STORY_DIRECTOR = {
2
- PersonId: -1,
3
- DisplayName: 'Story Director'
4
- };
5
-
6
- const isSameBout = (bout, selectedBout) => String(bout.BoutId) === String(selectedBout.BoutId);
7
- const isActiveBout = bout => String(bout?.Status || '').toLowerCase() === 'active';
8
- const hasSameIdentity = (firstId, secondId) => String(firstId ?? '') === String(secondId ?? '');
9
-
10
- export const cloneStoryBouts = bouts => (bouts || []).map(bout => ({ ...bout }));
11
-
12
- export const canStoryDirectorDirectBout = (bout, directorId) =>
13
- !isActiveBout(bout) || hasSameIdentity(bout.RefereeId, directorId);
14
-
15
- export const getStoryDirectorId = station => station?.Director?.PersonId ?? STORY_DIRECTOR.PersonId;
16
-
17
- export const activateStoryBout = (bout, station = null) => {
18
- const director = station?.Director || STORY_DIRECTOR;
19
-
20
- return {
21
- ...bout,
22
- Status: 'Active',
23
- RefereeId: director.PersonId,
24
- RefName: director.DisplayName,
25
- RingName: station?.RingName || bout.RingName || 'DE Bracket',
26
- TimerStatus: bout.TimerStatus || 'stopped',
27
- TimeLeft: Number(bout.TimeLeft) > 0 ? Number(bout.TimeLeft) : 180
28
- };
29
- };
30
-
31
- export const clearStoryBoutChrome = bout => ({
32
- ...bout,
33
- RingName: '',
34
- TimerStatus: 'stopped',
35
- TimeLeft: 0
36
- });
37
-
38
- export const replaceStoryBout = (bouts, selectedBout) =>
39
- bouts.map(bout => (isSameBout(bout, selectedBout) ? { ...selectedBout } : bout));
1
+ const STORY_DIRECTOR = {
2
+ PersonId: -1,
3
+ DisplayName: 'Story Director'
4
+ };
5
+
6
+ const isSameBout = (bout, selectedBout) => String(bout.BoutId) === String(selectedBout.BoutId);
7
+ const isActiveBout = bout => String(bout?.Status || '').toLowerCase() === 'active';
8
+ const hasSameIdentity = (firstId, secondId) => String(firstId ?? '') === String(secondId ?? '');
9
+
10
+ export const cloneStoryBouts = bouts => (bouts || []).map(bout => ({ ...bout }));
11
+
12
+ export const canStoryDirectorDirectBout = (bout, directorId) =>
13
+ !isActiveBout(bout) || hasSameIdentity(bout.RefereeId, directorId);
14
+
15
+ export const getStoryDirectorId = station => station?.Director?.PersonId ?? STORY_DIRECTOR.PersonId;
16
+
17
+ export const activateStoryBout = (bout, station = null) => {
18
+ const director = station?.Director || STORY_DIRECTOR;
19
+
20
+ return {
21
+ ...bout,
22
+ Status: 'Active',
23
+ RefereeId: director.PersonId,
24
+ RefName: director.DisplayName,
25
+ RingName: station?.RingName || bout.RingName || 'DE Bracket',
26
+ TimerStatus: bout.TimerStatus || 'stopped',
27
+ TimeLeft: Number(bout.TimeLeft) > 0 ? Number(bout.TimeLeft) : 180
28
+ };
29
+ };
30
+
31
+ export const clearStoryBoutChrome = bout => ({
32
+ ...bout,
33
+ RingName: '',
34
+ TimerStatus: 'stopped',
35
+ TimeLeft: 0
36
+ });
37
+
38
+ export const replaceStoryBout = (bouts, selectedBout) =>
39
+ bouts.map(bout => (isSameBout(bout, selectedBout) ? { ...selectedBout } : bout));
@@ -1,79 +1,79 @@
1
- import { describe, expect, it } from 'vitest';
2
- import {
3
- activateStoryBout,
4
- canStoryDirectorDirectBout,
5
- clearStoryBoutChrome,
6
- replaceStoryBout
7
- } from './BracketStoryHarness';
8
-
9
- describe('Bracket story parent simulation', () => {
10
- it('returns an Active parent-owned bout without mutating the selected bout', () => {
11
- const scheduledBout = { BoutId: 42, Status: 'Scheduled', TimeLeft: 0, Score1: 2, Score2: 1 };
12
-
13
- const activeBout = activateStoryBout(scheduledBout);
14
-
15
- expect(activeBout).toMatchObject({
16
- Status: 'Active',
17
- RefereeId: -1,
18
- RefName: 'Story Director',
19
- RingName: 'DE Bracket',
20
- TimerStatus: 'stopped',
21
- TimeLeft: 180,
22
- Score1: 2,
23
- Score2: 1
24
- });
25
- expect(scheduledBout).toEqual({ BoutId: 42, Status: 'Scheduled', TimeLeft: 0, Score1: 2, Score2: 1 });
26
- });
27
-
28
- it('replaces only the selected bout in the story-owned collection', () => {
29
- const bouts = [
30
- { BoutId: 41, Status: 'Scheduled' },
31
- { BoutId: 42, Status: 'Scheduled' }
32
- ];
33
- const activeBout = { BoutId: 42, Status: 'Active' };
34
-
35
- expect(replaceStoryBout(bouts, activeBout)).toEqual([bouts[0], activeBout]);
36
- });
37
-
38
- it('uses the viewer station when the story simulates pulling a scheduled bout', () => {
39
- const scheduledBout = { BoutId: 42, Status: 'Scheduled' };
40
- const station = {
41
- RingName: 'Ring 1',
42
- Director: { PersonId: 1001, DisplayName: 'Alex Morgan' }
43
- };
44
-
45
- expect(activateStoryBout(scheduledBout, station)).toMatchObject({
46
- Status: 'Active',
47
- RefereeId: 1001,
48
- RefName: 'Alex Morgan',
49
- RingName: 'Ring 1'
50
- });
51
- expect(scheduledBout).toEqual({ BoutId: 42, Status: 'Scheduled' });
52
- });
53
-
54
- it('allows scheduled bouts to move but protects an Active bout owned by another director', () => {
55
- expect(canStoryDirectorDirectBout({ Status: 'Scheduled', RefereeId: 2002 }, 1001)).toBe(true);
56
- expect(canStoryDirectorDirectBout({ Status: 'Active', RefereeId: 2002 }, 1001)).toBe(false);
57
- expect(canStoryDirectorDirectBout({ Status: 'Active', RefereeId: 1001 }, '1001')).toBe(true);
58
- });
59
-
60
- it('clears story-only ring and timer fields without resetting status or scores', () => {
61
- const activeBout = {
62
- BoutId: 42,
63
- Status: 'Active',
64
- Score1: 5,
65
- Score2: 4,
66
- RingName: 'Ring 3',
67
- TimerStatus: 'running',
68
- TimeLeft: 72
69
- };
70
-
71
- expect(clearStoryBoutChrome(activeBout)).toEqual({
72
- ...activeBout,
73
- RingName: '',
74
- TimerStatus: 'stopped',
75
- TimeLeft: 0
76
- });
77
- expect(activeBout).toMatchObject({ Status: 'Active', Score1: 5, Score2: 4 });
78
- });
79
- });
1
+ import { describe, expect, it } from 'vitest';
2
+ import {
3
+ activateStoryBout,
4
+ canStoryDirectorDirectBout,
5
+ clearStoryBoutChrome,
6
+ replaceStoryBout
7
+ } from './BracketStoryHarness';
8
+
9
+ describe('Bracket story parent simulation', () => {
10
+ it('returns an Active parent-owned bout without mutating the selected bout', () => {
11
+ const scheduledBout = { BoutId: 42, Status: 'Scheduled', TimeLeft: 0, Score1: 2, Score2: 1 };
12
+
13
+ const activeBout = activateStoryBout(scheduledBout);
14
+
15
+ expect(activeBout).toMatchObject({
16
+ Status: 'Active',
17
+ RefereeId: -1,
18
+ RefName: 'Story Director',
19
+ RingName: 'DE Bracket',
20
+ TimerStatus: 'stopped',
21
+ TimeLeft: 180,
22
+ Score1: 2,
23
+ Score2: 1
24
+ });
25
+ expect(scheduledBout).toEqual({ BoutId: 42, Status: 'Scheduled', TimeLeft: 0, Score1: 2, Score2: 1 });
26
+ });
27
+
28
+ it('replaces only the selected bout in the story-owned collection', () => {
29
+ const bouts = [
30
+ { BoutId: 41, Status: 'Scheduled' },
31
+ { BoutId: 42, Status: 'Scheduled' }
32
+ ];
33
+ const activeBout = { BoutId: 42, Status: 'Active' };
34
+
35
+ expect(replaceStoryBout(bouts, activeBout)).toEqual([bouts[0], activeBout]);
36
+ });
37
+
38
+ it('uses the viewer station when the story simulates pulling a scheduled bout', () => {
39
+ const scheduledBout = { BoutId: 42, Status: 'Scheduled' };
40
+ const station = {
41
+ RingName: 'Ring 1',
42
+ Director: { PersonId: 1001, DisplayName: 'Alex Morgan' }
43
+ };
44
+
45
+ expect(activateStoryBout(scheduledBout, station)).toMatchObject({
46
+ Status: 'Active',
47
+ RefereeId: 1001,
48
+ RefName: 'Alex Morgan',
49
+ RingName: 'Ring 1'
50
+ });
51
+ expect(scheduledBout).toEqual({ BoutId: 42, Status: 'Scheduled' });
52
+ });
53
+
54
+ it('allows scheduled bouts to move but protects an Active bout owned by another director', () => {
55
+ expect(canStoryDirectorDirectBout({ Status: 'Scheduled', RefereeId: 2002 }, 1001)).toBe(true);
56
+ expect(canStoryDirectorDirectBout({ Status: 'Active', RefereeId: 2002 }, 1001)).toBe(false);
57
+ expect(canStoryDirectorDirectBout({ Status: 'Active', RefereeId: 1001 }, '1001')).toBe(true);
58
+ });
59
+
60
+ it('clears story-only ring and timer fields without resetting status or scores', () => {
61
+ const activeBout = {
62
+ BoutId: 42,
63
+ Status: 'Active',
64
+ Score1: 5,
65
+ Score2: 4,
66
+ RingName: 'Ring 3',
67
+ TimerStatus: 'running',
68
+ TimeLeft: 72
69
+ };
70
+
71
+ expect(clearStoryBoutChrome(activeBout)).toEqual({
72
+ ...activeBout,
73
+ RingName: '',
74
+ TimerStatus: 'stopped',
75
+ TimeLeft: 0
76
+ });
77
+ expect(activeBout).toMatchObject({ Status: 'Active', Score1: 5, Score2: 4 });
78
+ });
79
+ });
@@ -1,93 +1,93 @@
1
- import { ref } from 'vue';
2
- import editConfig from './EditEventInfo.vue';
3
- import singleEventMock from '../../../../mocks/singleEventMock.js';
4
- import eventRules from '../../../../mocks/eventRules.js';
5
- import getAllWeapons from '../../../../mocks/getAllWeapons.js';
6
-
7
- export default {
8
- title: 'Templates/EventManagement/EditEventInfo',
9
- component: editConfig,
10
- tags: ['autodocs'],
11
- args: {
12
- event: singleEventMock,
13
- weapons: getAllWeapons,
14
- rules: eventRules,
15
- userLevel: 'admin'
16
- },
17
- argTypes: {
18
- editMode: { control: 'boolean' },
19
- step: { control: { type: 'number', min: 1, max: 5 } },
20
- saving: { control: 'boolean' },
21
- saveError: { control: 'text' },
22
- saveNotice: { control: 'text' },
23
- event: { control: 'object' },
24
- weapons: { control: 'object' },
25
- rules: { control: 'object' },
26
- userLevel: { control: 'text' }
27
- }
28
- };
29
-
30
- export const Default = {
31
- args: {
32
- event: singleEventMock,
33
- weapons: getAllWeapons,
34
- rules: eventRules,
35
- userLevel: 'admin'
36
- }
37
- };
38
-
39
- export const NewEvent = {
40
- args: {
41
- event: {
42
- Absent: 0,
43
- Date: new Date().toISOString().split('T')[0],
44
- EventName: '',
45
- Flights: 1,
46
- NumberOfPools: 2,
47
- NumberOfRings: 2,
48
- PoolSize: 0,
49
- Present: 0,
50
- StartTime: '12:00:00',
51
- Status: 'planning',
52
- TournamentId: 10
53
- },
54
- weapons: getAllWeapons,
55
- rules: [],
56
- userLevel: 'admin'
57
- }
58
- };
59
-
60
- export const EditWithStepSaves = {
61
- args: { ...Default.args, editMode: true, step: 1 },
62
- render: args => ({
63
- components: { Editor: editConfig },
64
- setup() {
65
- const event = ref(JSON.parse(JSON.stringify(args.event)));
66
- const step = ref(args.step);
67
- const saving = ref(false);
68
- const notice = ref('');
69
- const saveStep = async request => {
70
- saving.value = true;
71
- await new Promise(resolve => setTimeout(resolve, 500));
72
- event.value = request.event;
73
- step.value = Math.min(request.step + 1, 5);
74
- notice.value = 'Changes saved.';
75
- saving.value = false;
76
- };
77
- const clearNotice = dirty => {
78
- if (dirty) notice.value = '';
79
- };
80
- return { args, event, step, saving, notice, saveStep, clearNotice };
81
- },
82
- template:
83
- '<Editor v-bind="args" :rules="args.rules" :weapons="args.weapons" :event="event" :step="step" :saving="saving" :saveNotice="notice" @save:step="saveStep" @navigate:step="step = $event" @update:dirty="clearNotice" />'
84
- })
85
- };
86
-
87
- export const SavingStep = {
88
- args: { ...Default.args, editMode: true, step: 2, saving: true }
89
- };
90
-
91
- export const StepSaveFailed = {
92
- args: { ...Default.args, editMode: true, step: 2, saveError: 'Changes could not be saved. Please try again.' }
93
- };
1
+ import { ref } from 'vue';
2
+ import editConfig from './EditEventInfo.vue';
3
+ import singleEventMock from '../../../../mocks/singleEventMock.js';
4
+ import eventRules from '../../../../mocks/eventRules.js';
5
+ import getAllWeapons from '../../../../mocks/getAllWeapons.js';
6
+
7
+ export default {
8
+ title: 'Templates/EventManagement/EditEventInfo',
9
+ component: editConfig,
10
+ tags: ['autodocs'],
11
+ args: {
12
+ event: singleEventMock,
13
+ weapons: getAllWeapons,
14
+ rules: eventRules,
15
+ userLevel: 'admin'
16
+ },
17
+ argTypes: {
18
+ editMode: { control: 'boolean' },
19
+ step: { control: { type: 'number', min: 1, max: 5 } },
20
+ saving: { control: 'boolean' },
21
+ saveError: { control: 'text' },
22
+ saveNotice: { control: 'text' },
23
+ event: { control: 'object' },
24
+ weapons: { control: 'object' },
25
+ rules: { control: 'object' },
26
+ userLevel: { control: 'text' }
27
+ }
28
+ };
29
+
30
+ export const Default = {
31
+ args: {
32
+ event: singleEventMock,
33
+ weapons: getAllWeapons,
34
+ rules: eventRules,
35
+ userLevel: 'admin'
36
+ }
37
+ };
38
+
39
+ export const NewEvent = {
40
+ args: {
41
+ event: {
42
+ Absent: 0,
43
+ Date: new Date().toISOString().split('T')[0],
44
+ EventName: '',
45
+ Flights: 1,
46
+ NumberOfPools: 2,
47
+ NumberOfRings: 2,
48
+ PoolSize: 0,
49
+ Present: 0,
50
+ StartTime: '12:00:00',
51
+ Status: 'planning',
52
+ TournamentId: 10
53
+ },
54
+ weapons: getAllWeapons,
55
+ rules: [],
56
+ userLevel: 'admin'
57
+ }
58
+ };
59
+
60
+ export const EditWithStepSaves = {
61
+ args: { ...Default.args, editMode: true, step: 1 },
62
+ render: args => ({
63
+ components: { Editor: editConfig },
64
+ setup() {
65
+ const event = ref(JSON.parse(JSON.stringify(args.event)));
66
+ const step = ref(args.step);
67
+ const saving = ref(false);
68
+ const notice = ref('');
69
+ const saveStep = async request => {
70
+ saving.value = true;
71
+ await new Promise(resolve => setTimeout(resolve, 500));
72
+ event.value = request.event;
73
+ step.value = Math.min(request.step + 1, 5);
74
+ notice.value = 'Changes saved.';
75
+ saving.value = false;
76
+ };
77
+ const clearNotice = dirty => {
78
+ if (dirty) notice.value = '';
79
+ };
80
+ return { args, event, step, saving, notice, saveStep, clearNotice };
81
+ },
82
+ template:
83
+ '<Editor v-bind="args" :rules="args.rules" :weapons="args.weapons" :event="event" :step="step" :saving="saving" :saveNotice="notice" @save:step="saveStep" @navigate:step="step = $event" @update:dirty="clearNotice" />'
84
+ })
85
+ };
86
+
87
+ export const SavingStep = {
88
+ args: { ...Default.args, editMode: true, step: 2, saving: true }
89
+ };
90
+
91
+ export const StepSaveFailed = {
92
+ args: { ...Default.args, editMode: true, step: 2, saveError: 'Changes could not be saved. Please try again.' }
93
+ };