(0);
- const TabContent = TABS[selectedTabIndex].Component;
+ const TabContent = TABS[selectedTabIndex].component;
return (
diff --git a/packages/extension/src/view/settings/components/tabContent/settings/allowedNumberOfTabs/index.tsx b/packages/extension/src/view/settings/components/tabContent/settings/allowedNumberOfTabs/index.tsx
index 39ca7c0b0..7e5a6c9f7 100644
--- a/packages/extension/src/view/settings/components/tabContent/settings/allowedNumberOfTabs/index.tsx
+++ b/packages/extension/src/view/settings/components/tabContent/settings/allowedNumberOfTabs/index.tsx
@@ -62,7 +62,7 @@ const AllowedNumberOfTabs: React.FC = () => {
checked={allowedNumberOfTabs === 'unlimited'}
/>
No restriction (Processing too many tabs may cause the browser to slow
- down)
+ down.) - Tabs would need to be refreshed
);
diff --git a/packages/extension/src/view/settings/components/tabHeader/tests/index.tsx b/packages/extension/src/view/settings/components/tabHeader/tests/index.tsx
new file mode 100644
index 000000000..027d65b4d
--- /dev/null
+++ b/packages/extension/src/view/settings/components/tabHeader/tests/index.tsx
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * External dependencies.
+ */
+import React from 'react';
+import { fireEvent, render, screen } from '@testing-library/react';
+import { act } from 'react-dom/test-utils';
+import '@testing-library/jest-dom';
+
+/**
+ * Internal dependencies.
+ */
+import TabHeader from '..';
+import TABS from '../../../tabs';
+describe('TabHeader', () => {
+ it('Should render without issue.', async () => {
+ act(() =>
+ render(
+ tab.display_name)}
+ selectedTabIndex={0}
+ setSelectedTabIndex={() => undefined}
+ />
+ )
+ );
+ expect(await screen.findByText('Settings')).toBeInTheDocument();
+ });
+ it('Should render without issue.', () => {
+ const setSelectedIndexMock = jest.fn();
+ act(() =>
+ render(
+ tab.display_name)}
+ selectedTabIndex={0}
+ setSelectedTabIndex={setSelectedIndexMock}
+ />
+ )
+ );
+ fireEvent.click(screen.getByText('Settings'));
+ expect(setSelectedIndexMock).toHaveBeenCalled();
+ });
+});
diff --git a/packages/extension/src/view/settings/tabs.ts b/packages/extension/src/view/settings/tabs.ts
new file mode 100644
index 000000000..42c70f6d4
--- /dev/null
+++ b/packages/extension/src/view/settings/tabs.ts
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Internal dependencies.
+ */
+import Settings from './components/tabContent/settings';
+
+const TABS = [
+ {
+ display_name: 'Settings',
+ id: 'settings',
+ component: Settings,
+ },
+];
+
+export default TABS;
diff --git a/packages/extension/src/view/settings/tests/index.tsx b/packages/extension/src/view/settings/tests/index.tsx
new file mode 100644
index 000000000..114fb3090
--- /dev/null
+++ b/packages/extension/src/view/settings/tests/index.tsx
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * External dependencies.
+ */
+import React from 'react';
+import { render, screen } from '@testing-library/react';
+import { act } from 'react-dom/test-utils';
+import '@testing-library/jest-dom';
+import SinonChrome from 'sinon-chrome';
+
+/**
+ * Internal dependencies.
+ */
+import App from '../app';
+import { Provider as SettingsProvider } from '../stateProviders/syncSettingsStore';
+describe('Index', () => {
+ beforeAll(() => {
+ globalThis.chrome = SinonChrome as unknown as typeof chrome;
+ globalThis.chrome = {
+ ...SinonChrome,
+ storage: {
+ //@ts-ignore
+ local: {
+ clear: () => Promise.resolve(),
+ //@ts-ignore
+ onChanged: {
+ addListener: () => undefined,
+ removeListener: () => undefined,
+ },
+ },
+ sync: {
+ //@ts-ignore
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ get: (_, __) =>
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ new Promise<{ [key: string]: any }>((resolve) => {
+ resolve({
+ allowedNumberOfTabs: 'single',
+ });
+ }),
+ //@ts-ignore
+ onChanged: {
+ addListener: () => undefined,
+ removeListener: () => undefined,
+ },
+ },
+ },
+ };
+ });
+
+ it('All Providers should be added to DOM', async () => {
+ act(() =>
+ render(
+
+
+
+ )
+ );
+ expect(await screen.findByText('Settings')).toBeInTheDocument();
+ });
+
+ afterAll(() => {
+ globalThis.chrome = undefined as unknown as typeof chrome;
+ });
+});
diff --git a/packages/extension/src/worker/service-worker.ts b/packages/extension/src/worker/service-worker.ts
index 99a66ec55..5ca3f9323 100644
--- a/packages/extension/src/worker/service-worker.ts
+++ b/packages/extension/src/worker/service-worker.ts
@@ -286,8 +286,8 @@ chrome.runtime.onInstalled.addListener(async (details) => {
});
}
if (details.reason === 'update') {
- const preSetSettings = chrome.storage.sync.get();
- if (Object.keys(preSetSettings).length === 2) {
+ const preSetSettings = await chrome.storage.sync.get();
+ if (preSetSettings?.allowedNumberOfTabs) {
return;
}
await chrome.storage.sync.clear();
diff --git a/tests/jest.config.cjs b/tests/jest.config.cjs
index 382a2bab9..abb740166 100644
--- a/tests/jest.config.cjs
+++ b/tests/jest.config.cjs
@@ -48,6 +48,7 @@ module.exports = {
'/packages/extension/src/view/devtools/index.tsx',
'/packages/extension/src/view/popup/index.tsx',
'/packages/extension/src/view/devtools/devtools.ts',
+ '/packages/extension/src/view/settings/index.tsx',
],
coverageReporters: ['lcov'],
collectCoverageFrom: [