Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com> Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Aarav Sareen <96787824+arvsrn@users.noreply.github.com> Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com> Co-authored-by: opencode <opencode@sst.dev> Co-authored-by: Jay <53023+jayair@users.noreply.github.com> Co-authored-by: David Hill <1879069+iamdavidhill@users.noreply.github.com> Co-authored-by: BB84 <110078428+BB-84C@users.noreply.github.com> Co-authored-by: Aiden Cline <aidenpcline@gmail.com> Co-authored-by: Dax <mail@thdxr.com> Co-authored-by: Brendan Allan <git@brendonovich.dev> Co-authored-by: Jay V <air@live.ca> Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com> Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Co-authored-by: Dustin Deus <deusdustin@gmail.com> Co-authored-by: Frank <frank@anoma.ly> Co-authored-by: usrnk1 <7547651+usrnk1@users.noreply.github.com> Co-authored-by: Jack <jack@anoma.ly> Co-authored-by: Sebastian <hasta84@gmail.com> Co-authored-by: Jérôme Benoit <jerome.benoit@sap.com> Co-authored-by: Test User <test@test.com> Co-authored-by: Simon Klee <hello@simonklee.dk> Co-authored-by: Rahul A Mistry <149420892+ProdigyRahul@users.noreply.github.com> Co-authored-by: Qiping Li <liqiping1991@gmail.com> Co-authored-by: liqiping <liqiping@msh.team> Co-authored-by: OpeOginni <107570612+OpeOginni@users.noreply.github.com> Co-authored-by: Matthias Reso <13337103+mreso@users.noreply.github.com> Co-authored-by: tobwen <1864057+tobwen@users.noreply.github.com> Co-authored-by: Daniel Polito <danielbpolito@gmail.com> Co-authored-by: opencode <noreply@opencode.ai> Co-authored-by: Devin R Leopold <devin.leopold@gmail.com> Co-authored-by: Zach Bruggeman <mail@bruggie.com> Co-authored-by: Zach Bruggeman <zbruggeman@ramp.com> Co-authored-by: Kit Langton <kit.langton@gmail.com> Co-authored-by: David Siewert <david1gruppenplan@gmail.com> Co-authored-by: Andrei Dziahel <develop7@develop7.info> Co-authored-by: adityachaudhary99 <adityaachaudhary2003@gmail.com> Co-authored-by: Vladimir Glafirov <vglafirov@gitlab.com> Co-authored-by: Matt Carey <mcarey@cloudflare.com>
79 lines
3.3 KiB
TypeScript
79 lines
3.3 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
import {
|
|
hasExistingWebState,
|
|
isAppUpgrade,
|
|
layoutTransitionState,
|
|
maximumSunsetTimeout,
|
|
newLayoutDesignsDefault,
|
|
nextSunsetCheckDelay,
|
|
resolveNewLayoutDesigns,
|
|
shouldDisplayTabsToast,
|
|
shouldEnableNewLayout,
|
|
} from "./settings"
|
|
|
|
describe("layout transition", () => {
|
|
test("blank profiles default to the new layout", () => {
|
|
expect(newLayoutDesignsDefault).toBe(true)
|
|
})
|
|
|
|
test("hides the transition until a sunset is scheduled", () => {
|
|
expect(layoutTransitionState(false, true, false, false)).toEqual({ available: false, notice: false })
|
|
})
|
|
|
|
test("existing profiles can switch before sunset", () => {
|
|
expect(layoutTransitionState(true, true, false, false)).toEqual({ available: true, notice: false })
|
|
})
|
|
|
|
test("classifies web profiles from existing settings or a recorded version", () => {
|
|
expect(hasExistingWebState("{}", undefined)).toBe(true)
|
|
expect(hasExistingWebState(null, "1.17.19")).toBe(true)
|
|
expect(hasExistingWebState(null, undefined)).toBe(false)
|
|
})
|
|
|
|
test("preserves explicit and default layout preferences", () => {
|
|
expect(resolveNewLayoutDesigns(false, false, true)).toBe(false)
|
|
expect(resolveNewLayoutDesigns(false, undefined, false)).toBe(false)
|
|
expect(resolveNewLayoutDesigns(false, undefined, true)).toBe(true)
|
|
})
|
|
|
|
test("sunset replaces the toggle with a dismissible notice", () => {
|
|
expect(layoutTransitionState(true, true, true, false)).toEqual({ available: false, notice: true })
|
|
expect(layoutTransitionState(true, true, true, true)).toEqual({ available: false, notice: false })
|
|
expect(resolveNewLayoutDesigns(true, false)).toBe(true)
|
|
})
|
|
|
|
test("caps checks for sunsets beyond the browser timeout limit", () => {
|
|
expect(nextSunsetCheckDelay(maximumSunsetTimeout + 1_000, 0)).toBe(maximumSunsetTimeout)
|
|
expect(nextSunsetCheckDelay(10_000, 9_000)).toBe(1_000)
|
|
expect(nextSunsetCheckDelay(9_000, 10_000)).toBe(0)
|
|
})
|
|
|
|
test("enables the new layout when upgrading from 1.17.19 or earlier", () => {
|
|
expect(shouldEnableNewLayout("v1.17.19", "1.17.20")).toBe(true)
|
|
expect(shouldEnableNewLayout("1.16.9", "2.0.0")).toBe(true)
|
|
})
|
|
|
|
test("enables the new layout when no previous version was recorded", () => {
|
|
expect(shouldEnableNewLayout(undefined, "1.17.20")).toBe(true)
|
|
})
|
|
|
|
test("detects upgrades only when a previous version is older", () => {
|
|
expect(isAppUpgrade("1.17.19", "1.17.20")).toBe(true)
|
|
expect(isAppUpgrade(undefined, "1.17.20")).toBe(false)
|
|
expect(isAppUpgrade("1.17.20", "1.17.20")).toBe(false)
|
|
expect(isAppUpgrade("1.17.21", "1.17.20")).toBe(false)
|
|
})
|
|
|
|
test("shows the tabs toast for upgrades and existing installs without a recorded version", () => {
|
|
expect(shouldDisplayTabsToast("1.17.19", "1.17.20", false)).toBe(true)
|
|
expect(shouldDisplayTabsToast(undefined, "1.17.20", true)).toBe(true)
|
|
expect(shouldDisplayTabsToast(undefined, "1.17.20", false)).toBe(false)
|
|
})
|
|
|
|
test("does not enable the new layout without a qualifying upgrade", () => {
|
|
expect(shouldEnableNewLayout("1.17.19", "1.17.19")).toBe(false)
|
|
expect(shouldEnableNewLayout("1.17.20", "1.17.21")).toBe(false)
|
|
expect(shouldEnableNewLayout(undefined, "1.17.19")).toBe(false)
|
|
expect(shouldEnableNewLayout("dev", "1.17.20")).toBe(false)
|
|
})
|
|
})
|