Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Validate event properties #9

Merged
merged 14 commits into from
Oct 30, 2024
Merged

Validate event properties #9

merged 14 commits into from
Oct 30, 2024

Conversation

n3f
Copy link
Collaborator

@n3f n3f commented Oct 24, 2024

Fixes https://github.com/Automattic/gold/issues/525

Changes proposed in this Pull Request

  • Add event validation.
  • Fixes flaky tests (github action didn't like caching strategy)
  • Document/add an alternative testing strategy.

Testing instructions

  • Setup with wp-env (e.g. npm i && composer install && npx wp-env start)
  • npm run test

@n3f n3f mentioned this pull request Oct 24, 2024
@n3f
Copy link
Collaborator Author

n3f commented Oct 24, 2024

I guess the tests are flaky...

@n3f n3f self-assigned this Oct 29, 2024
with:
path: ${{ steps.wp_env_dir.outputs.WPENV_DIR }}
key: ${{ runner.os }}-${{ hashFiles('**/.wp-env.json') }}
# - name: Cache wp-env
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@n3f Is that change necessary? If so, should it be removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the builds were failing with this in for some reason. I'm not sure if it created a timeout or if the cache was bad or what. I left the comment in because it seems like it should work (and it did work for several builds - then it broke for several). Since I removed it, all the builds have been working correctly.

@@ -120,7 +126,7 @@ public static function login_failure( string $username, \WP_Error $error ) {
$failure_reason = null;
}
$properties = array(
'$user_id' => $attempted_user->ID ? $attempted_user->ID : null,
'$user_id' => (string) $attempted_user->ID ?? null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't $attempted_user->ID ?? null on (string)?
I am always confused with that...

Copy link
Collaborator

@millerf millerf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code LGTM and tests are passing 👍

Copy link

Code Coverage

Package Line Rate Complexity Health
inc/abuse-decisions-actions.php 0% 22
inc/abuse-decisions.php 0% 19
inc/rest-api-webhooks.php 0% 5
inc/sift-object-validator.php 91% 117
inc/tracking-js.php 0% 4
inc/wc-settings-tab.php 0% 14
inc/woocommerce-actions.php 70% 73
index.php 0% 0
sift-decisions.php 0% 9
Summary 58% (617 / 1058) 263

@n3f n3f merged commit ec68f9b into trunk Oct 30, 2024
12 checks passed
@n3f n3f deleted the events/validate branch October 30, 2024 16:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants