From 0d3b8a0c360fc2d81184a05e6653440fffbaee4b Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> Date: Thu, 6 Feb 2025 16:19:36 +0200 Subject: [PATCH] Do not show connection error before it has been requested --- .../components/PushConnectionTracker.test.ts | 17 +++++++++++++++-- .../src/components/PushConnectionTracker.vue | 11 ++++++++++- .../PushConnectionTracker.test.ts.snap | 13 +++++++++++-- .../src/stores/pushConnection.store.ts | 18 ++++++++++++++++-- 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/packages/editor-ui/src/components/PushConnectionTracker.test.ts b/packages/editor-ui/src/components/PushConnectionTracker.test.ts index 2671a80eaca45..5e6c37157c848 100644 --- a/packages/editor-ui/src/components/PushConnectionTracker.test.ts +++ b/packages/editor-ui/src/components/PushConnectionTracker.test.ts @@ -5,11 +5,13 @@ import { createTestingPinia } from '@pinia/testing'; import { setActivePinia } from 'pinia'; let isConnected = true; +let isConnectionRequested = true; vi.mock('@/stores/pushConnection.store', () => { return { usePushConnectionStore: vi.fn(() => ({ isConnected, + isConnectionRequested, })), }; }); @@ -21,6 +23,7 @@ describe('PushConnectionTracker', () => { initialState: { [STORES.PUSH]: { isConnected, + isConnectionRequested, }, }, }); @@ -29,15 +32,25 @@ describe('PushConnectionTracker', () => { return createComponentRenderer(PushConnectionTracker)(); }; - it('should render when connected', () => { + it('should not render error when connected and connection requested', () => { isConnected = true; + isConnectionRequested = true; const { container } = render(); expect(container).toMatchSnapshot(); }); - it('should render when disconnected', () => { + it('should render error when disconnected and connection requested', () => { isConnected = false; + isConnectionRequested = true; + const { container } = render(); + + expect(container).toMatchSnapshot(); + }); + + it('should not render error when connected and connection not requested', () => { + isConnected = true; + isConnectionRequested = false; const { container } = render(); expect(container).toMatchSnapshot(); diff --git a/packages/editor-ui/src/components/PushConnectionTracker.vue b/packages/editor-ui/src/components/PushConnectionTracker.vue index f673f13add01b..0ce23634b0ac5 100644 --- a/packages/editor-ui/src/components/PushConnectionTracker.vue +++ b/packages/editor-ui/src/components/PushConnectionTracker.vue @@ -1,14 +1,23 @@