summaryrefslogtreecommitdiff
path: root/tests/testing-strategy.org
blob: d7b25a9532f3e303e8b154c3fdfaf7b075163ae6 (plain)
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#+TITLE: CHIME Testing Strategy
#+AUTHOR: Craig Jennings
#+DATE: 2024-10-24

* Overview

This document outlines the ERT test strategy for the CHIME package, prioritizing critical functionality and documenting what should be tested and why.

* Test Guidelines

** Requirements
- All tests in =chime.el/tests/= directory
- File naming: =test-chime-<methodname>.el=
- Use =testutil-general.el= utilities for test data management
- Tests must be independent, deterministic, and isolated

** Testing Approach
- ERT framework
- Each test verifies one specific behavior
- Mock external dependencies (file I/O, time, network)
- Descriptive naming: =test-chime-<function>-<scenario>-<expected-result>=

** CHIME-Specific Considerations
- Mock: =alert=, =play-sound-file=, =current-time=, async operations, org-agenda functions
- Focus on critical paths: notification logic, modeline updates, sound playback, time calculations

* Priority Tiers

** TIER 1: Core Logic (Must Test)

*** DONE Test chime--timestamp-parse
:PROPERTIES:
:PRIORITY: A
:TIER: 1
:END:

*Why:* Fixed bugs here. Converts org timestamps to Emacs time. Foundation of all time calculations.

*Risk:*
- Malformed timestamps
- Timezone issues
- Repeating timestamps (=+1w=, =.+1d=, =++1w=)
- Edge cases around midnight
- Invalid date/time strings

*Test Coverage:*
- Normal: Valid timestamps with various formats
- Boundary: Midnight, year boundaries, DST transitions
- Error: Malformed strings, missing components, invalid dates

*Status:* ✅ Complete - 25 tests, all passing

*** DONE Test chime--has-timestamp
:PROPERTIES:
:PRIORITY: A
:TIER: 1
:END:

*Why:* Fixed bugs here. Determines if event has valid time component. Gates whether events get processed.

*Risk:*
- Misclassifying day-wide vs timed events
- False positives/negatives on timestamp detection
- Not handling all org timestamp formats

*Test Coverage:*
- Normal: Standard timestamps with time components
- Boundary: Timestamps at boundaries, with/without time
- Error: Invalid formats, missing brackets, partial timestamps

*Status:* ✅ Complete - 17 tests, all passing

*** DONE Test chime--timestamp-within-interval-p
:PROPERTIES:
:PRIORITY: A
:TIER: 1
:END:

*Why:* The "should we notify NOW?" decision. Critical timing logic.

*Risk:*
- Off-by-one errors
- Boundary conditions around notification times
- Incorrect interval calculations
- Missing notifications at exact times

*Test Coverage:*
- Normal: Events at various intervals (5 min, 1 hour, etc.)
- Boundary: Exactly at notification time, 0 minutes, very large intervals
- Error: Negative intervals, past events, invalid timestamps

*Status:* ✅ Complete - 17 tests, all passing

*** DONE Test chime--notifications
:PROPERTIES:
:PRIORITY: A
:TIER: 1
:END:

*Why:* Calculates which notifications should fire for an event. Combines alert times with event times.

*Risk:*
- Missing notifications
- Duplicate notifications
- Incorrect intervals
- Not respecting per-event CHIME_NOTIFY_BEFORE property
- Wrong interaction between global and per-event settings

*Test Coverage:*
- Normal: Single alert time, multiple alert times, per-event overrides
- Boundary: Alert at event time (0 minutes), very early alerts
- Error: Invalid alert times, missing properties, conflicting settings

*Status:* ✅ Complete - 10 tests, all passing, no bugs found

*** DONE Test chime--check-event
:PROPERTIES:
:PRIORITY: A
:TIER: 1
:END:

*Why:* Processes single event and returns notification list. Main business logic.

*Risk:*
- Logic errors combining filtering and time checks
- Missing edge cases in event processing
- Incorrect event data extraction
- Filtering interactions

*Test Coverage:*
- Normal: Valid events with various configurations
- Boundary: Events at exact notification time, multiple timestamps
- Error: Malformed events, missing required fields

*Status:* ✅ Complete - 7 tests, all passing, no bugs found

** TIER 2: Key Features (Should Test)

*** DONE Test chime--update-modeline
:PROPERTIES:
:PRIORITY: B
:TIER: 2
:END:

*Why:* New feature. Calculates soonest event within lookahead window.

*Risk:*
- Wrong event shown
- Returns nil when should show event
- Not updating when events change
- Lookahead window calculation errors
- Format string issues

*Test Coverage:*
- Normal: Single event, multiple events, events outside window
- Boundary: Event exactly at lookahead boundary, 0 lookahead
- Error: No events, all events outside window, malformed events

*Status:* ✅ Complete - 8 tests, all passing, no bugs found

*** DONE Test chime--notify
:PROPERTIES:
:PRIORITY: B
:TIER: 2
:END:

*Why:* Actually sends notifications and plays sound. User-facing.

*Risk:*
- Sound file not found
- Sound file corrupted
- Notification failures
- Error handling doesn't prevent notification display

*Test Coverage:*
- Normal: Valid sound file, notification with sound enabled
- Boundary: Sound disabled, custom sound file
- Error: Missing sound file, invalid file path, permission errors

*Status:* ✅ Complete - 8 tests, all passing, no bugs found

*** DONE Test chime--notification-text
:PROPERTIES:
:PRIORITY: B
:TIER: 2
:END:

*Why:* Formats notification messages. User sees this directly.

*Risk:*
- Formatting errors
- Edge cases in time display
- Unicode/special character handling
- Very long event titles

*Test Coverage:*
- Normal: Standard event with title and time
- Boundary: Very long titles, titles with special chars, minimal data
- Error: Missing event data, malformed time intervals

*Status:* ✅ Complete - 11 tests, all passing, no bugs found

*** DONE Test chime--time-left
:PROPERTIES:
:PRIORITY: B
:TIER: 2
:END:

*Why:* Formats "in X minutes/hours" text. User-visible.

*Risk:*
- Plural/singular errors
- Formatting edge cases (0 minutes, "right now")
- Very large time values
- Negative times

*Test Coverage:*
- Normal: Various time intervals (seconds, minutes, hours, days)
- Boundary: 0 seconds, 1 minute, 60 minutes, 24 hours
- Error: Negative times, extremely large values

*Status:* ✅ Complete - 17 tests, all passing, no bugs found

** TIER 3: Filtering (Good to Test)

*** DONE Test chime--apply-whitelist
:PROPERTIES:
:PRIORITY: C
:TIER: 3
:END:

*Why:* Filters events by keyword/tag whitelist.

*Risk:*
- Filtering out valid events
- Letting through invalid events
- Interaction between keyword and tag filters

*Test Coverage:*
- Normal: Valid whitelist with matching/non-matching events
- Boundary: Empty whitelist (nil), single item, many items
- Error: Invalid whitelist format, malformed events

*Status:* ✅ Complete - 9 tests, all passing, no bugs found

*** DONE Test chime--apply-blacklist
:PROPERTIES:
:PRIORITY: C
:TIER: 3
:END:

*Why:* Filters events by keyword/tag blacklist.

*Risk:*
- Filtering out valid events
- Letting through invalid events
- Interaction with whitelist

*Test Coverage:*
- Normal: Valid blacklist with matching/non-matching events
- Boundary: Empty blacklist, single item, many items
- Error: Invalid blacklist format, malformed events

*Status:* ✅ Complete - 10 tests, all passing, no bugs found

*** DONE Test chime--extract-time
:PROPERTIES:
:PRIORITY: C
:TIER: 3
:END:

*Why:* Extracts SCHEDULED/DEADLINE/timestamp from org entry.

*Risk:*
- Missing timestamps
- Wrong priority (SCHEDULED vs DEADLINE vs plain)
- Not handling multiple timestamps correctly

*Test Coverage:*
- Normal: Events with SCHEDULED, DEADLINE, plain timestamps
- Boundary: Multiple timestamps, conflicting times
- Error: No timestamps, malformed org entries

*Status:* ✅ Complete - 12 tests, all passing, no bugs found

* Methods Skipped

These methods are either trivial, covered by higher-level tests, or difficult to unit test meaningfully.

** SKIP chime--extract-title
*Reason:* Simple text extraction from org entry. Covered by integration tests. Low risk.

** SKIP chime--gather-info
*Reason:* Simple aggregator function that calls other functions. Testing the individual functions provides sufficient coverage.

** SKIP chime--get-tags
*Reason:* Trivial property getter. One-liner wrapper around org-entry-get.

** SKIP chime--time=
*Reason:* Trivial time comparison helper. Low complexity, low risk.

** SKIP chime--today
*Reason:* Simple wrapper around time-to-days. Trivial.

** SKIP chime--retrieve-events
*Reason:* Complex org-agenda integration using async. Very difficult to unit test. Better tested via integration tests.

** SKIP chime--check-events
*Reason:* Already well-covered by existing integration tests (chime-tests.el). Orchestration function that calls testable components.

** SKIP Day-wide event functions
*Functions:* =chime-current-time-is-day-wide-time=, =chime-day-wide-notifications=, =chime-display-as-day-wide-event=, =chime-event-has-any-day-wide-timestamp=, =chime-event-has-any-passed-time=, =chime--day-wide-notification-text=

*Reason:* Edge case functionality with lower priority. Existing integration tests provide some coverage.

** SKIP Mode management functions
*Functions:* =chime-mode=, =chime--start=, =chime--stop=, =chime-check=

*Reason:* Integration test territory. Requires full Emacs environment. Difficult to meaningfully unit test.