Skip to content

test(frontend): await diagram data before search assertion (deflake main) - #738

Open
seonghobae wants to merge 3 commits into
mainfrom
fix/flaky-diagram-search-waitfor
Open

test(frontend): await diagram data before search assertion (deflake main)#738
seonghobae wants to merge 3 commits into
mainfrom
fix/flaky-diagram-search-waitfor

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

Summary

The test navigates dashboard, project, and diagram states including empty/search branches in frontend/src/App.coverage.test.tsx is flaky on main: it fires the diagram search (fireEvent.change on 다이어그램 검색) before the async snapshot list has loaded, so the assertion intermittently sees the empty state instead of search results. This has been failing the frontend job on unrelated PRs — e.g. the docs-only #735.

Fix

Cherry-pick of the single test hunk from commit 06a7eae on #700 (bolt/optimize-handle-lookup-17383827529551263442): await waitFor for the empty-state text (아직 다이어그램 스냅샷이 없습니다...) to disappear before firing the search. waitFor was already imported.

#700 is still open with checks stalled, so this lands the deflake standalone to stop the queue-wide flake; #700's own copy of the hunk will no-op on merge.

🤖 Generated with Claude Code

Cherry-pick of the App.coverage.test.tsx fix from 06a7eae (PR #700).
The diagram search fired before the async snapshot list loaded,
making this test flaky on main and failing CI on unrelated PRs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2e668f03-a947-48c8-8843-59eea5b6cfee

📥 Commits

Reviewing files that changed from the base of the PR and between 72afe6d and 60b482d.

📒 Files selected for processing (1)
  • frontend/src/App.coverage.test.tsx

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae enabled auto-merge (squash) August 4, 2026 05:47
@seonghobae
seonghobae marked this pull request as draft August 4, 2026 06:21
auto-merge was automatically disabled August 4, 2026 06:21

Pull request was converted to draft

@seonghobae
seonghobae marked this pull request as ready for review August 4, 2026 06:21
seonghobae and others added 2 commits August 4, 2026 16:27
…mer tests

Same race as the diagram-search flake: four tests click the first
열기 button immediately after navigating to 다이어그램, before the
async snapshot list has rendered. Wait for the buttons (real timers)
before enabling fake timers, matching the guard already used elsewhere
in this file.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@seonghobae
seonghobae enabled auto-merge (squash) August 4, 2026 08:19

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

Please review exact current head 60b482da234158ab0aca53a5f4a4c1da46127fcc. The single test-only change waits for snapshot-list readiness before applying diagram search. Current-head CI, Security Scan, and Semgrep are green; submit the normal review verdict only if no finding remains.

Copy link
Copy Markdown
Collaborator Author

@opencode-agent Please review exact current head 60b482da234158ab0aca53a5f4a4c1da46127fcc. Verify the one-line asynchronous readiness wait is deterministic, test-only, and does not weaken assertions. Current-head repository checks are green; submit APPROVE only if no blocking finding remains.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

expected='60b482da234158ab0aca53a5f4a4c1da46127fcc'
actual="$(git rev-parse HEAD)"
printf 'HEAD=%s\nEXPECTED=%s\n' "$actual" "$expected"
if [ "$actual" != "$expected" ]; then
  echo 'ERROR: checked-out HEAD does not match the requested commit' >&2
  exit 1
fi

echo '--- changed files and diff against first parent ---'
git diff --stat HEAD^ HEAD
git diff --find-renames --unified=80 HEAD^ HEAD -- frontend/src/App.coverage.test.tsx

echo '--- AST outline: affected test file ---'
ast-grep outline frontend/src/App.coverage.test.tsx --items all --view expanded

echo '--- empty-state and diagram search references ---'
rg -n -C 4 --glob '*.{ts,tsx}' \
  '아직 다이어그램 스냅샷이 없습니다|다이어그램 검색' frontend

Length of output: 20002


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- commit metadata ---'
git show -s --format='commit=%H%nparent=%P%nsubject=%s%nbody=%b' HEAD

echo '--- diagram-search test: parent versus current ---'
for revision in HEAD^ HEAD; do
  echo "### $revision: frontend/src/App.coverage.test.tsx Lines 315-342"
  git show "${revision}:frontend/src/App.coverage.test.tsx" | sed -n '315,342p'
done

echo '--- current changed test blocks ---'
sed -n '585,790p' frontend/src/App.coverage.test.tsx

echo '--- test setup and async API mocks ---'
sed -n '248,315p' frontend/src/App.coverage.test.tsx

echo '--- PR metadata ---'
gh pr view 738 --repo ContextualWisdomLab/pg-erd-cloud \
  --json number,title,baseRefOid,headRefOid,commits \
  --jq '{number,title,baseRefOid,headRefOid,commits:[.commits[]|{oid:.oid,messageHeadline:.messageHeadline}]}'

Length of output: 17183


🏁 Script executed:

#!/bin/bash
set -euo pipefail

base='72afe6db712b145baaba084f64a1ff4fb36d9fd0'
head='60b482da234158ab0aca53a5f4a4c1da46127fcc'

echo '--- complete PR diff: base to requested head ---'
git diff --check "$base" "$head"
git diff --stat "$base" "$head"
git diff --unified=30 "$base" "$head" -- frontend/src/App.coverage.test.tsx

echo '--- readiness-guard pattern in the coverage test ---'
rg -n -C 2 --glob 'App.coverage.test.tsx' \
  "waitFor\\(\\(\\) => expect\\(screen\\.getAllByRole\\('button', \\{ name: '열기' \\}\\)\\.length\\)\\.toBeGreaterThan\\(0\\)\\)" \
  frontend/src

echo '--- current PR check summary ---'
gh pr checks 738 --repo ContextualWisdomLab/pg-erd-cloud

Length of output: 20630


@seonghobae Reviewed exact head 60b482da234158ab0aca53a5f4a4c1da46127fcc.

No findings remain. The PR waits for snapshot-list readiness before the diagram search. It also applies the same guard before fake timers in related diagram-opening tests. The complete base-to-head diff only changes frontend/src/App.coverage.test.tsx. Current frontend, security, Semgrep, dependency, and static-analysis checks pass.

[approve]

You are interacting with an AI system.

Copy link
Copy Markdown
Collaborator Author

@cwl-noema-review Please independently review exact current head 60b482da234158ab0aca53a5f4a4c1da46127fcc after checks. Confirm the test waits for the intended snapshot-list state transition without hiding a product defect, and submit APPROVE only if no blocker remains.

@seonghobae
seonghobae marked this pull request as draft August 4, 2026 09:50
auto-merge was automatically disabled August 4, 2026 09:50

Pull request was converted to draft

@seonghobae
seonghobae marked this pull request as ready for review August 4, 2026 09:50
@seonghobae
seonghobae enabled auto-merge (squash) August 4, 2026 09:51

Copy link
Copy Markdown
Collaborator Author

@opencode-agent Please review exact head 60b482da234158ab0aca53a5f4a4c1da46127fcc. Repository CI, Security Scan, and Semgrep are green. Verify all four async readiness waits are deterministic, test-only, and preserve the original assertions; submit APPROVE only if no blocking finding remains.

Copy link
Copy Markdown
Collaborator Author

@cwl-noema-review Please independently review exact head 60b482da234158ab0aca53a5f4a4c1da46127fcc. Confirm the test-only deflake does not weaken behavior assertions; submit APPROVE only if no blocker remains.

Copy link
Copy Markdown
Collaborator Author

@opencode-agent @cwl-noema-review Please independently review exact current head 60b482da234158ab0aca53a5f4a4c1da46127fcc. Current-head CI, Security Scan, and SAST Semgrep are successful; no review thread is unresolved. Verify the one-file test-only change waits for async diagram/snapshot controls before search, polling, auto-layout, and stale-response interactions without weakening assertions or adding arbitrary sleeps. Submit APPROVE only for this exact head if no blocker remains.

Copy link
Copy Markdown
Collaborator Author

@opencode-agent @cwl-noema-review Please perform a fresh independent review of current head 60b482da234158ab0aca53a5f4a4c1da46127fcc. Repository CI, Security Scan, Semgrep, and CodeRabbit are green; no unresolved inline threads remain. This is the bounded standalone deflake extracted from #700.

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review
@cwl-noema-review
@opencode-agent

Please review the exact live head only. Verify the frontend flake is removed by waiting for the asynchronous diagram snapshot state before search assertions, without weakening the assertion, adding sleeps, or changing production behavior. Require current frontend typecheck, complete tests and 100% configured coverage, production build, security gates, and zero unresolved actionable threads. Review only; do not update the branch, merge, release, or alter protections.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/pg-erd-cloud'
pr='738'

echo '--- live pull request metadata ---'
gh pr view "$pr" --repo "$repo" \
  --json number,title,state,isDraft,baseRefOid,headRefOid,mergeStateStatus,reviewDecision \
  --jq '{number,title,state,isDraft,baseRefOid,headRefOid,mergeStateStatus,reviewDecision}'

live_head="$(gh pr view "$pr" --repo "$repo" --json headRefOid --jq .headRefOid)"
local_head="$(git rev-parse HEAD)"
printf '\n--- head verification ---\nlive_head=%s\nchecked_out_head=%s\n' "$live_head" "$local_head"
if [ "$live_head" != "$local_head" ]; then
  echo 'ERROR: checked-out repository does not match the live PR head.' >&2
  exit 2
fi

base="$(gh pr view "$pr" --repo "$repo" --json baseRefOid --jq .baseRefOid)"
echo '--- complete base-to-head diff summary ---'
git diff --check "$base" "$live_head"
git diff --stat "$base" "$live_head"
git diff --name-status "$base" "$live_head"

echo '--- affected file outline ---'
ast-grep outline frontend/src/App.coverage.test.tsx --items all --view expanded

echo '--- complete pull request diff ---'
git diff --find-renames --unified=40 "$base" "$live_head" -- frontend/src/App.coverage.test.tsx

echo '--- async readiness, search, and assertion references ---'
rg -n -C 5 --glob 'App.coverage.test.tsx' \
  "waitFor\(|다이어그램 검색|아직 다이어그램 스냅샷이 없습니다|fireEvent\.change|expect\(" \
  frontend/src/App.coverage.test.tsx

echo '--- current check results ---'
gh pr checks "$pr" --repo "$repo" --json name,state,link,workflow \
  --jq '.[] | {name,state,workflow,link}'

echo '--- review threads ---'
gh api graphql -F owner='ContextualWisdomLab' -F name='pg-erd-cloud' -F number="$pr" -f query='
query($owner: String!, $name: String!, $number: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $number) {
      reviewThreads(first: 100) {
        nodes {
          isResolved
          isOutdated
          path
          line
          comments(first: 10) {
            nodes { author { login } body }
          }
        }
      }
    }
  }
}' --jq '.data.repository.pullRequest.reviewThreads.nodes[] |
  select(.isResolved == false) |
  {isOutdated,path,line,comments:[.comments.nodes[]|{author:.author.login,body:.body}]}'

Length of output: 46211


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/pg-erd-cloud'
pr='738'
head='60b482da234158ab0aca53a5f4a4c1da46127fcc'

echo '--- frontend workflow job steps and conclusions ---'
gh run view 30888424270 --repo "$repo" --json jobs \
  --jq '.jobs[] | select(.name == "frontend") | {name,conclusion,startedAt,completedAt,steps:[.steps[]|{name,conclusion}]}'

echo '--- locate frontend CI configuration and package manifests ---'
fd -HI -t f '^(package\.json|pnpm-lock\.yaml|yarn\.lock|package-lock\.json|.*\.(yml|yaml))$' . \
  | sed -n '1,240p'

echo '--- frontend package test, typecheck, coverage, and build scripts ---'
if [ -f frontend/package.json ]; then
  jq '{scripts,devDependencies,dependencies}' frontend/package.json
fi

echo '--- workflow commands that invoke frontend validation ---'
rg -n -i -C 4 \
  '(frontend|typecheck|type-check|coverage|vitest|test:|build)' \
  .github 2>/dev/null || true

echo '--- asynchronous snapshot fixture and surrounding test setup ---'
sed -n '248,310p' frontend/src/App.coverage.test.tsx

echo '--- exact changed test block at current head ---'
sed -n '315,345p' frontend/src/App.coverage.test.tsx

echo '--- confirm the live head has not changed during review ---'
current_live_head="$(gh pr view "$pr" --repo "$repo" --json headRefOid --jq .headRefOid)"
printf 'expected=%s\nlive_now=%s\n' "$head" "$current_live_head"
test "$current_live_head" = "$head"

Length of output: 11561


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/pg-erd-cloud'
pr='738'
head='60b482da234158ab0aca53a5f4a4c1da46127fcc'
run='30888422764'

echo '--- coverage-evidence job steps and conclusions ---'
gh run view "$run" --repo "$repo" --json jobs \
  --jq '.jobs[] | select(.name == "coverage-evidence") |
    {name,conclusion,startedAt,completedAt,steps:[.steps[]|{name,conclusion}]}'

echo '--- OpenCode Review workflow coverage references ---'
gh api "repos/$repo/actions/workflows" --paginate \
  --jq '.workflows[] | select(.name == "OpenCode Review") | {id,path,name}' \
  > /tmp/opencode-workflow.json
cat /tmp/opencode-workflow.json

workflow_path="$(jq -r .path /tmp/opencode-workflow.json)"
if [ -n "$workflow_path" ] && [ "$workflow_path" != "null" ]; then
  echo "--- $workflow_path coverage configuration ---"
  git show "HEAD:$workflow_path" | grep -n -i -C 5 'coverage\|threshold\|100' || true
fi

echo '--- coverage configuration files ---'
fd -HI -t f . frontend \
  | grep -Ei '(vitest|vite|coverage|test).*\.(ts|tsx|js|mjs|cjs|json)$' \
  | sort
for file in $(fd -HI -t f . frontend | grep -Ei '(vitest|vite|coverage|test).*\.(ts|tsx|js|mjs|cjs|json)$' | sort); do
  if [ "$(basename "$file")" != "App.coverage.test.tsx" ]; then
    echo "--- $file ---"
    sed -n '1,220p' "$file"
  fi
done

echo '--- current PR check state for coverage evidence ---'
gh pr checks "$pr" --repo "$repo" --json name,state,workflow \
  --jq '.[] | select(.name == "coverage-evidence" or .name == "frontend") | {name,state,workflow}'

echo '--- final live-head verification ---'
live_head="$(gh pr view "$pr" --repo "$repo" --json headRefOid --jq .headRefOid)"
printf 'reviewed=%s\nlive_now=%s\n' "$head" "$live_head"
test "$live_head" = "$head"

Length of output: 2241


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/pg-erd-cloud'
pr='738'
head='60b482da234158ab0aca53a5f4a4c1da46127fcc'
job_id='91932487236'

echo '--- coverage-evidence GitHub Actions job ---'
gh api "repos/$repo/actions/jobs/$job_id" \
  --jq '{id,name,status,conclusion,started_at,completed_at,steps:[.steps[]|{name,status,conclusion,number}]}'

echo '--- coverage-evidence check-run output ---'
gh api "repos/$repo/check-runs/$job_id" \
  --jq '{id,name,status,conclusion,details_url,output:{title:.output.title,summary:.output.summary,text:.output.text}}'

echo '--- local frontend coverage configuration ---'
fd -HI -t f . frontend | grep -Ei '(vitest|vite|coverage).*\.(ts|tsx|js|mjs|cjs|json)$' | sort | while IFS= read -r file; do
  echo "--- $file ---"
  sed -n '1,240p' "$file"
done

echo '--- current relevant check states ---'
gh pr checks "$pr" --repo "$repo" --json name,state,workflow \
  --jq '.[] | select(.name == "frontend" or .name == "coverage-evidence" or .name == "dependency-review" or .name == "Semgrep OSS" or .name == "Semgrep (multi-language SAST)" or .name == "strix" or .name == "osv-scan" or .name == "trivy-fs" or .name == "Analyze (javascript-typescript)" or .name == "Analyze (python)") | {name,state,workflow}'

echo '--- final live-head verification ---'
live_head="$(gh pr view "$pr" --repo "$repo" --json headRefOid --jq .headRefOid)"
printf 'reviewed=%s\nlive_now=%s\n' "$head" "$live_head"
test "$live_head" = "$head"

Length of output: 45674


@seonghobae Review completed for exact live head 60b482da234158ab0aca53a5f4a4c1da46127fcc.

The test-only change correctly waits for the asynchronous diagram snapshot state before it changes 다이어그램 검색. It preserves both original search assertions. It adds no sleep and changes no production code. The additional readiness waits also use UI state, not elapsed time.

Frontend type checking, complete frontend tests, and the production build passed. Current security and static-analysis checks passed. No unresolved review threads were returned.

I cannot approve under the requested coverage requirement. frontend/vitest.config.ts has coverage reporters but no 100% thresholds. The successful coverage-evidence job only runs an echo command. It does not execute coverage or verify configured 100% coverage.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Collaborator Author

Exact-current-head review request for 60b482da234158ab0aca53a5f4a4c1da46127fcc. Complete CI, Security Scan, and Semgrep succeeded; there are no inline threads. Review the one-file async test deflake on this head only.

@coderabbitai review
@opencode-agent review
@cwl-noema-review review

Do not modify the branch, bypass protection, merge, tag, release, or publish.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo='ContextualWisdomLab/pg-erd-cloud'
pr='738'
expected='60b482da234158ab0aca53a5f4a4c1da46127fcc'

echo '--- live pull request metadata ---'
gh pr view "$pr" --repo "$repo" \
  --json number,state,isDraft,baseRefOid,headRefOid,mergeStateStatus,reviewDecision \
  --jq '{number,state,isDraft,baseRefOid,headRefOid,mergeStateStatus,reviewDecision}'

live_head="$(gh pr view "$pr" --repo "$repo" --json headRefOid --jq .headRefOid)"
local_head="$(git rev-parse HEAD)"
printf '\n--- head verification ---\nexpected=%s\nlive=%s\nchecked_out=%s\n' \
  "$expected" "$live_head" "$local_head"
test "$live_head" = "$expected"
test "$local_head" = "$expected"

base="$(gh pr view "$pr" --repo "$repo" --json baseRefOid --jq .baseRefOid)"
echo '--- complete base-to-head change set ---'
git diff --check "$base" "$expected"
git diff --stat "$base" "$expected"
git diff --name-status "$base" "$expected"
git diff --unified=50 "$base" "$expected" -- frontend/src/App.coverage.test.tsx

echo '--- affected test-file outline ---'
ast-grep outline frontend/src/App.coverage.test.tsx --items all --view expanded

echo '--- async test setup and changed-test context ---'
sed -n '240,360p' frontend/src/App.coverage.test.tsx
sed -n '580,800p' frontend/src/App.coverage.test.tsx

echo '--- readiness waits, search events, and relevant assertions ---'
rg -n -C 4 --glob 'App.coverage.test.tsx' \
  "waitFor\\(|다이어그램 검색|아직 다이어그램 스냅샷이 없습니다|fireEvent\\.change|expect\\(" \
  frontend/src/App.coverage.test.tsx

echo '--- current required check results ---'
gh pr checks "$pr" --repo "$repo" --json name,state,workflow,link \
  --jq '.[] | {name,state,workflow,link}'

echo '--- unresolved review threads ---'
gh api graphql -F owner='ContextualWisdomLab' -F name='pg-erd-cloud' -F number="$pr" -f query='
query($owner: String!, $name: String!, $number: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $number) {
      reviewThreads(first: 100) {
        nodes {
          isResolved
          isOutdated
          path
          line
          comments(first: 10) {
            nodes { author { login } body }
          }
        }
      }
    }
  }
}' --jq '.data.repository.pullRequest.reviewThreads.nodes[] |
  select(.isResolved == false) |
  {isOutdated,path,line,comments:[.comments.nodes[]|{author:.author.login,body:.body}]}'

echo '--- final live-head verification ---'
final_live_head="$(gh pr view "$pr" --repo "$repo" --json headRefOid --jq .headRefOid)"
printf 'reviewed=%s\nlive_now=%s\n' "$expected" "$final_live_head"
test "$final_live_head" = "$expected"

Length of output: 63169


@seonghobae Reviewed exact live head 60b482da234158ab0aca53a5f4a4c1da46127fcc.

No blocking findings remain.

The PR changes only frontend/src/App.coverage.test.tsx. The search test now waits for the asynchronous snapshot-list empty state to disappear before it changes 다이어그램 검색. The test still asserts both the no-results state and the ERD_all_2 search result.

The added readiness waits use rendered UI state. They do not use arbitrary sleeps. The change does not modify production code.

The frontend, security, Semgrep, CodeQL, and CodeRabbit checks are successful. No unresolved review threads remain.

[approve]

You are interacting with an AI system.

@opencode-agent

opencode-agent Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Queued @cwl-noema-review for PR #738 at head 60b482da234158ab0aca53a5f4a4c1da46127fcc. Central exact-name Actions artifacts are the durable dispatch ledger; existing review workflows remain authoritative for the final verdict and failure evidence.

@opencode-agent

opencode-agent Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Queued @cwl-noema-review for PR #738 at head 60b482da234158ab0aca53a5f4a4c1da46127fcc. Central exact-name Actions artifacts are the durable dispatch ledger; existing review workflows remain authoritative for the final verdict and failure evidence.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant