mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-01 01:52:30 +01:00
Hide whats-new modal on public demo
This commit is contained in:
@@ -1130,6 +1130,10 @@ product copy, or external links back into the shared shell. Internal product
|
|||||||
navigation from that shell should still route through canonical shared helpers
|
navigation from that shell should still route through canonical shared helpers
|
||||||
such as `frontend-modern/src/routing/resourceLinks.ts` rather than freezing raw
|
such as `frontend-modern/src/routing/resourceLinks.ts` rather than freezing raw
|
||||||
`/recovery?...` route strings into the modal itself.
|
`/recovery?...` route strings into the modal itself.
|
||||||
|
That state owner now also owns public-demo suppression: the modal must stay
|
||||||
|
closed until `sessionPresentationPolicyResolved()` is true and must fail closed
|
||||||
|
when `presentationPolicyIsDemoMode()` resolves true, so the public demo does
|
||||||
|
not front-load product migration onboarding ahead of the actual surface.
|
||||||
Canonical customer disclosures inside those shared shells now route through
|
Canonical customer disclosures inside those shared shells now route through
|
||||||
`frontend-modern/src/utils/docsLinks.ts`, so settings and what's-new privacy
|
`frontend-modern/src/utils/docsLinks.ts`, so settings and what's-new privacy
|
||||||
links resolve to shipped `/docs/...` assets instead of hard-coded GitHub
|
links resolve to shipped `/docs/...` assets instead of hard-coded GitHub
|
||||||
|
|||||||
@@ -1134,6 +1134,8 @@ describe('shared primitive guardrails', () => {
|
|||||||
expect(whatsNewModalStateSource).toContain('createLocalStorageBooleanSignal');
|
expect(whatsNewModalStateSource).toContain('createLocalStorageBooleanSignal');
|
||||||
expect(whatsNewModalStateSource).toContain('createSignal');
|
expect(whatsNewModalStateSource).toContain('createSignal');
|
||||||
expect(whatsNewModalStateSource).toContain('STORAGE_KEYS.WHATS_NEW_NAV_V2_SHOWN');
|
expect(whatsNewModalStateSource).toContain('STORAGE_KEYS.WHATS_NEW_NAV_V2_SHOWN');
|
||||||
|
expect(whatsNewModalStateSource).toContain('sessionPresentationPolicyResolved');
|
||||||
|
expect(whatsNewModalStateSource).toContain('presentationPolicyIsDemoMode');
|
||||||
expect(whatsNewModalStateSource).toContain('handleClose');
|
expect(whatsNewModalStateSource).toContain('handleClose');
|
||||||
|
|
||||||
expect(whatsNewModalModelSource).toContain('WHATS_NEW_FEATURE_CARDS');
|
expect(whatsNewModalModelSource).toContain('WHATS_NEW_FEATURE_CARDS');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
|
import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
|
||||||
import { WhatsNewModal } from '@/components/shared/WhatsNewModal';
|
import { WhatsNewModal } from '@/components/shared/WhatsNewModal';
|
||||||
import whatsNewModalSource from '@/components/shared/WhatsNewModal.tsx?raw';
|
import whatsNewModalSource from '@/components/shared/WhatsNewModal.tsx?raw';
|
||||||
@@ -6,9 +6,19 @@ import whatsNewModalModelSource from '@/components/shared/whatsNewModalModel.ts?
|
|||||||
import whatsNewModalStateSource from '@/components/shared/useWhatsNewModalState.ts?raw';
|
import whatsNewModalStateSource from '@/components/shared/useWhatsNewModalState.ts?raw';
|
||||||
import { STORAGE_KEYS } from '@/utils/localStorage';
|
import { STORAGE_KEYS } from '@/utils/localStorage';
|
||||||
|
|
||||||
|
const presentationPolicyIsDemoModeMock = vi.hoisted(() => vi.fn(() => false));
|
||||||
|
const sessionPresentationPolicyResolvedMock = vi.hoisted(() => vi.fn(() => true));
|
||||||
|
|
||||||
|
vi.mock('@/stores/sessionPresentationPolicy', () => ({
|
||||||
|
presentationPolicyIsDemoMode: presentationPolicyIsDemoModeMock,
|
||||||
|
sessionPresentationPolicyResolved: sessionPresentationPolicyResolvedMock,
|
||||||
|
}));
|
||||||
|
|
||||||
describe('WhatsNewModal', () => {
|
describe('WhatsNewModal', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
|
presentationPolicyIsDemoModeMock.mockReturnValue(false);
|
||||||
|
sessionPresentationPolicyResolvedMock.mockReturnValue(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -31,6 +41,8 @@ describe('WhatsNewModal', () => {
|
|||||||
expect(whatsNewModalStateSource).toContain('createLocalStorageBooleanSignal');
|
expect(whatsNewModalStateSource).toContain('createLocalStorageBooleanSignal');
|
||||||
expect(whatsNewModalStateSource).toContain('createSignal');
|
expect(whatsNewModalStateSource).toContain('createSignal');
|
||||||
expect(whatsNewModalStateSource).toContain('STORAGE_KEYS.WHATS_NEW_NAV_V2_SHOWN');
|
expect(whatsNewModalStateSource).toContain('STORAGE_KEYS.WHATS_NEW_NAV_V2_SHOWN');
|
||||||
|
expect(whatsNewModalStateSource).toContain('sessionPresentationPolicyResolved');
|
||||||
|
expect(whatsNewModalStateSource).toContain('presentationPolicyIsDemoMode');
|
||||||
expect(whatsNewModalStateSource).toContain('handleClose');
|
expect(whatsNewModalStateSource).toContain('handleClose');
|
||||||
|
|
||||||
expect(whatsNewModalModelSource).toContain('WHATS_NEW_FEATURE_CARDS');
|
expect(whatsNewModalModelSource).toContain('WHATS_NEW_FEATURE_CARDS');
|
||||||
@@ -56,6 +68,16 @@ describe('WhatsNewModal', () => {
|
|||||||
expect(screen.getByText('Welcome to the New Navigation!')).toBeInTheDocument();
|
expect(screen.getByText('Welcome to the New Navigation!')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('stays hidden for public demo sessions', async () => {
|
||||||
|
presentationPolicyIsDemoModeMock.mockReturnValue(true);
|
||||||
|
|
||||||
|
render(() => <WhatsNewModal />);
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('closes on backdrop click and records the modal as seen by default', async () => {
|
it('closes on backdrop click and records the modal as seen by default', async () => {
|
||||||
render(() => <WhatsNewModal />);
|
render(() => <WhatsNewModal />);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import { createSignal } from 'solid-js';
|
import { createSignal } from 'solid-js';
|
||||||
import { createLocalStorageBooleanSignal, STORAGE_KEYS } from '@/utils/localStorage';
|
import { createLocalStorageBooleanSignal, STORAGE_KEYS } from '@/utils/localStorage';
|
||||||
|
import {
|
||||||
|
presentationPolicyIsDemoMode,
|
||||||
|
sessionPresentationPolicyResolved,
|
||||||
|
} from '@/stores/sessionPresentationPolicy';
|
||||||
|
|
||||||
export function useWhatsNewModalState() {
|
export function useWhatsNewModalState() {
|
||||||
const [hasSeen, setHasSeen] = createLocalStorageBooleanSignal(
|
const [hasSeen, setHasSeen] = createLocalStorageBooleanSignal(
|
||||||
@@ -9,7 +13,11 @@ export function useWhatsNewModalState() {
|
|||||||
const [dontShowAgain, setDontShowAgain] = createSignal(true);
|
const [dontShowAgain, setDontShowAgain] = createSignal(true);
|
||||||
const [dismissedForSession, setDismissedForSession] = createSignal(false);
|
const [dismissedForSession, setDismissedForSession] = createSignal(false);
|
||||||
|
|
||||||
const isOpen = () => !hasSeen() && !dismissedForSession();
|
const isOpen = () =>
|
||||||
|
sessionPresentationPolicyResolved() &&
|
||||||
|
!presentationPolicyIsDemoMode() &&
|
||||||
|
!hasSeen() &&
|
||||||
|
!dismissedForSession();
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
if (dontShowAgain()) {
|
if (dontShowAgain()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user