Settings form: round-trip coverage, stop calling GitHub on every save, drop dead settings - #160
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three changes to the plugin settings form, each found by the one before it.
Round-trip coverage (e2e)
A setting is wired up in three separate places —
initData(),readInputData()andexecute()— and omitting it from any one loses the value in silence:getData()returns null,updateSetting()writes the null, and the field is empty next time the form opens. Nothing fails and nothing logs.The new spec derives its field list from what the form renders rather than hard-coding one, so a setting added without being wired up fails without anyone remembering to extend the test. It writes distinctive values before saving — saving unchanged proves little, since seven settings are empty in the test dataset and "empty survived" holds either way. Verified by removing
badgeHeightfromreadUserVars: it fails naming the field.Saving no longer calls GitHub every time
SettingsForm::execute()calledvalidateRegisterFileExists()unconditionally, so every save — a badge height, a dashboard toggle — blocked on an unauthenticated GitHub request forregister.csv, against a 60/hour per-IP limit. It now runs only when the organisation or repository actually changed. Verified by instrumenting the method: four saves with the register untouched make no request; changing the organisation still makes one.Two dead settings removed
codecheckApiEndpointandcodecheckApiKeywere handled in all three lifecycle methods and written on every save, butsettings.tplrenders no field for either and nothing reads them. Added in db25e55 as scaffolding, never wired up.Neither is repurposed for the one hardcoded CODECHECK endpoint (the venues list) — that deserves a name saying what it is, and there is no authenticated CODECHECK API for a key to belong to.
API routing coverage
ApiEndpointandCodecheckRoleArrayhad no coverage. Tests pin down which route and method map to which handler and role set, and the recursive role flattening including the admin ⊂ edit ⊂ read nesting the handler builds.ApiEndpointis also made total: a method with no entries raisedUndefined array key, and reading an unresolved endpoint threwTyped property … must not be accessed before initialization. That is a class-level fix, not a reachable one — OJS's own router answers routes and methods this table does not cover before the handler runs, verified against a running instance.Stacked on #159. Suite: 131 PHPUnit (none skipped), 48 component, 13 e2e.