Skip to content

Fix flaky BrowserSimulation test: async timing in ObjectForm field validation#373

Merged
hotlong merged 4 commits intocopilot/update-kernel-to-latest-versionfrom
copilot/fix-ci-pipeline-error-another-one
Feb 3, 2026
Merged

Fix flaky BrowserSimulation test: async timing in ObjectForm field validation#373
hotlong merged 4 commits intocopilot/update-kernel-to-latest-versionfrom
copilot/fix-ci-pipeline-error-another-one

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 3, 2026

The Scenario 4: Object Create Form test was failing in CI with expected 0 to be greater than 0 when checking for the Date field label. The test was racing against async form rendering (client init + schema fetch + field generation).

Changes

MockDataSource interface completion

  • Added missing findOne method required by DataSource interface

Async timing adjustments

  • Increased initial field wait from 5s → 10s to account for 500ms client init delay + async operations
  • Changed sequential field validation loop to concurrent Promise.all (reduces max wait from 35s → 10s)

Code quality

  • Extracted expectLabelToExist helper to eliminate duplication
// Before: synchronous checks that race against rendering
for (const label of fieldLabels) {
  expect(screen.queryAllByText(new RegExp(label, 'i')).length).toBeGreaterThan(0);
}

// After: concurrent async checks with proper timeout
await Promise.all(
  fieldLabels.map(label =>
    waitFor(() => expectLabelToExist(label), { timeout: 5000 })
  )
);

All changes are test-only. No production code modified.

Original prompt

引用: https://github.com/objectstack-ai/objectui/actions/runs/21622660842/job/62315046887#step:8:1


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Feb 3, 2026 9:12am
objectui-components Ready Ready Preview, Comment Feb 3, 2026 9:12am
objectui-crm-app Error Error Feb 3, 2026 9:12am

Request Review

- Add findOne method to MockDataSource
- Increase timeout for form field loading to 15 seconds
- Wrap each field label check in waitFor to handle async rendering
- Fixes "expected 0 to be greater than 0" assertion error for Date field

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
- Reduce initial timeout from 15s to 10s
- Use Promise.all to check all field labels concurrently instead of sequentially
- Improves test execution time while maintaining reliability

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
- Add expectLabelToExist helper function to reduce code duplication
- Improves readability and maintainability
- All tests still passing

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CI pipeline error in build process Fix flaky BrowserSimulation test: async timing in ObjectForm field validation Feb 3, 2026
Copilot AI requested a review from hotlong February 3, 2026 09:10
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 3, 2026

✅ All checks passed!

  • ✅ Type check passed
  • ✅ Tests passed
  • ✅ Lint check completed

@hotlong hotlong marked this pull request as ready for review February 3, 2026 09:32
Copilot AI review requested due to automatic review settings February 3, 2026 09:32
@hotlong hotlong merged commit 210b295 into copilot/update-kernel-to-latest-version Feb 3, 2026
8 of 9 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a flaky test in the CI pipeline that was failing due to race conditions in async form rendering. The test was checking for form field labels before they were fully rendered, causing intermittent failures with "expected 0 to be greater than 0" errors.

Changes:

  • Added missing findOne method to MockDataSource to complete the DataSource interface implementation
  • Increased timeout from 5s to 10s and converted sequential field checks to concurrent Promise.all for better async handling
  • Extracted expectLabelToExist helper function to eliminate code duplication

}
return { data: [] };
}
async findOne(objectName: string, id: string) {
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The findOne method signature should match the DataSource interface exactly. The interface defines id parameter as string | number, but the mock only accepts string. While this works for current tests, it could cause type errors if future tests pass numeric IDs. Consider updating the signature to match the interface.

Suggested change
async findOne(objectName: string, id: string) {
async findOne(objectName: string, id: string | number) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants