-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[One Workflow] fail Scout approval tests on stale approved step/trigger rows #260939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -46,6 +46,8 @@ apiTest.describe( | |||||
| expect(response.body.steps).toBeDefined(); | ||||||
| expect(Array.isArray(response.body.steps)).toBe(true); | ||||||
|
|
||||||
| // Registered ⊆ approved: every step returned by the server must be listed in the fixture | ||||||
| // with a matching handler hash (catches new or changed handlers not yet approved). | ||||||
| for (const step of response.body.steps) { | ||||||
| const approvedStep = APPROVED_STEP_DEFINITIONS.find(({ id }) => id === step.id); | ||||||
|
|
||||||
|
|
@@ -57,6 +59,22 @@ apiTest.describe( | |||||
| message: `Step "${step.id}" has an invalid handler hash`, | ||||||
| }).toBe(approvedStep?.handlerHash); | ||||||
| } | ||||||
|
|
||||||
| // Approved ⊆ registered: every fixture row must still exist on the server with the same hash | ||||||
| // (catches stale rows left after a step was removed or the list was not updated). | ||||||
| for (const approved of APPROVED_STEP_DEFINITIONS) { | ||||||
| const registeredStep = response.body.steps.find( | ||||||
| (step: { id: string; handlerHash: string }) => step.id === approved.id | ||||||
| ); | ||||||
|
Comment on lines
+65
to
+68
|
||||||
|
|
||||||
| expect(registeredStep, { | ||||||
| message: `Approved list contains stale entry "${approved.id}" that is not registered`, | ||||||
| }).toBeDefined(); | ||||||
|
|
||||||
| expect(registeredStep?.handlerHash, { | ||||||
|
||||||
| expect(registeredStep?.handlerHash, { | |
| expect(registeredStep!.handlerHash, { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,8 @@ apiTest.describe( | |
| ).toBe(true); | ||
| expect(Array.isArray(response.body.triggers)).toBe(true); | ||
|
|
||
| // Registered ⊆ approved: every trigger returned by the server must be listed in the fixture | ||
| // with a matching schema hash (catches new or changed schemas not yet approved). | ||
| for (const trigger of response.body.triggers) { | ||
| const approvedTrigger = APPROVED_TRIGGER_DEFINITIONS.find(({ id }) => id === trigger.id); | ||
|
|
||
|
|
@@ -59,6 +61,22 @@ apiTest.describe( | |
| message: `Trigger "${trigger.id}" has an invalid schema hash`, | ||
| }).toBe(trigger.schemaHash); | ||
| } | ||
|
Comment on lines
53
to
63
|
||
|
|
||
| // Approved ⊆ registered: every fixture row must still exist on the server with the same hash | ||
| // (catches stale rows left after a trigger was removed or the list was not updated). | ||
| for (const approved of APPROVED_TRIGGER_DEFINITIONS) { | ||
| const registeredTrigger = response.body.triggers.find( | ||
| (trigger: { id: string; schemaHash: string }) => trigger.id === approved.id | ||
| ); | ||
|
Comment on lines
+67
to
+70
|
||
|
|
||
| expect(registeredTrigger, { | ||
| message: `Approved list contains stale entry "${approved.id}" that is not registered`, | ||
| }).toBeDefined(); | ||
|
|
||
| expect(registeredTrigger?.schemaHash, { | ||
| message: `Approved entry "${approved.id}" has an invalid schema hash (does not match registered trigger)`, | ||
| }).toBe(approved.schemaHash); | ||
|
Comment on lines
+72
to
+78
|
||
| } | ||
| } | ||
| ); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with triggers, the two loops do repeated
.find(...)lookups, leading to O(n²) behavior. Consider indexingresponse.body.steps(and/orAPPROVED_STEP_DEFINITIONS) into aMaponce to make both the forward and reverse checks O(n) and reduce duplicated lookup logic.