Skip to content

Commit 01ee2c7

Browse files
Artur-claude
andcommitted
test: add visual tests for grid header and footer slots
Added four visual test scenarios to verify the grid header and footer slots rendering: - Header and footer slots together with content - Header slot only with toolbar styling - Footer slot only with pagination controls - Empty slots to verify they take no space Part of #986 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 23d7072 commit 01ee2c7

File tree

9 files changed

+103
-0
lines changed

9 files changed

+103
-0
lines changed
8.02 KB
Loading
10.7 KB
Loading
8.25 KB
Loading
17.1 KB
Loading

packages/grid/test/visual/grid.common.js

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,4 +463,107 @@ describe('grid', () => {
463463
await visualDiff(element, 'empty-state');
464464
});
465465
});
466+
467+
describe('grid header and footer slots', () => {
468+
beforeEach(async () => {
469+
element = fixtureSync(`
470+
<vaadin-grid style="width: 400px">
471+
<div slot="header" style="padding: 10px; background: #f0f0f0; display: flex; align-items: center; gap: 10px;">
472+
<strong>Grid Header</strong>
473+
<button style="margin-left: auto;">Action</button>
474+
</div>
475+
476+
<vaadin-grid-column path="name.first" header="First name"></vaadin-grid-column>
477+
<vaadin-grid-column path="name.last" header="Last name"></vaadin-grid-column>
478+
479+
<div slot="footer" style="padding: 8px; background: #fafafa; font-size: 12px; display: flex; justify-content: space-between;">
480+
<span>Total: 10 items</span>
481+
<span>Page 1 of 1</span>
482+
</div>
483+
</vaadin-grid>
484+
`);
485+
element.items = users.slice(0, 5);
486+
flushGrid(element);
487+
await nextRender();
488+
});
489+
490+
it('header and footer slots', async () => {
491+
await visualDiff(element, 'grid-header-footer-slots');
492+
});
493+
});
494+
495+
describe('grid header slot only', () => {
496+
beforeEach(async () => {
497+
element = fixtureSync(`
498+
<vaadin-grid style="width: 400px">
499+
<div slot="header" style="padding: 12px; background: linear-gradient(to right, #4f46e5, #7c3aed); color: white;">
500+
<div style="display: flex; align-items: center; gap: 10px;">
501+
<strong style="flex: 1;">User Management</strong>
502+
<input type="search" placeholder="Search..." style="padding: 4px 8px; border-radius: 4px; border: none;">
503+
<button style="padding: 4px 12px; background: white; color: #4f46e5; border: none; border-radius: 4px; font-weight: bold;">Add User</button>
504+
</div>
505+
</div>
506+
507+
<vaadin-grid-column path="name.first" header="First name"></vaadin-grid-column>
508+
<vaadin-grid-column path="name.last" header="Last name"></vaadin-grid-column>
509+
<vaadin-grid-column path="email" header="Email"></vaadin-grid-column>
510+
</vaadin-grid>
511+
`);
512+
element.items = users.slice(0, 5);
513+
flushGrid(element);
514+
await nextRender();
515+
});
516+
517+
it('header slot only', async () => {
518+
await visualDiff(element, 'grid-header-slot-only');
519+
});
520+
});
521+
522+
describe('grid footer slot only', () => {
523+
beforeEach(async () => {
524+
element = fixtureSync(`
525+
<vaadin-grid style="width: 400px">
526+
<vaadin-grid-column path="name.first" header="First name"></vaadin-grid-column>
527+
<vaadin-grid-column path="name.last" header="Last name"></vaadin-grid-column>
528+
<vaadin-grid-column path="location.city" header="City"></vaadin-grid-column>
529+
530+
<div slot="footer" style="padding: 10px; background: #f9fafb; border-top: 1px solid #e5e7eb;">
531+
<div style="display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: #6b7280;">
532+
<span>Showing 5 of 200 results</span>
533+
<div style="display: flex; gap: 5px;">
534+
<button style="padding: 2px 8px;">← Previous</button>
535+
<button style="padding: 2px 8px;">Next →</button>
536+
</div>
537+
</div>
538+
</div>
539+
</vaadin-grid>
540+
`);
541+
element.items = users.slice(0, 5);
542+
flushGrid(element);
543+
await nextRender();
544+
});
545+
546+
it('footer slot only', async () => {
547+
await visualDiff(element, 'grid-footer-slot-only');
548+
});
549+
});
550+
551+
describe('grid empty header and footer slots', () => {
552+
beforeEach(async () => {
553+
element = fixtureSync(`
554+
<vaadin-grid style="width: 400px">
555+
<vaadin-grid-column path="name.first" header="First name"></vaadin-grid-column>
556+
<vaadin-grid-column path="name.last" header="Last name"></vaadin-grid-column>
557+
<vaadin-grid-column path="email" header="Email"></vaadin-grid-column>
558+
</vaadin-grid>
559+
`);
560+
element.items = users.slice(0, 5);
561+
flushGrid(element);
562+
await nextRender();
563+
});
564+
565+
it('empty slots', async () => {
566+
await visualDiff(element, 'grid-empty-slots');
567+
});
568+
});
466569
});
10.1 KB
Loading
12.5 KB
Loading
10.2 KB
Loading
19.2 KB
Loading

0 commit comments

Comments
 (0)