Skip to content
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

e2e test for background error telemetry #8717

Merged
merged 7 commits into from
Jun 28, 2024
Merged

e2e test for background error telemetry #8717

merged 7 commits into from
Jun 28, 2024

Conversation

fungairino
Copy link
Collaborator

@fungairino fungairino commented Jun 27, 2024

What does this PR do?

  • This ensures we don't break error reporting that is emitted in the background script

Future Work

  • Note the Datadog issue linked in the PR. We are waiting to see if there's a way to trigger flushing the metrics.

Checklist

  • Added jest or playwright tests and/or storybook stories

For more information on our expectations for the PR process, see the
code review principles doc

@fungairino fungairino changed the title e2e background e2e test for background error telemetry Jun 27, 2024
@fungairino fungairino requested a review from mnholtz June 27, 2024 21:23
Copy link

codecov bot commented Jun 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.07%. Comparing base (c32e86f) to head (9454929).
Report is 63 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8717      +/-   ##
==========================================
+ Coverage   73.69%   74.07%   +0.37%     
==========================================
  Files        1344     1342       -2     
  Lines       41566    41387     -179     
  Branches     7775     7753      -22     
==========================================
+ Hits        30633    30658      +25     
+ Misses      10933    10729     -204     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Jun 27, 2024

Playwright test results

passed  82 passed
skipped  2 skipped

Details

report  Open report ↗︎
stats  84 tests across 29 suites
duration  12 minutes, 10 seconds
commit  9454929

Skipped tests

chrome › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options
edge › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options

@@ -26,54 +26,68 @@ async function waitForBackgroundPageRequest(
return offscreenPage?.waitForRequest(errorServiceEndpoint);
}

async function getSentErrors(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
async function getSentErrors(
async function getForwardedErrors(

or

Suggested change
async function getSentErrors(
async function getErrorsFromRequest(

I don't know about anyone else, but my brain lumps "getSent" together instead of "sentErrors" together

@@ -82,6 +96,100 @@ test("can report application error to telemetry service", async ({
message: expect.any(String),
kind: expect.any(String),
}),
// Stack and message are duplicated
Copy link
Collaborator

@mnholtz mnholtz Jun 27, 2024

Choose a reason for hiding this comment

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

Not sure what the intended goal with this one is. Is this a bug? Does message == stack? If so, are we missing the stack or the message?

I could at least see a comment like this being better suited for where we add the error message in the first place as opposed to a test, e.g.

const errorMessage = getErrorMessage(error);

But at best I'd like to clarify if this is a problem or not, and create a ticket if so.

context,
extensionId,
}) => {
const errorServiceEndpoint = "https://browser-intake-datadoghq.com/api/v2/*";
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: opportunity to extract errorServiceEndpoint


await test.step("Mock the registry endpoint to return a bad response, and mock errorService calls", async () => {
await context.route(
"https://app.pixiebrix.com/api/registry/bricks/",
Copy link
Collaborator

@mnholtz mnholtz Jun 27, 2024

Choose a reason for hiding this comment

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

I would extract this endpoint into a constant called something like endpointCalledFromServiceWorker to clarify what makes this test different from the first, and how this test covers the service worker case.

) {
// TODO: due to Datadog SDK implementation, it will take ~30 seconds for the
// request to be sent. We should figure out a way to induce the request to be sent sooner.
// See this datadog support request: https://help.datadoghq.com/hc/en-us/requests/1754158
Copy link
Collaborator

Choose a reason for hiding this comment

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

❤️ thanks again to reaching out to support

);
});

await page.goto(getBaseExtensionConsoleUrl(extensionId));
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be too early to extract at 2x usages, but maybe if we end up adding a third test with this shape, we should extract this logic into something reusable.

@fungairino fungairino merged commit 3acbe9e into main Jun 28, 2024
18 checks passed
@fungairino fungairino deleted the e2e-background branch June 28, 2024 22:53
twschiller pushed a commit that referenced this pull request Jun 30, 2024
* e2e test for background error telemetry

* pr feedback

* rename

* fix error not being emitted in bg
@grahamlangford grahamlangford added this to the 2.0.4 milestone Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

4 participants