Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fixed unit tests

Blue Mousef3cf2467de7c
diff --git a/app/redux/constants/index.ts b/app/redux/constants/index.ts
index 2b5a5d6ad..0df4ef75d 100644
--- a/app/redux/constants/index.ts
+++ b/app/redux/constants/index.ts
@@ -220,19 +220,20 @@ export const SECURITY_EMAIL: string = '[email protected]'
export const LIVE_VISITORS_UPDATE_INTERVAL: number = 40000
// Environment variables
-const isStaging = isBrowser ? window.REMIX_ENV.STAGING : process.env.STAGING
-const STAGING_API_URL = isBrowser ? window.REMIX_ENV.API_STAGING_URL : process.env.API_STAGING_URL
-const PRODUCTION_API_URL = isBrowser ? window.REMIX_ENV.API_URL : process.env.API_URL
+// Using optional chaining for REMIX_ENV?. to avoid errors when running some unit tests
+const isStaging = isBrowser ? window.REMIX_ENV?.STAGING : process.env.STAGING
+const STAGING_API_URL = isBrowser ? window.REMIX_ENV?.API_STAGING_URL : process.env.API_STAGING_URL
+const PRODUCTION_API_URL = isBrowser ? window.REMIX_ENV?.API_URL : process.env.API_URL
export const API_URL = isStaging ? STAGING_API_URL : PRODUCTION_API_URL
-export const BLOG_URL = isBrowser ? window.REMIX_ENV.BLOG_URL : process.env.BLOG_URL
-export const AIAPI_URL = isBrowser ? window.REMIX_ENV.AIAPI_URL : process.env.AIAPI_URL
-export const CDN_URL = isBrowser ? window.REMIX_ENV.CDN_URL : process.env.CDN_URL
-export const NODE_ENV = isBrowser ? window.REMIX_ENV.NODE_ENV : process.env.NODE_ENV
+export const BLOG_URL = isBrowser ? window.REMIX_ENV?.BLOG_URL : process.env.BLOG_URL
+export const AIAPI_URL = isBrowser ? window.REMIX_ENV?.AIAPI_URL : process.env.AIAPI_URL
+export const CDN_URL = isBrowser ? window.REMIX_ENV?.CDN_URL : process.env.CDN_URL
+export const NODE_ENV = isBrowser ? window.REMIX_ENV?.NODE_ENV : process.env.NODE_ENV
export const isDevelopment = !NODE_ENV || NODE_ENV === 'development'
export const isSelfhosted = Boolean(
- isBrowser ? window.REMIX_ENV.SELFHOSTED : process.env.SELFHOSTED,
+ isBrowser ? window.REMIX_ENV?.SELFHOSTED : process.env.SELFHOSTED,
)
// Functions
diff --git a/app/ui/__test__/Beta.test.tsx b/app/ui/__test__/Beta.test.tsx
index b9f6b030f..d667414b8 100644
--- a/app/ui/__test__/Beta.test.tsx
+++ b/app/ui/__test__/Beta.test.tsx
@@ -4,8 +4,11 @@ import React from 'react'
import { render } from '@testing-library/react'
import { I18nextProvider } from 'react-i18next'
import i18n from 'i18next'
+import '@testing-library/jest-dom'
import Beta from '../Beta'
+global.ResizeObserver = require('resize-observer-polyfill')
+
describe('Beta component', () => {
beforeEach(() => {
i18n.init({
diff --git a/app/ui/__test__/Button.test.tsx b/app/ui/__test__/Button.test.tsx
index 3be5dcc4d..c298b5f13 100644
--- a/app/ui/__test__/Button.test.tsx
+++ b/app/ui/__test__/Button.test.tsx
@@ -26,13 +26,13 @@ describe('Button component', () => {
it('renders a primary button', () => {
const { getByText } = render(<Button text='Click me' primary />)
const button = getByText('Click me')
- expect(button).toHaveClass('bg-indigo-600')
+ expect(button).toHaveClass('bg-slate-900')
})
it('renders a secondary button', () => {
const { getByText } = render(<Button text='Click me' secondary />)
const button = getByText('Click me')
- expect(button).toHaveClass('bg-indigo-100')
+ expect(button).toHaveClass('bg-slate-300')
})
it('renders a white button', () => {
diff --git a/app/ui/__test__/Modal.test.tsx b/app/ui/__test__/Modal.test.tsx
index d08205a4f..1411fcf09 100644
--- a/app/ui/__test__/Modal.test.tsx
+++ b/app/ui/__test__/Modal.test.tsx
@@ -7,6 +7,8 @@ import { I18nextProvider } from 'react-i18next'
import i18n from 'i18next'
import Modal from '../Modal'
+global.ResizeObserver = require('resize-observer-polyfill')
+
describe('Modal component', () => {
const defaultProps: {
type: 'error' | 'success' | 'info' | 'warning' | 'confirmed',