| ... | @@ -333,6 +333,33 @@ describe("resolveRestingComposerControlsLayout hysteresis", () => { | ... | @@ -333,6 +333,33 @@ describe("resolveRestingComposerControlsLayout hysteresis", () => { |
| 333 | ).toEqual({ hiddenCount: 0, visible: true }); | 333 | ).toEqual({ hiddenCount: 0, visible: true }); |
| 334 | }); | 334 | }); |
| 335 | | 335 | |
| | 336 | it("restores the blocks that fit when the full cluster has no slack", () => { |
| | 337 | const partlyRestored = resolveRestingComposerControlsLayout({ |
| | 338 | ...base, |
| | 339 | hostWidth: 357, |
| | 340 | previous: { hiddenCount: 2, visible: true }, |
| | 341 | }); |
| | 342 | expect(partlyRestored).toEqual({ hiddenCount: 1, visible: true }); |
| | 343 | expect( |
| | 344 | resolveRestingComposerControlsLayout({ ...base, hostWidth: 357, previous: partlyRestored }), |
| | 345 | ).toEqual(partlyRestored); |
| | 346 | expect( |
| | 347 | resolveRestingComposerControlsLayout({ ...base, hostWidth: 358, previous: partlyRestored }), |
| | 348 | ).toEqual({ hiddenCount: 0, visible: true }); |
| | 349 | }); |
| | 350 | |
| | 351 | it("requires slack before partially restoring a cluster", () => { |
| | 352 | // One inline block, the picker, and overflow need 149 + 60 + 24 + 8 = 241px. |
| | 353 | const previous = { hiddenCount: 2, visible: true }; |
| | 354 | expect(resolveRestingComposerControlsLayout({ ...base, hostWidth: 241, previous })).toEqual( |
| | 355 | previous, |
| | 356 | ); |
| | 357 | expect(resolveRestingComposerControlsLayout({ ...base, hostWidth: 242, previous })).toEqual({ |
| | 358 | hiddenCount: 1, |
| | 359 | visible: true, |
| | 360 | }); |
| | 361 | }); |
| | 362 | |
| 336 | it("still resolves from scratch when there is no previous layout", () => { | 363 | it("still resolves from scratch when there is no previous layout", () => { |
| 337 | expect(resolveRestingComposerControlsLayout({ ...base, hostWidth: 357 })).toEqual({ | 364 | expect(resolveRestingComposerControlsLayout({ ...base, hostWidth: 357 })).toEqual({ |
| 338 | hiddenCount: 0, | 365 | hiddenCount: 0, |