-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add toggle button to show/hide raw cache headers #89
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
Copilot
wants to merge
7
commits into
main
Choose a base branch
from
copilot/fix-85
base: main
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 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
99cdbc8
Initial plan
Copilot b8e8487
Initial analysis: Add toggle button for raw headers
Copilot 10bc9c8
Implement toggle button for raw headers with tests
Copilot 3c3930f
Fix linting issues in RunPanel test
Copilot 68d0b61
Merge branch 'main' into copilot/fix-85
serhalp 394e139
Refactor raw headers toggle to global control
Copilot a728e60
Improve toggle design with grouped controls and better styling
Copilot 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
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,105 @@ | ||
/** | ||
* @vitest-environment jsdom | ||
*/ | ||
import { describe, it, expect, vi } from 'vitest' | ||
import { mount } from '@vue/test-utils' | ||
import RunPanel from './RunPanel.vue' | ||
|
||
// Mock the components that RunPanel uses | ||
vi.mock('./CacheAnalysis.vue', () => ({ | ||
default: { | ||
name: 'CacheAnalysis', | ||
template: '<div class="cache-analysis-mock">Cache Analysis</div>', | ||
}, | ||
})) | ||
|
||
vi.mock('./RawCacheHeaders.vue', () => ({ | ||
default: { | ||
name: 'RawCacheHeaders', | ||
template: '<div class="raw-cache-headers-mock">Raw Cache Headers</div>', | ||
}, | ||
})) | ||
|
||
const mockProps = { | ||
runId: 'test-run-id', | ||
url: 'https://example.com', | ||
status: 200, | ||
durationInMs: 150, | ||
cacheHeaders: { | ||
'cache-control': 'max-age=3600', | ||
'etag': '"abc123"', | ||
}, | ||
enableDiffOnHover: false, | ||
showRawHeaders: false, | ||
} | ||
|
||
describe('RunPanel', () => { | ||
it('renders basic information correctly', () => { | ||
const wrapper = mount(RunPanel, { | ||
props: mockProps, | ||
global: { | ||
stubs: { | ||
NuxtLink: { | ||
template: '<a :href="to"><slot /></a>', | ||
props: ['to'], | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
expect(wrapper.text()).toContain('https://example.com') | ||
expect(wrapper.text()).toContain('HTTP 200 (150 ms)') | ||
expect(wrapper.find('.cache-analysis-mock').exists()).toBe(true) | ||
}) | ||
|
||
it('renders permalink correctly', () => { | ||
const wrapper = mount(RunPanel, { | ||
props: mockProps, | ||
global: { | ||
stubs: { | ||
NuxtLink: { | ||
template: '<a :href="to"><slot /></a>', | ||
props: ['to'], | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
const permalink = wrapper.find('.run-permalink') | ||
expect(permalink.exists()).toBe(true) | ||
expect(permalink.attributes('href')).toBe('/run/test-run-id') | ||
expect(permalink.text()).toBe('🔗 Permalink') | ||
}) | ||
|
||
it('hides raw headers when showRawHeaders prop is false', () => { | ||
const wrapper = mount(RunPanel, { | ||
props: { ...mockProps, showRawHeaders: false }, | ||
global: { | ||
stubs: { | ||
NuxtLink: { | ||
template: '<a :href="to"><slot /></a>', | ||
props: ['to'], | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
expect(wrapper.find('.raw-cache-headers-mock').exists()).toBe(false) | ||
}) | ||
|
||
it('shows raw headers when showRawHeaders prop is true', () => { | ||
const wrapper = mount(RunPanel, { | ||
props: { ...mockProps, showRawHeaders: true }, | ||
global: { | ||
stubs: { | ||
NuxtLink: { | ||
template: '<a :href="to"><slot /></a>', | ||
props: ['to'], | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
expect(wrapper.find('.raw-cache-headers-mock').exists()).toBe(true) | ||
}) | ||
}) |
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.
it's still really ugly:
maybe you aren't taking into account the global styles the app loads in the nuxt config file? maybe your permissions are blocking it from loading or something?
now that I think about it, maybe the "Reset" button and this toggle should be grouped together somehow? they're both controls. maybe make a visually nice controls section somewhere? the only constraint is it shouldn't take much vertical space, ideally zero somehow.
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.
Addressed the design feedback by creating a clean controls bar that groups the toggle and clear button together. The toggle is now a modern switch instead of a basic checkbox, with better styling that should work with the global styles. The controls are positioned logically above the run panels and take minimal vertical space. (a728e60)