Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 18 additions & 1 deletion packages/react-chat/src/utils/assistant.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { VoiceflowRuntime } from '@voiceflow/sdk-runtime';
import { createMock } from '@voiceflow/test-common/vitest';
import type { Mock } from 'vitest';
import { describe, expect, it, vi } from 'vitest';
import { beforeEach, describe, expect, it, vi } from 'vitest';

import type { RawAssistantOptions } from '@/dtos/AssistantOptions.dto';
import { DEFAULT_AVATAR } from '@/dtos/AssistantOptions.dto';
Expand Down Expand Up @@ -148,5 +148,22 @@ describe('assistant utils', () => {
extensions: [],
});
});

describe('window.location', () => {
beforeEach(() => {
vi.spyOn(window, 'location', 'get').mockReturnValue({
...window.location,
hostname: 'store.myshopify.com',
});
});

it('should not show watermark on myshopify.com', async () => {
mockGetPublishing().mockResolvedValue({ watermark: true });

const merged = await mergeAssistantOptions(config, {});

expect(merged.watermark).toBe(false);
});
});
});
});
9 changes: 8 additions & 1 deletion packages/react-chat/src/utils/assistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const mergeAssistantOptions = async (
...publishing,
...overrides,
// watermark can not be overridden with local config
watermark: publishing?.watermark,
watermark: showWatermark(publishing?.watermark),
feedback: publishing?.feedback,
spacing: {
...publishing?.spacing,
Expand All @@ -34,3 +34,10 @@ export const mergeAssistantOptions = async (
extensions: [...(publishing?.extensions ?? []), ...(overrides?.extensions ?? [])],
});
};

const showWatermark = (watermark: boolean | undefined) => {
if (window.location.hostname.endsWith('.myshopify.com')) {
return false;
}
return watermark;
};
Loading