- Notifications
You must be signed in to change notification settings - Fork928
chore(coderd/notifications): expand golden file testing for notifications#15032
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…otification body template
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
coderd/notifications/testdata/rendered-templates/TemplateTemplateDeleted.json.golden OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
coderd/notifications/testdata/rendered-templates/TemplateUserAccountSuspended.json.golden OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
coderd/notifications/dispatch/testdata/rendered-templates/TemplateWorkspaceDeleted.golden.html OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
coderd/notifications/dispatch/testdata/rendered-templates/TemplateWorkspaceDeleted.golden.html OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
coderd/notifications/dispatch/testdata/rendered-templates/TemplateWorkspaceDeleted.golden.html OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
…for the golden file test
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.
Nice work on increasing the test coverage. I didn't look too closely at the actual rendered output as I lack a bit of context, but perhaps@dannykopping or@mtojek has more thoughts on that.
coderd/database/migrations/000263_consistent_notification_initiator_naming.down.sqlShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
coderd/notifications/dispatch/testdata/rendered-templates/TemplateWorkspaceDeleted.golden.html OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
coderd/notifications/testdata/rendered-templates/smtp/TemplateTemplateDeleted.html.goldenShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
I believe this is in a good shape 👍 Left a couple of nit-picks to take a look & reply. Feel free to ignore them or postpone for later!
Nice job, Sas 👍 👍
Uh oh!
There was an error while loading.Please reload this page.
} | ||
func normalizeGoldenWebhook(content []byte) []byte { | ||
const constantUUID = "00000000-0000-0000-0000-000000000000" |
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.
{ "_version": "1.1", "msg_id": "00000000-0000-0000-0000-000000000000", "payload": { "_version": "1.1", "notification_name": "Workspace Autobuild Failed", "notification_template_id": "00000000-0000-0000-0000-000000000000", "user_id": "00000000-0000-0000-0000-000000000000",
Ok, I know why you did this but I'm wondering if there is a way to keep stable uuids written to the golden file 🤔. It could help find out why some labels change, and prevent bugs in the future.
PS. If this is difficult->impossible, it can be postponed for later (add FIXME label).
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.
keep stable uuids written to the golden file
What does stable mean in this context?
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.
I mean, we could replace dynamic UUIDs with some const/known values rather than zeros. For instance:
user_id ->ceb6824e-7fe1-4000-aad9-b80bb141560a
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.
from your comment below I infer that stable means constant and applies to thenotification_template_id
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.
ACK. Thanks
Uh oh!
There was an error while loading.Please reload this page.
coderd/notifications/testdata/rendered-templates/smtp/TemplateTemplateDeleted.html.goldenShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Content-Transfer-Encoding: quoted-printable | ||
Content-Type: text/plain; charset=UTF-8 | ||
Hi Bobby, |
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.
I didn't know that we could render two content-types. Curious, if we can store golden results in separate files?
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.
Curious, if we can store golden results in separate files?
The premise that I adopted for this PR was one of integration testing. This output is meant to represent exactly what would have been sent to the customer. I did not make them render in the same file. This is how it has been. This is what we currently send to customers.
To separate them would, in my opinion, introduce artificial opportunity for drift from actual behaviour. These tests are most reliable if they not only mimick, but actually dogfood the actual system's behaviour.
If you'd like me to change it to be multiple files, I would be happy to. Would you mind helping me understand the benefit though?
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.
Ok! If there are no benefits, then let's leave them as is. Maybe replace.html.golden
with.smtp.golden
as this is not just HTML file, but also Plaintext and headers.
Would you mind helping me understand the benefit though?
My original intention was keep HTML in.html.golden
files, and Plaintext in.txt.golden
"payload": { | ||
"_version": "1.1", | ||
"notification_name": "User account activated", | ||
"notification_template_id": "00000000-0000-0000-0000-000000000000", |
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.
One more comment:
Can we keepnotification_template_id
as is, and not zero it? These values are const/stable.
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.
Let's get this large PR merged, nit-picks can be done in a follow-up.
208ed1e
intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
This PR aims toclose#14913.
It expands the golden files for the notifier to include the entire payload serialised as JSON.