Why the editor's Run button fails for trigger functions
When Apps Script fires onEdit, it constructs an event object and passes it as the first argument. That object carries e.range, e.value, e.oldValue, e.source, and e.user. When you hit Run in the editor, Apps Script calls the function with no arguments, so e is undefined. The first time you try e.range.getRow() inside an onEdit handler, you get a TypeError on a function that works perfectly once a real edit fires.
The fix is not to add null-guards everywhere. The fix is to build a fake event that matches the shape the real trigger would send, then call your handler with it. You stay in full control of which row, which column, and which value the test uses.