-
Notifications
You must be signed in to change notification settings - Fork 0
🎨 Palette: 대시보드 'Deploy-blocking' 카드 클릭 필터 기능 추가 #1090
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
Open
seonghobae
wants to merge
5
commits into
develop
Choose a base branch
from
palette-interactive-deploy-blocking-card-12517871394529878792
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
40ab1da
🎨 Palette: 대시보드의 'Deploy-blocking' 카드를 상호작용 가능한 필터 토글로 개선
seonghobae d8bd9a0
test(dashboard): preserve blocking-card filter and focus contract
seonghobae 95fa6ed
fix(dashboard): restore blocking-card focus after render
seonghobae 75987ae
test(dashboard): execute blocking filter render behavior
seonghobae a3ab25b
🎨 Palette: 대시보드의 'Deploy-blocking' 카드를 상호작용 가능한 필터 토글로 개선
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| """Behavioral contracts for the deploy-blocking dashboard filter.""" | ||
|
|
||
| import re | ||
| import subprocess | ||
|
|
||
| from scanner.cli.appguardrail import dashboard_index_path | ||
|
|
||
|
|
||
| def _dashboard_html() -> str: | ||
| """Read the shipped dashboard asset used by the CLI server.""" | ||
| return dashboard_index_path().read_text(encoding="utf-8") | ||
|
|
||
|
|
||
| def _render_script_prefix(html: str) -> str: | ||
| """Return the real dashboard script through `render` without boot side effects.""" | ||
| match = re.search(r"<script>(?P<script>[\s\S]*?)</script>", html) | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| assert match is not None | ||
| script = match.group("script") | ||
| prefix, separator, _ = script.partition("function openDetail(f){") | ||
| assert separator | ||
| return prefix | ||
|
|
||
|
|
||
| def test_deploy_blocking_card_filter_contract_is_complete() -> None: | ||
| """The card must expose pointer, keyboard, pressed-state, and filter wiring.""" | ||
| html = _dashboard_html() | ||
| card = re.search( | ||
| r'<div id="deploy-blocking-card" class="card"(?P<attrs>[^>]*)>', | ||
| html, | ||
| ) | ||
|
|
||
| assert card is not None | ||
| attrs = card.group("attrs") | ||
| assert 'role="button"' in attrs | ||
| assert 'tabindex="0"' in attrs | ||
| assert 'aria-pressed="${filterBlocking}"' in attrs | ||
| assert 'onclick="filterBlocking=!filterBlocking; render();"' in attrs | ||
| assert "event.key==='Enter'||event.key===' '" in attrs | ||
| assert ".filter(({f})=> !filterBlocking || isDeployBlocking(f))" in html | ||
|
|
||
|
|
||
| def test_deploy_blocking_filter_executes_and_restores_focus() -> None: | ||
| """Run the shipped render logic and verify filtering, pressed state, and focus.""" | ||
| html = _dashboard_html() | ||
| script = _render_script_prefix(html) | ||
| harness = r''' | ||
| const registry = new Map(); | ||
| function makeElement(id) { | ||
| return { | ||
| id, | ||
| _html: '', | ||
| textContent: '', | ||
| value: '', | ||
| selectionStart: 0, | ||
| selectionEnd: 0, | ||
| listeners: {}, | ||
| addEventListener(type, fn) { this.listeners[type] = fn; }, | ||
| querySelectorAll() { return []; }, | ||
| focus() { document.activeElement = this; }, | ||
| setSelectionRange(start, end) { this.selectionStart = start; this.selectionEnd = end; } | ||
| }; | ||
| } | ||
| const body = makeElement('body'); | ||
| const app = makeElement('app'); | ||
| const summary = makeElement('findings-summary'); | ||
| Object.defineProperty(app, 'innerHTML', { | ||
| get() { return this._html; }, | ||
| set(value) { | ||
| this._html = value; | ||
| registry.set('q', makeElement('q')); | ||
| registry.set('sev', makeElement('sev')); | ||
| if (value.includes('id="deploy-blocking-card"')) { | ||
| registry.set('deploy-blocking-card', makeElement('deploy-blocking-card')); | ||
| } else { | ||
| registry.delete('deploy-blocking-card'); | ||
| } | ||
| } | ||
| }); | ||
| const document = { | ||
| activeElement: body, | ||
| getElementById(id) { | ||
| if (id === 'app') return app; | ||
| if (id === 'findings-summary') return summary; | ||
| if (id === 'body') return body; | ||
| return registry.get(id) || null; | ||
| } | ||
| }; | ||
| ''' | ||
| assertions = r''' | ||
| ALL = [ | ||
| {severity:'CRITICAL', context:'app-code', message:'blocking-one', file:'a.py', rule_id:'A', category:'security', line:1}, | ||
| {severity:'HIGH', context:'test', message:'nonblocking-test', file:'b.py', rule_id:'B', category:'security', line:2}, | ||
| {severity:'WARNING', context:'app-code', message:'warning-only', file:'c.py', rule_id:'C', category:'quality', line:3} | ||
| ]; | ||
| render(); | ||
| const firstCard = registry.get('deploy-blocking-card'); | ||
| if (!firstCard) throw new Error('deploy-blocking card was not rendered with a stable id'); | ||
| firstCard.focus(); | ||
| filterBlocking = !filterBlocking; | ||
| render(); | ||
| if (!app.innerHTML.includes('blocking-one')) throw new Error('blocking finding disappeared'); | ||
| if (app.innerHTML.includes('nonblocking-test')) throw new Error('non-blocking test finding leaked through filter'); | ||
| if (app.innerHTML.includes('warning-only')) throw new Error('warning finding leaked through filter'); | ||
| if (!app.innerHTML.includes('aria-pressed="true"')) throw new Error('pressed state did not follow filter state'); | ||
| if (document.activeElement?.id !== 'deploy-blocking-card') throw new Error('focus was not restored to the replaced card'); | ||
| ''' | ||
|
|
||
| completed = subprocess.run( | ||
| ["node", "-e", harness + script + assertions], | ||
| check=False, | ||
| capture_output=True, | ||
| text=True, | ||
| ) | ||
|
|
||
| assert completed.returncode == 0, completed.stderr | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
📝 Info: Combined filters preserve row identity
The blocking predicate intersects with severity and search filters. Preserved original indices keep each displayed row linked to the correct finding.
Was this helpful? React with 👍 or 👎 to provide feedback.