Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1d49643
feat(grid): Phase 3 add `align-content` tests and snapshots
jwxbond Dec 22, 2025
189d9d1
feat(grid): Phase 3 add `align-item` tests and snapshots
jwxbond Dec 22, 2025
3b38875
feat(grid): Phase 3 add `align-self` tests and snapshots
jwxbond Dec 22, 2025
a4894ec
feat(grid): Phase 3 add `auto-margin` tests and snapshots
jwxbond Dec 22, 2025
0486827
feat(grid): Phase 3 add `justify-content` tests and snapshots
jwxbond Dec 22, 2025
c453d37
feat(grid): Phase 3 add `justify-items` tests and snapshots
jwxbond Dec 22, 2025
a21528e
feat(grid): Phase 3 add `justify-self` tests and snapshots
jwxbond Dec 22, 2025
d3aa12c
feat(grid): Phase 3 add `place-content` tests and snapshots
jwxbond Dec 22, 2025
71c7d5c
feat(grid): Phase 3 add `place-items` tests and snapshots
jwxbond Dec 22, 2025
58e77a9
feat(grid): Phase 3 add `place-self` tests and snapshots
jwxbond Dec 22, 2025
c6041dd
feat(grid): Phase 3 add `safe-unsafe` and `writing-mode` tests and sn…
jwxbond Dec 22, 2025
26c58d8
feat(grid): Phase 4 add `auto-fill` tests and snapshots
jwxbond Dec 22, 2025
151d51c
feat(grid): Phase 4 add `auto-fit` tests and snapshots
jwxbond Dec 22, 2025
7a653b6
feat(grid): Phase 4 add `fractional (fr) units` tests and snapshots
jwxbond Dec 23, 2025
6b345c4
feat(grid): Phase 4 add `intrinsic sizing` tests and snapshots
jwxbond Dec 23, 2025
c610f5d
feat(grid): Phase 4 add `minmax() advanced` tests and snapshots
jwxbond Dec 23, 2025
d2955a5
feat(grid): Phase 4 add `minmax() basic` tests and snapshots
jwxbond Dec 23, 2025
bbcbf78
feat(grid): Phase 4 add `track breadth calculation` tests and snapshots
jwxbond Dec 23, 2025
527d248
feat(grid): Phase 4 add `spanning with intrinsic sizes` tests and sna…
jwxbond Dec 23, 2025
073351a
feat(grid): Phase 4 add `content distribution` tests and snapshots
jwxbond Dec 23, 2025
5dcd893
fix: get compute style for flex & grid
jwxbond Dec 24, 2025
e7048f4
fix: auto-margins.ts
jwxbond Dec 24, 2025
df75cf0
fix: auto-fit cases and update snapshot
jwxbond Dec 24, 2025
41c2a90
fix: content-distribution cases and update snapshot
jwxbond Dec 24, 2025
95775b1
fix: `minmax-advanced` cases and update snapshot
jwxbond Dec 24, 2025
a88e77d
fix: `align-item` cases and update snapshot
jwxbond Dec 24, 2025
19d0ae1
fix: grid item overlap with opacity < 1
jwxbond Dec 25, 2025
8d474b7
fix(rendering): paint negative z-index under background
jwxbond Dec 25, 2025
cd5fc02
feat(grid): Phase 4 add `fit-content` tests and snapshots & fix fit-c…
jwxbond Dec 25, 2025
625ad4e
fix: grid item overlap with opacity < 1 & add snapshot
jwxbond Dec 25, 2025
bd570ef
fix: `minmax-advanced` cases and update snapshot 2
jwxbond Dec 25, 2025
050b7b7
feat(grid): Phase 3: Alignment & Spacing is now complete
jwxbond Dec 27, 2025
4345065
feat(grid): Phase 4: dynamic add/remove items tests & snapshtos
jwxbond Dec 27, 2025
6fae952
feat(grid): Phase 4: `container resize behavior` tests & snapshots
jwxbond Dec 27, 2025
eac696a
feat(grid): Phase 4: `dynamic style changes` tests & snapshots
jwxbond Dec 27, 2025
38bc881
feat(grid): Phase 4: `auto-columns extended` tests & snapshots
jwxbond Dec 27, 2025
9034f16
feat(grid): Phase 4: `auto-rows` tests & snapshots
jwxbond Dec 27, 2025
e37db26
fix(grid): grid-auto-rows: 1fr sizing by resolving all row flex trac…
jwxbond Dec 27, 2025
d3786d4
feat(grid): Phase 4: `implicit track creation` tests & snapshots and …
jwxbond Dec 27, 2025
0e9f492
feat(grid): Phase 4: `implicit tracks with named lines` tests & snaps…
jwxbond Dec 27, 2025
e4c4b33
feat(grid): Phase 4: `implicit tracks with gaps` tests & snapshots an…
jwxbond Dec 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
166 changes: 166 additions & 0 deletions integration_tests/specs/css/css-grid/advanced-sizing/auto-fill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
describe('CSS Grid auto-fill', () => {
it('creates tracks with auto-fill and fixed size', async () => {
const grid = document.createElement('div');
grid.style.display = 'grid';
grid.style.gridTemplateColumns = 'repeat(auto-fill, 100px)';
grid.style.gridTemplateRows = '80px';
grid.style.width = '350px';
grid.style.gap = '0';
grid.style.backgroundColor = '#f5f5f5';

for (let i = 0; i < 5; i++) {
const item = document.createElement('div');
item.textContent = `${i + 1}`;
item.style.backgroundColor = ['#42A5F5', '#66BB6A', '#FFA726', '#BA68C8', '#9575CD'][i];
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
grid.appendChild(item);
}

document.body.appendChild(grid);
await waitForFrame();
await snapshot();

const items = Array.from(grid.children) as HTMLElement[];
// Should fit 3 columns (350/100 = 3), wrapping to rows
expect(items[0].getBoundingClientRect().width).toBe(100);
expect(items[1].getBoundingClientRect().width).toBe(100);
expect(items[2].getBoundingClientRect().width).toBe(100);

grid.remove();
});
Comment on lines +2 to +33
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Grid width exceeds maximum testing window width.

Line 7 sets the grid width to 350px, which exceeds the documented maximum testing window width of 340px. This may cause clipping or unexpected layout behavior.

Based on coding guidelines, the max width of the testing window is 340px.

🔎 Proposed fix
-    grid.style.width = '350px';
+    grid.style.width = '340px';

You may also need to adjust the comment on line 27 accordingly:

-    // Should fit 3 columns (350/100 = 3), wrapping to rows
+    // Should fit 3 columns (340/100 = 3), wrapping to rows
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it('creates tracks with auto-fill and fixed size', async () => {
const grid = document.createElement('div');
grid.style.display = 'grid';
grid.style.gridTemplateColumns = 'repeat(auto-fill, 100px)';
grid.style.gridTemplateRows = '80px';
grid.style.width = '350px';
grid.style.gap = '0';
grid.style.backgroundColor = '#f5f5f5';
for (let i = 0; i < 5; i++) {
const item = document.createElement('div');
item.textContent = `${i + 1}`;
item.style.backgroundColor = ['#42A5F5', '#66BB6A', '#FFA726', '#BA68C8', '#9575CD'][i];
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
grid.appendChild(item);
}
document.body.appendChild(grid);
await waitForFrame();
await snapshot();
const items = Array.from(grid.children) as HTMLElement[];
// Should fit 3 columns (350/100 = 3), wrapping to rows
expect(items[0].getBoundingClientRect().width).toBe(100);
expect(items[1].getBoundingClientRect().width).toBe(100);
expect(items[2].getBoundingClientRect().width).toBe(100);
grid.remove();
});
it('creates tracks with auto-fill and fixed size', async () => {
const grid = document.createElement('div');
grid.style.display = 'grid';
grid.style.gridTemplateColumns = 'repeat(auto-fill, 100px)';
grid.style.gridTemplateRows = '80px';
grid.style.width = '340px';
grid.style.gap = '0';
grid.style.backgroundColor = '#f5f5f5';
for (let i = 0; i < 5; i++) {
const item = document.createElement('div');
item.textContent = `${i + 1}`;
item.style.backgroundColor = ['#42A5F5', '#66BB6A', '#FFA726', '#BA68C8', '#9575CD'][i];
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
grid.appendChild(item);
}
document.body.appendChild(grid);
await waitForFrame();
await snapshot();
const items = Array.from(grid.children) as HTMLElement[];
// Should fit 3 columns (340/100 = 3), wrapping to rows
expect(items[0].getBoundingClientRect().width).toBe(100);
expect(items[1].getBoundingClientRect().width).toBe(100);
expect(items[2].getBoundingClientRect().width).toBe(100);
grid.remove();
});
🤖 Prompt for AI Agents
In integration_tests/specs/css/css-grid/advanced-sizing/auto-fill.ts around
lines 2 to 33, the test sets grid.style.width = '350px' which exceeds the
documented maximum testing window width (340px); change the width to '340px' and
update the inline comment on line ~27 to reflect the max window width (e.g.,
"Should fit 3 columns (340/100 = 3)"), ensuring assertions remain valid.


it('creates empty tracks with auto-fill', async () => {
const grid = document.createElement('div');
grid.style.display = 'grid';
grid.style.gridTemplateColumns = 'repeat(auto-fill, 80px)';
grid.style.gridTemplateRows = '70px';
grid.style.width = '300px';
grid.style.gap = '0';
grid.style.backgroundColor = '#e3f2fd';

for (let i = 0; i < 2; i++) {
const item = document.createElement('div');
item.textContent = `${i + 1}`;
item.style.backgroundColor = ['#2196F3', '#1E88E5'][i];
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
grid.appendChild(item);
}

document.body.appendChild(grid);
await waitForFrame();
await snapshot();

// Should create tracks even if not all filled
const items = Array.from(grid.children) as HTMLElement[];
items.forEach(item => {
expect(item.getBoundingClientRect().width).toBe(80);
});

grid.remove();
});

it('uses auto-fill with minmax', async () => {
const grid = document.createElement('div');
grid.style.display = 'grid';
grid.style.gridTemplateColumns = 'repeat(auto-fill, minmax(100px, 1fr))';
grid.style.gridTemplateRows = '80px';
grid.style.width = '350px';
grid.style.gap = '0';
grid.style.backgroundColor = '#f3e5f5';

for (let i = 0; i < 5; i++) {
const item = document.createElement('div');
item.textContent = `${i + 1}`;
item.style.backgroundColor = ['#BA68C8', '#AB47BC', '#9C27B0', '#8E24AA', '#7B1FA2'][i];
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
grid.appendChild(item);
}

document.body.appendChild(grid);
await waitForFrame();
await snapshot();

const items = Array.from(grid.children) as HTMLElement[];
// Should fit 3 columns at minimum (350/100 = 3)
items.slice(0, 3).forEach(item => {
expect(item.getBoundingClientRect().width).toBeGreaterThanOrEqual(100);
});

grid.remove();
});
Comment on lines +68 to +99
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Grid width exceeds maximum testing window width.

Line 73 sets the grid width to 350px, which exceeds the documented maximum testing window width of 340px. This may cause clipping or unexpected layout behavior.

Based on coding guidelines, the max width of the testing window is 340px.

🔎 Proposed fix
-    grid.style.width = '350px';
+    grid.style.width = '340px';

You may also need to adjust the comment on line 93 accordingly:

-    // Should fit 3 columns at minimum (350/100 = 3)
+    // Should fit 3 columns at minimum (340/100 = 3)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it('uses auto-fill with minmax', async () => {
const grid = document.createElement('div');
grid.style.display = 'grid';
grid.style.gridTemplateColumns = 'repeat(auto-fill, minmax(100px, 1fr))';
grid.style.gridTemplateRows = '80px';
grid.style.width = '350px';
grid.style.gap = '0';
grid.style.backgroundColor = '#f3e5f5';
for (let i = 0; i < 5; i++) {
const item = document.createElement('div');
item.textContent = `${i + 1}`;
item.style.backgroundColor = ['#BA68C8', '#AB47BC', '#9C27B0', '#8E24AA', '#7B1FA2'][i];
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
grid.appendChild(item);
}
document.body.appendChild(grid);
await waitForFrame();
await snapshot();
const items = Array.from(grid.children) as HTMLElement[];
// Should fit 3 columns at minimum (350/100 = 3)
items.slice(0, 3).forEach(item => {
expect(item.getBoundingClientRect().width).toBeGreaterThanOrEqual(100);
});
grid.remove();
});
it('uses auto-fill with minmax', async () => {
const grid = document.createElement('div');
grid.style.display = 'grid';
grid.style.gridTemplateColumns = 'repeat(auto-fill, minmax(100px, 1fr))';
grid.style.gridTemplateRows = '80px';
grid.style.width = '340px';
grid.style.gap = '0';
grid.style.backgroundColor = '#f3e5f5';
for (let i = 0; i < 5; i++) {
const item = document.createElement('div');
item.textContent = `${i + 1}`;
item.style.backgroundColor = ['#BA68C8', '#AB47BC', '#9C27B0', '#8E24AA', '#7B1FA2'][i];
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
grid.appendChild(item);
}
document.body.appendChild(grid);
await waitForFrame();
await snapshot();
const items = Array.from(grid.children) as HTMLElement[];
// Should fit 3 columns at minimum (340/100 = 3)
items.slice(0, 3).forEach(item => {
expect(item.getBoundingClientRect().width).toBeGreaterThanOrEqual(100);
});
grid.remove();
});
🤖 Prompt for AI Agents
In integration_tests/specs/css/css-grid/advanced-sizing/auto-fill.ts around
lines 68 to 99, the test sets grid.style.width = '350px' which exceeds the
testing window max width (340px) and can cause clipping; change the grid width
to '340px' (or a smaller value ≤340px) and update any related inline comment
(around line 93) that states the expected number of columns or math based on 350
to reflect the new width (e.g., 340/100 = 3) so assertions remain accurate.


it('handles auto-fill with gaps', async () => {
const grid = document.createElement('div');
grid.style.display = 'grid';
grid.style.gridTemplateColumns = 'repeat(auto-fill, 90px)';
grid.style.gridTemplateRows = '70px';
grid.style.width = '300px';
grid.style.columnGap = '10px';
grid.style.backgroundColor = '#fff3e0';

for (let i = 0; i < 4; i++) {
const item = document.createElement('div');
item.textContent = `${i + 1}`;
item.style.backgroundColor = ['#FFB74D', '#FFA726', '#FF9800', '#FB8C00'][i];
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
grid.appendChild(item);
}

document.body.appendChild(grid);
await waitForFrame();
await snapshot();

const items = Array.from(grid.children) as HTMLElement[];
// With gaps: 90 + 10 + 90 + 10 + 90 = 290px, fits 3 columns
items.forEach(item => {
expect(item.getBoundingClientRect().width).toBe(90);
});

grid.remove();
});

it('handles auto-fill with small items', async () => {
const grid = document.createElement('div');
grid.style.display = 'grid';
grid.style.gridTemplateColumns = 'repeat(auto-fill, minmax(60px, 1fr))';
grid.style.gridTemplateRows = '60px';
grid.style.width = '250px';
grid.style.gap = '0';
grid.style.backgroundColor = '#e8f5e9';

for (let i = 0; i < 3; i++) {
const item = document.createElement('div');
item.textContent = `${i + 1}`;
item.style.backgroundColor = ['#66BB6A', '#4CAF50', '#43A047'][i];
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
grid.appendChild(item);
}

document.body.appendChild(grid);
await waitForFrame();
await snapshot();

const items = Array.from(grid.children) as HTMLElement[];
// Should fit 4 columns (250/60 = 4), but only 3 items
items.forEach(item => {
expect(item.getBoundingClientRect().width).toBeGreaterThanOrEqual(60);
});

grid.remove();
});
});
187 changes: 187 additions & 0 deletions integration_tests/specs/css/css-grid/advanced-sizing/auto-fit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
describe('CSS Grid auto-fit', () => {
it('collapses empty tracks with auto-fit', async () => {
const grid = document.createElement('div');
grid.style.display = 'grid';
grid.style.gridTemplateColumns = 'repeat(auto-fit, 100px)';
grid.style.gridTemplateRows = '80px';
grid.style.width = '350px';
grid.style.gap = '0';
grid.style.backgroundColor = '#f5f5f5';

for (let i = 0; i < 2; i++) {
const item = document.createElement('div');
item.textContent = `${i + 1}`;
item.style.backgroundColor = ['#42A5F5', '#66BB6A'][i];
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
grid.appendChild(item);
}

document.body.appendChild(grid);
await waitForFrame();
await snapshot();

const items = Array.from(grid.children) as HTMLElement[];
// auto-fit collapses empty tracks, items may stretch
items.forEach(item => {
expect(item.getBoundingClientRect().width).toBeGreaterThanOrEqual(100);
});

grid.remove();
});

it('uses auto-fit with minmax to stretch items', async () => {
const grid = document.createElement('div');
grid.style.display = 'grid';
grid.style.gridTemplateColumns = 'repeat(auto-fit, minmax(100px, 1fr))';
grid.style.gridTemplateRows = '80px';
grid.style.width = '350px';
grid.style.gap = '0';
grid.style.backgroundColor = '#e3f2fd';

for (let i = 0; i < 2; i++) {
const item = document.createElement('div');
item.textContent = `Item ${i + 1}`;
item.style.backgroundColor = ['#2196F3', '#1E88E5'][i];
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
grid.appendChild(item);
}

document.body.appendChild(grid);
await waitForFrame();
await snapshot();

const items = Array.from(grid.children) as HTMLElement[];
// Items should stretch to fill available space
expect(items[0].getBoundingClientRect().width).toBeGreaterThan(100);
expect(items[1].getBoundingClientRect().width).toBeGreaterThan(100);

grid.remove();
});

it('handles auto-fit with gaps', async () => {
const grid = document.createElement('div');
grid.style.display = 'grid';
grid.style.gridTemplateColumns = 'repeat(auto-fit, minmax(80px, 1fr))';
grid.style.gridTemplateRows = '70px';
grid.style.width = '300px';
grid.style.columnGap = '10px';
grid.style.backgroundColor = '#f3e5f5';

for (let i = 0; i < 3; i++) {
const item = document.createElement('div');
item.textContent = `${i + 1}`;
item.style.backgroundColor = ['#BA68C8', '#AB47BC', '#9C27B0'][i];
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
grid.appendChild(item);
}

document.body.appendChild(grid);
await waitForFrame();
await snapshot();

const items = Array.from(grid.children) as HTMLElement[];
items.forEach(item => {
expect(item.getBoundingClientRect().width).toBeGreaterThanOrEqual(80);
});

grid.remove();
});

it('compares auto-fit vs auto-fill behavior', async () => {
const grid1 = document.createElement('div');
grid1.style.display = 'grid';
grid1.style.gridTemplateColumns = 'repeat(auto-fill, 100px)';
grid1.style.gridTemplateRows = '70px';
grid1.style.width = '350px';
grid1.style.gap = '0';
grid1.style.backgroundColor = '#fff3e0';

for (let i = 0; i < 2; i++) {
const item = document.createElement('div');
item.textContent = `Fill ${i + 1}`;
item.style.backgroundColor = ['#FFB74D', '#FFA726'][i];
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
item.style.fontSize = '11px';
grid1.appendChild(item);
}

document.body.appendChild(grid1);
await waitForFrame();
await snapshot();

const fillItems = Array.from(grid1.children) as HTMLElement[];
expect(fillItems[0].getBoundingClientRect().width).toBe(100);

grid1.remove();

const grid2 = document.createElement('div');
grid2.style.display = 'grid';
grid2.style.gridTemplateColumns = 'repeat(auto-fit, minmax(100px, 1fr))';
grid2.style.gridTemplateRows = '70px';
grid2.style.width = '350px';
grid2.style.gap = '0';
grid2.style.backgroundColor = '#e8f5e9';

for (let i = 0; i < 2; i++) {
const item = document.createElement('div');
item.textContent = `Fit ${i + 1}`;
item.style.backgroundColor = ['#66BB6A', '#4CAF50'][i];
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
item.style.fontSize = '11px';
grid2.appendChild(item);
}

document.body.appendChild(grid2);
await waitForFrame();
await snapshot();

const fitItems = Array.from(grid2.children) as HTMLElement[];
// auto-fit items should be wider (stretched)
expect(fitItems[0].getBoundingClientRect().width).toBeGreaterThan(100);

grid2.remove();
});

it('handles auto-fit with single item', async () => {
const grid = document.createElement('div');
grid.style.display = 'grid';
grid.style.gridTemplateColumns = 'repeat(auto-fit, minmax(100px, 1fr))';
grid.style.gridTemplateRows = '80px';
grid.style.width = '300px';
grid.style.gap = '0';
grid.style.backgroundColor = '#ede7f6';

const item = document.createElement('div');
item.textContent = 'Single item';
item.style.backgroundColor = '#9575CD';
item.style.display = 'flex';
item.style.alignItems = 'center';
item.style.justifyContent = 'center';
item.style.color = 'white';
grid.appendChild(item);

document.body.appendChild(grid);
await waitForFrame();
await snapshot();

// Single item should stretch to fill available space
expect(item.getBoundingClientRect().width).toBe(300);

grid.remove();
});
});
Loading
Loading