-
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 4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
/** | ||
* @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, | ||
} | ||
|
||
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('shows toggle button for raw headers', () => { | ||
const wrapper = mount(RunPanel, { | ||
props: mockProps, | ||
global: { | ||
stubs: { | ||
NuxtLink: { | ||
template: '<a :href="to"><slot /></a>', | ||
props: ['to'], | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
const toggleButton = wrapper.find('.toggle-raw-headers') | ||
expect(toggleButton.exists()).toBe(true) | ||
expect(toggleButton.text()).toBe('Show Raw Headers') | ||
}) | ||
|
||
it('hides raw headers by default', () => { | ||
const wrapper = mount(RunPanel, { | ||
props: mockProps, | ||
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 toggle button is clicked', async () => { | ||
const wrapper = mount(RunPanel, { | ||
props: mockProps, | ||
global: { | ||
stubs: { | ||
NuxtLink: { | ||
template: '<a :href="to"><slot /></a>', | ||
props: ['to'], | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
const toggleButton = wrapper.find('.toggle-raw-headers') | ||
await toggleButton.trigger('click') | ||
|
||
expect(wrapper.find('.raw-cache-headers-mock').exists()).toBe(true) | ||
expect(toggleButton.text()).toBe('Hide Raw Headers') | ||
}) | ||
|
||
it('hides raw headers when toggle button is clicked twice', async () => { | ||
const wrapper = mount(RunPanel, { | ||
props: mockProps, | ||
global: { | ||
stubs: { | ||
NuxtLink: { | ||
template: '<a :href="to"><slot /></a>', | ||
props: ['to'], | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
const toggleButton = wrapper.find('.toggle-raw-headers') | ||
|
||
// Click to show | ||
await toggleButton.trigger('click') | ||
expect(wrapper.find('.raw-cache-headers-mock').exists()).toBe(true) | ||
expect(toggleButton.text()).toBe('Hide Raw Headers') | ||
|
||
// Click to hide | ||
await toggleButton.trigger('click') | ||
expect(wrapper.find('.raw-cache-headers-mock').exists()).toBe(false) | ||
expect(toggleButton.text()).toBe('Show Raw Headers') | ||
}) | ||
|
||
it('updates button title attribute based on state', async () => { | ||
const wrapper = mount(RunPanel, { | ||
props: mockProps, | ||
global: { | ||
stubs: { | ||
NuxtLink: { | ||
template: '<a :href="to"><slot /></a>', | ||
props: ['to'], | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
const toggleButton = wrapper.find('.toggle-raw-headers') | ||
|
||
// Initial state | ||
expect(toggleButton.attributes('title')).toBe('Show raw headers') | ||
|
||
// After clicking to show | ||
await toggleButton.trigger('click') | ||
expect(toggleButton.attributes('title')).toBe('Hide raw headers') | ||
|
||
// After clicking to hide again | ||
await toggleButton.trigger('click') | ||
expect(toggleButton.attributes('title')).toBe('Show raw headers') | ||
}) | ||
}) |
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.
Uh oh!
There was an error while loading. Please reload this page.