Skip to content

test(contact-center-insights): add delay to createAnalysis test to ensure conversation readiness#4322

Draft
angelcaamal wants to merge 3 commits into
mainfrom
fix/test-stability-create-analysis
Draft

test(contact-center-insights): add delay to createAnalysis test to ensure conversation readiness#4322
angelcaamal wants to merge 3 commits into
mainfrom
fix/test-stability-create-analysis

Conversation

@angelcaamal
Copy link
Copy Markdown
Contributor

@angelcaamal angelcaamal commented May 22, 2026

Description

This PR addresses a race condition found in the createAnalysis test. Due to the asynchronous nature of the backend ingestion process, the conversation was occasionally not fully ready to be analyzed, resulting in internal errors.

Fixes #

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

  • I have followed guidelines from CONTRIBUTING.MD and Samples Style Guide
  • Tests pass: npm test (see Testing)
  • Lint pass: npm run lint (see Style)
  • Required CI tests pass (see CI testing)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This pull request is from a branch created directly off of GoogleCloudPlatform/nodejs-docs-samples. Not a fork.
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new sample directory, and I created GitHub Actions workflow for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

Note: Any check with (dev), (experimental), or (legacy) can be ignored and should not block your PR from merging (see CI testing).

@angelcaamal angelcaamal added samples Issues that are directly related to samples. api: contactcenterinsights Issues related to the Contact Center AI Insights API. labels May 22, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a 10-second delay in the createAnalysis.test.js file to ensure conversations are ready before analysis. Feedback suggests replacing the raw setTimeout with the project's existing delay helper function to maintain consistency and leverage its built-in backoff logic.

);

console.info('Waiting for conversation to be ready for analysis...');
await new Promise(resolve => setTimeout(resolve, 10000));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Instead of using a raw setTimeout, consider using the existing delay helper function defined at the top of this file. This ensures consistency with the rest of the test file and leverages the built-in exponential backoff logic if the test retries after a failure.

Suggested change
await new Promise(resolve => setTimeout(resolve, 10000));
await delay(this.test, 10000);
References
  1. Maintain established boilerplate patterns across samples within a repository, even if it means deviating from technically optimal solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: contactcenterinsights Issues related to the Contact Center AI Insights API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant