From 1fd4c7bee0e627e7fcc940be218ed4d30f80d378 Mon Sep 17 00:00:00 2001 From: Didd Tuni Date: Thu, 6 Jun 2024 21:12:56 +0300 Subject: [PATCH] chore(): clean up and fix tests v1 --- extensions/apps/antenna/jest.setup.js | 26 +-- .../components/__tests__/beam-page.spec.tsx | 188 ++++++++++------ .../__tests__/global-antenna-page.spec.tsx | 47 ---- .../__tests__/pending-reflect.spec.tsx | 29 --- .../__tests__/reflection-page.spec.tsx | 47 ---- .../__tests__/tag-feed-page.spec.tsx | 19 -- .../src/components/app-routes/data-loaders.ts | 20 ++ .../src/components/app-routes/index.tsx | 29 ++- .../components/pages/entry-page/beam-page.tsx | 39 +--- .../reflect-editor/pending-reflect.tsx | 1 - .../src/components/__tests__/connect.spec.tsx | 28 --- .../components/__tests__/apps-page.spec.tsx | 18 -- .../__tests__/explore-page.spec.tsx | 18 -- .../__tests__/my-apps-page.spec.tsx | 18 -- .../__tests__/my-widgets-page.spec.tsx | 18 -- .../customize-notification-page.spec.tsx | 16 -- .../__tests__/welcome-page.spec.tsx | 22 -- extensions/apps/profile/jest.setup.js | 6 +- .../__tests__/profile-edit-general.spec.tsx | 78 ------- .../__tests__/profile-info.spec.tsx | 110 ---------- .../components/__tests__/search-page.spec.tsx | 41 ---- .../src/components/pages/entry-renderer.tsx | 2 +- .../__tests__/settings-page.spec.tsx | 17 -- .../components/__tests__/dashboard.spec.tsx | 26 --- .../components/__tests__/moderators.spec.tsx | 26 --- .../__tests__/no-items-found.spec.tsx | 31 --- .../components/__tests__/overview.spec.tsx | 26 --- extensions/jest.setup.js | 52 ++++- .../__tests__/cookie-widget.spec.tsx | 18 -- .../__tests__/sidebar-widget.spec.tsx | 32 --- .../__tests__/topbar-component.spec.tsx | 33 --- .../trending-widget-component.spec.tsx | 25 --- libs/design-system-components/jest.setup.js | 2 +- .../src/components/Entry/EntryCard/index.tsx | 6 +- .../dscomponents/entry-card.stories.tsx | 2 +- .../vibes-console-content-card.stories.tsx | 2 +- libs/design-system-core/jest.config.cjs | 1 - libs/design-system-core/jest.setup.js | 2 - .../AppAvatar/__tests__/index.test.tsx | 1 + libs/design-system-core/tsconfig.json | 2 +- libs/extensions/jest.setup.js | 2 +- .../__mocks__/get-reflection-feed-mocks.ts | 85 ++++++++ libs/feed/src/__tests__/__mocks__/index.tsx | 1 + .../cards/author-profile-avatar/index.tsx | 109 +++++----- .../src/components/cards/beam-card/index.tsx | 2 +- .../cards/reflection-card/index.tsx | 2 +- .../components/reflection-preview/index.tsx | 1 - package.json | 6 +- tests/ethereum-world/cypress.config.ts | 12 -- .../cypress/fixtures/example.json | 5 - .../cypress/integration/antennapage.spec.ts | 53 ----- .../cypress/integration/bookmarks.spec.ts | 13 -- .../cypress/integration/extensions.spec.ts | 13 -- .../cypress/integration/legalpages.spec.ts | 61 ------ .../cypress/integration/notifications.spec.ts | 13 -- .../partials/layout-widget.spec.ts | 23 -- .../integration/partials/topbar.spec.ts | 7 - .../partials/trendingWidget.spec.ts | 7 - .../cypress/integration/profilepage.spec.ts | 31 --- .../cypress/integration/searchpage.spec.ts | 17 -- .../cypress/integration/sign-in-up.spec.ts | 13 -- .../cypress/integration/tagpage.spec.ts | 30 --- tests/ethereum-world/cypress/local.json | 6 - tests/ethereum-world/cypress/production.json | 6 - .../ethereum-world/cypress/pull-request.json | 5 - tests/ethereum-world/cypress/staging.json | 6 - .../cypress/support/commands.ts | 30 --- tests/ethereum-world/cypress/support/e2e.ts | 20 -- tests/ethereum-world/cypress/support/hooks.ts | 4 - tests/ethereum-world/cypress/support/index.ts | 20 -- tests/ethereum-world/cypress/tsconfig.json | 8 - .../ethereum-world/cypress/utils/constants.ts | 1 - tests/ethereum-world/cypress/utils/index.ts | 8 - tests/src/data-generator/beam.ts | 59 ------ tests/src/data-generator/reflection.ts | 28 --- tests/src/data-generator/user.ts | 59 ------ tests/src/index.ts | 48 ----- tests/src/mocks/operator.ts | 9 - tests/src/providers.tsx | 64 ------ tests/tsconfig.json | 9 - tests/{ => utils}/package.json | 0 tests/{ => utils}/project.json | 6 +- .../data-generator/app-loader-extensions.ts | 0 tests/utils/src/data-generator/beam.ts | 200 ++++++++++++++++++ tests/{ => utils}/src/data-generator/index.ts | 0 .../src/data-generator/integrations.ts | 7 +- tests/utils/src/data-generator/reflection.ts | 179 ++++++++++++++++ tests/{ => utils}/src/data-generator/store.ts | 10 +- tests/utils/src/data-generator/user.ts | 34 +++ .../src/data-generator/world-config.ts | 0 tests/utils/src/index.ts | 32 +++ tests/{ => utils}/src/mocks/localStorage.ts | 0 tests/{ => utils}/src/mocks/single-spa.ts | 0 tests/{ => utils}/src/mocks/uiEvents.ts | 2 +- tests/utils/src/providers.tsx | 42 ++++ tests/{src/utils => utils/src}/toBinary.ts | 0 tests/utils/tsconfig.json | 9 + yarn.lock | 89 +++----- 98 files changed, 939 insertions(+), 1691 deletions(-) delete mode 100644 extensions/apps/antenna/src/components/__tests__/global-antenna-page.spec.tsx delete mode 100644 extensions/apps/antenna/src/components/__tests__/pending-reflect.spec.tsx delete mode 100644 extensions/apps/antenna/src/components/__tests__/reflection-page.spec.tsx delete mode 100644 extensions/apps/antenna/src/components/__tests__/tag-feed-page.spec.tsx delete mode 100644 extensions/apps/auth-app/src/components/__tests__/connect.spec.tsx delete mode 100644 extensions/apps/extensions/src/components/__tests__/apps-page.spec.tsx delete mode 100644 extensions/apps/extensions/src/components/__tests__/explore-page.spec.tsx delete mode 100644 extensions/apps/extensions/src/components/__tests__/my-apps-page.spec.tsx delete mode 100644 extensions/apps/extensions/src/components/__tests__/my-widgets-page.spec.tsx delete mode 100644 extensions/apps/notifications/src/components/__tests__/customize-notification-page.spec.tsx delete mode 100644 extensions/apps/notifications/src/components/__tests__/welcome-page.spec.tsx delete mode 100644 extensions/apps/profile/src/components/__tests__/profile-edit-general.spec.tsx delete mode 100644 extensions/apps/profile/src/components/__tests__/profile-info.spec.tsx delete mode 100644 extensions/apps/search/src/components/__tests__/search-page.spec.tsx delete mode 100644 extensions/apps/settings/src/components/__tests__/settings-page.spec.tsx delete mode 100644 extensions/apps/vibes-console/src/components/__tests__/dashboard.spec.tsx delete mode 100644 extensions/apps/vibes/src/components/__tests__/moderators.spec.tsx delete mode 100644 extensions/apps/vibes/src/components/__tests__/no-items-found.spec.tsx delete mode 100644 extensions/apps/vibes/src/components/__tests__/overview.spec.tsx delete mode 100644 extensions/widgets/analytics/src/components/__tests__/cookie-widget.spec.tsx delete mode 100644 extensions/widgets/sidebar/src/components/__tests__/sidebar-widget.spec.tsx delete mode 100644 extensions/widgets/top-bar/src/components/__tests__/topbar-component.spec.tsx delete mode 100644 extensions/widgets/trending/src/components/__tests__/trending-widget-component.spec.tsx create mode 100644 libs/feed/src/__tests__/__mocks__/get-reflection-feed-mocks.ts create mode 100644 libs/feed/src/__tests__/__mocks__/index.tsx delete mode 100644 tests/ethereum-world/cypress.config.ts delete mode 100644 tests/ethereum-world/cypress/fixtures/example.json delete mode 100644 tests/ethereum-world/cypress/integration/antennapage.spec.ts delete mode 100644 tests/ethereum-world/cypress/integration/bookmarks.spec.ts delete mode 100644 tests/ethereum-world/cypress/integration/extensions.spec.ts delete mode 100644 tests/ethereum-world/cypress/integration/legalpages.spec.ts delete mode 100644 tests/ethereum-world/cypress/integration/notifications.spec.ts delete mode 100644 tests/ethereum-world/cypress/integration/partials/layout-widget.spec.ts delete mode 100644 tests/ethereum-world/cypress/integration/partials/topbar.spec.ts delete mode 100644 tests/ethereum-world/cypress/integration/partials/trendingWidget.spec.ts delete mode 100644 tests/ethereum-world/cypress/integration/profilepage.spec.ts delete mode 100644 tests/ethereum-world/cypress/integration/searchpage.spec.ts delete mode 100644 tests/ethereum-world/cypress/integration/sign-in-up.spec.ts delete mode 100644 tests/ethereum-world/cypress/integration/tagpage.spec.ts delete mode 100644 tests/ethereum-world/cypress/local.json delete mode 100644 tests/ethereum-world/cypress/production.json delete mode 100644 tests/ethereum-world/cypress/pull-request.json delete mode 100644 tests/ethereum-world/cypress/staging.json delete mode 100644 tests/ethereum-world/cypress/support/commands.ts delete mode 100644 tests/ethereum-world/cypress/support/e2e.ts delete mode 100644 tests/ethereum-world/cypress/support/hooks.ts delete mode 100644 tests/ethereum-world/cypress/support/index.ts delete mode 100644 tests/ethereum-world/cypress/tsconfig.json delete mode 100644 tests/ethereum-world/cypress/utils/constants.ts delete mode 100644 tests/ethereum-world/cypress/utils/index.ts delete mode 100644 tests/src/data-generator/beam.ts delete mode 100644 tests/src/data-generator/reflection.ts delete mode 100644 tests/src/data-generator/user.ts delete mode 100644 tests/src/index.ts delete mode 100644 tests/src/mocks/operator.ts delete mode 100644 tests/src/providers.tsx delete mode 100644 tests/tsconfig.json rename tests/{ => utils}/package.json (100%) rename tests/{ => utils}/project.json (85%) rename tests/{ => utils}/src/data-generator/app-loader-extensions.ts (100%) create mode 100644 tests/utils/src/data-generator/beam.ts rename tests/{ => utils}/src/data-generator/index.ts (100%) rename tests/{ => utils}/src/data-generator/integrations.ts (93%) create mode 100644 tests/utils/src/data-generator/reflection.ts rename tests/{ => utils}/src/data-generator/store.ts (83%) create mode 100644 tests/utils/src/data-generator/user.ts rename tests/{ => utils}/src/data-generator/world-config.ts (100%) create mode 100644 tests/utils/src/index.ts rename tests/{ => utils}/src/mocks/localStorage.ts (100%) rename tests/{ => utils}/src/mocks/single-spa.ts (100%) rename tests/{ => utils}/src/mocks/uiEvents.ts (53%) create mode 100644 tests/utils/src/providers.tsx rename tests/{src/utils => utils/src}/toBinary.ts (100%) create mode 100644 tests/utils/tsconfig.json diff --git a/extensions/apps/antenna/jest.setup.js b/extensions/apps/antenna/jest.setup.js index 7972386572..186fa84e28 100644 --- a/extensions/apps/antenna/jest.setup.js +++ b/extensions/apps/antenna/jest.setup.js @@ -1,15 +1,14 @@ -import './jest.setup'; +import '../../jest.setup'; -import { genLoggedInState } from '@akashaorg/af-testing'; -import * as loginHooks from '@akashaorg/ui-awf-hooks/lib/use-login.new'; import * as mediaHooks from '@akashaorg/ui-awf-hooks/lib/utils/media-utils'; jest.mock('@akashaorg/typings/lib/ui', () => ({ EntityTypes: { - POST: 0, + BEAM: 0, PROFILE: 1, - REPLY: 2, + REFLECT: 2, TAG: 3, + ARTICLE: 4, }, EventTypes: { Instantiated: 'instantiated', @@ -37,20 +36,3 @@ jest.mock('@akashaorg/typings/lib/ui', () => ({ jest .spyOn(mediaHooks, 'getMediaUrl') .mockReturnValue({ originLink: '', fallbackLink: '', pathLink: '' }); - -jest.spyOn(loginHooks, 'useGetLogin').mockReturnValue({ - data: { ...genLoggedInState(true) }, - status: 'success', - isSuccess: true, - reported: true, -}); - -const mockIntersectionObserver = jest.fn(); - -mockIntersectionObserver.mockReturnValue({ - observe: () => null, - unobserve: () => null, - disconnect: () => null, -}); - -global.IntersectionObserver = mockIntersectionObserver; diff --git a/extensions/apps/antenna/src/components/__tests__/beam-page.spec.tsx b/extensions/apps/antenna/src/components/__tests__/beam-page.spec.tsx index 8cd75a0064..eca1b281cb 100644 --- a/extensions/apps/antenna/src/components/__tests__/beam-page.spec.tsx +++ b/extensions/apps/antenna/src/components/__tests__/beam-page.spec.tsx @@ -1,90 +1,158 @@ import React from 'react'; import BeamPage from '../pages/entry-page/beam-page'; -import * as apolloHooks from '@akashaorg/ui-awf-hooks/lib/generated/apollo'; -import * as useBeamsHook from '@akashaorg/ui-awf-hooks/lib/use-beams'; -import * as useReflectionsHook from '@akashaorg/ui-awf-hooks/lib/use-reflections'; - import { screen, renderWithAllProviders, act, genAppProps, genBeamData, - genUser, + waitFor, + genContentBlock, + genReflectionStream, + genProfileByDID, } from '@akashaorg/af-testing'; import { AnalyticsProvider } from '@akashaorg/ui-awf-hooks/lib/use-analytics'; +import { AkashaBeamStreamModerationStatus } from '@akashaorg/typings/lib/sdk/graphql-types-new'; +import { mapBeamEntryData } from '@akashaorg/ui-awf-hooks'; +import { + GetProfileByDidDocument, + GetContentBlockByIdDocument, + GetReflectionStreamDocument, + GetBeamByIdDocument, +} from '@akashaorg/ui-awf-hooks/lib/generated/apollo'; +import { formatRelativeTime, truncateDid } from '@akashaorg/design-system-core/lib/utils'; +import { getReflectionFeedMocks } from '@akashaorg/ui-lib-feed/lib/__tests__/__mocks__/get-reflection-feed-mocks'; -class ResizeObserver { - observe() { - return; - } - unobserve() { - return; - } - disconnect() { - return; - } -} +const BEAM_SECTION = { + profileDID: 'did:pkh:eip155:11155111:0x1d3ac7a3d118f60a726f2dc52a614b2a6ae8dd00', + beamId: 'kjzl6kcym7w8y5coci0at0tquy8zmferlog88ys14oj2qgyjy8soxzpbflmlzey', + reflectionId: 'kjzl6kcym7w8y4wm6o3ikwiwttnsr6f7g0tkpqojlwsmp2r9wehvfapuvkfqqjn', + content: 'Beam', +}; + +const REFLECT_FEED = { + authorProfileDID: 'did:pkh:eip155:11155111:0x404ea3f8e4a5fcc8bdcdb7a74f25357113fdf989', + beamId: BEAM_SECTION.beamId, + reflectionId: 'kjzl6kcym7w8yaknlainhkpejftbsmffx9799hf1nrmkptk2gvqi7t27d3rp1ve', + content: 'Reflection', + preview: { + reflectionId: 'kjzl6kcym7w8y70ra8llsn1l6qi4iy9d5g1acypb2uh9bl1bw479h92gygkmze3', + content: 'Reflection Preview', + }, +}; describe('< BeamPage /> component', () => { - global.ResizeObserver = ResizeObserver; + const beamData = genBeamData({ + beamId: BEAM_SECTION.beamId, + authorProfileDID: BEAM_SECTION.profileDID, + }); + const profileData = genProfileByDID(BEAM_SECTION.profileDID); const BaseComponent = ( ); beforeEach(async () => { await act(async () => { - renderWithAllProviders(BaseComponent, {}); + renderWithAllProviders( + BaseComponent, + {}, + { + mocks: [ + { + request: { + query: GetProfileByDidDocument, + }, + variableMatcher: () => true, + result: { + data: { + node: profileData, + }, + }, + }, + { + request: { + query: GetBeamByIdDocument, + }, + variableMatcher: () => true, + result: { + data: { + node: genBeamData({ + beamId: BEAM_SECTION.beamId, + authorProfileDID: BEAM_SECTION.profileDID, + reflectionsCount: BEAM_SECTION.reflectionCount, + }), + }, + }, + }, + ...beamData.content.map(block => ({ + request: { + query: GetContentBlockByIdDocument, + }, + variableMatcher: () => true, + result: { + data: { + node: genContentBlock({ + blockId: block.blockID, + authorProfileDID: BEAM_SECTION.profileDID, + content: BEAM_SECTION.content, + }), + }, + }, + })), + { + request: { + query: GetReflectionStreamDocument, + }, + variableMatcher: () => true, + result: { + data: { + node: genReflectionStream({ + beamId: BEAM_SECTION.beamId, + reflectionId: BEAM_SECTION.reflectionId, + }), + }, + }, + }, + ...getReflectionFeedMocks({ + beamId: REFLECT_FEED.beamId, + reflectionId: REFLECT_FEED.preview.reflectionId, + authorProfileDID: REFLECT_FEED.authorProfileDID, + reflectionContent: REFLECT_FEED.content, + reflectionPreviewContent: REFLECT_FEED.preview.content, + }), + ], + }, + ); }); }); - beforeAll(() => { - ( - jest.spyOn(apolloHooks, 'useGetReflectReflectionsLazyQuery') as unknown as jest.SpyInstance< - [ - typeof jest.fn, - { - data: unknown; - isLoading: boolean; - }, - ] - > - ).mockReturnValue([ - jest.fn().mockReturnValue({ data: undefined }), - { data: {}, isLoading: false }, - ]); - ( - jest.spyOn(apolloHooks, 'useGetMyProfileQuery') as unknown as jest.SpyInstance<{ - data: { viewer: { akashaProfile: ReturnType } }; - }> - ).mockReturnValue({ - data: { - viewer: { - akashaProfile: genUser('did:pkh:eip155:5:0xc47a483494db8fe455ba29a53a7f75349dfc02ff'), - }, - }, + //TODO add test case for publishing reflection + it('should render beam section', async () => { + await waitFor(() => { + expect(screen.getAllByTestId('info-box')[0]).toHaveTextContent( + profileData.akashaProfile.name, + ); + expect(screen.getAllByTestId('info-box')[0]).toHaveTextContent( + truncateDid(profileData.akashaProfile.did.id), + ); + expect(screen.getAllByTestId('info-box')[0]).toHaveTextContent( + formatRelativeTime(beamData.createdAt, 'en'), + ); + expect(screen.getByText(/Share your thoughts/i)).toBeInTheDocument(); + expect(screen.getByRole('button', { name: 'Reflect' })).toBeInTheDocument(); }); - ( - jest.spyOn(useBeamsHook, 'useBeams') as unknown as jest.SpyInstance<{ - data: unknown; - }> - ).mockReturnValue({ data: {} }); - ( - jest.spyOn(useReflectionsHook, 'useReflections') as unknown as jest.SpyInstance<{ - reflections: unknown[]; - fetchInitialData: typeof jest.fn; - }> - ).mockReturnValue({ reflections: [], fetchInitialData: jest.fn }); }); - it.skip('should render beam page', async () => { - expect(screen.getByText(/Share your thoughts/i)).toBeInTheDocument(); - expect(screen.getByRole('button', { name: /Reflect/i })).toBeInTheDocument(); + it('should render reflect feed', async () => { + await waitFor(() => { + expect(screen.getByText(REFLECT_FEED.content)).toBeInTheDocument(); + expect(screen.getByText(REFLECT_FEED.preview.content)).toBeInTheDocument(); + }); }); }); diff --git a/extensions/apps/antenna/src/components/__tests__/global-antenna-page.spec.tsx b/extensions/apps/antenna/src/components/__tests__/global-antenna-page.spec.tsx deleted file mode 100644 index 1e61286eaa..0000000000 --- a/extensions/apps/antenna/src/components/__tests__/global-antenna-page.spec.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import React from 'react'; -import GlobalAntennaPage from '../pages/global-antenna-page'; - -import { screen, renderWithAllProviders, genAppProps, genUser } from '@akashaorg/af-testing'; -import { AnalyticsProvider } from '@akashaorg/ui-awf-hooks/lib/use-analytics'; -import { act } from 'react-dom/test-utils'; -class ResizeObserver { - observe() { - return; - } - unobserve() { - return; - } - disconnect() { - return; - } -} -describe('< GlobalAntennaPage /> component', () => { - global.ResizeObserver = ResizeObserver; - const BaseComponent = ({ authenticatedProfile }) => ( - - - - ); - - it.skip('should render feed page for anonymous users', async () => { - await act(async () => { - renderWithAllProviders(, {}); - }); - expect(screen.getByText(/Loading.../i)).toBeInTheDocument(); - }); - - it.skip('should render feed page for authenticated users', async () => { - await act(async () => { - renderWithAllProviders( - , - {}, - ); - }); - expect(screen.getByText(/From Your Mind to the World/i)).toBeInTheDocument(); - expect(screen.getByText(/Start Beaming/i)).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/antenna/src/components/__tests__/pending-reflect.spec.tsx b/extensions/apps/antenna/src/components/__tests__/pending-reflect.spec.tsx deleted file mode 100644 index c9054b57b4..0000000000 --- a/extensions/apps/antenna/src/components/__tests__/pending-reflect.spec.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; -import { - screen, - renderWithAllProviders, - act, - genUser, - genReflectionData, -} from '@akashaorg/af-testing'; -import { PendingReflect } from '../reflect-editor/pending-reflect'; - -describe('< PendingReflect /> component', () => { - const reflectionData = genReflectionData(); - - const BaseComponent = ( - - ); - - it('should show pending reflect', async () => { - await act(async () => { - renderWithAllProviders(BaseComponent, {}); - }); - expect(screen.getByText(/Reflection content/i)).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/antenna/src/components/__tests__/reflection-page.spec.tsx b/extensions/apps/antenna/src/components/__tests__/reflection-page.spec.tsx deleted file mode 100644 index f84aa3d056..0000000000 --- a/extensions/apps/antenna/src/components/__tests__/reflection-page.spec.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import React from 'react'; -import ReflectionPage from '../pages/entry-page/reflection-page'; -import { - screen, - renderWithAllProviders, - act, - genAppProps, - genReflectionData, -} from '@akashaorg/af-testing'; -import { AnalyticsProvider } from '@akashaorg/ui-awf-hooks/lib/use-analytics'; - -class ResizeObserver { - observe() { - return; - } - unobserve() { - return; - } - disconnect() { - return; - } -} - -describe('< ReflectionPage /> component', () => { - global.ResizeObserver = ResizeObserver; - const BaseComponent = ( - - - - ); - - beforeEach(async () => { - await act(async () => { - renderWithAllProviders(BaseComponent, {}); - }); - }); - - it.skip('should render reflection page', async () => { - expect(screen.getByText(/Back to original beam/i)).toBeInTheDocument(); - expect(screen.getByText(/Share your thoughts/i)).toBeInTheDocument(); - expect(screen.getByRole('button', { name: /Reflect/i })).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/antenna/src/components/__tests__/tag-feed-page.spec.tsx b/extensions/apps/antenna/src/components/__tests__/tag-feed-page.spec.tsx deleted file mode 100644 index cb8b91e83b..0000000000 --- a/extensions/apps/antenna/src/components/__tests__/tag-feed-page.spec.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import React from 'react'; -import TagFeedPage from '../pages/tag-feed-page/tag-feed-page'; - -import { screen, renderWithAllProviders, act } from '@akashaorg/af-testing'; - -describe('< TagFeedPage /> component', () => { - const BaseComponent = ; - - // @TODO fix after new hooks - it.skip('should render tag feed page', async () => { - await act(async () => { - renderWithAllProviders(BaseComponent, {}); - }); - - expect(screen.getByText(/my-tag/i)).toBeInTheDocument(); - expect(screen.getByText(/10 mentions/i)).toBeInTheDocument(); - expect(screen.getByText(/Subscribe/i)).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/antenna/src/components/app-routes/data-loaders.ts b/extensions/apps/antenna/src/components/app-routes/data-loaders.ts index f4464a00a7..4da751c4ed 100644 --- a/extensions/apps/antenna/src/components/app-routes/data-loaders.ts +++ b/extensions/apps/antenna/src/components/app-routes/data-loaders.ts @@ -5,6 +5,7 @@ import { GetReflectionByIdQuery, } from '@akashaorg/typings/lib/sdk/graphql-operation-types-new'; import { RouterContext } from '@akashaorg/typings/lib/ui'; +import { hasOwn } from '@akashaorg/ui-awf-hooks'; import { GetBeamByIdDocument, GetBeamStreamDocument, @@ -48,3 +49,22 @@ export async function getReflectionById({ }); return data; } + +export function getBeamStatus(beamStream: GetBeamStreamQuery) { + if ( + beamStream?.node && + hasOwn(beamStream.node, 'akashaBeamStreamList') && + beamStream.node.akashaBeamStreamList.edges?.[0]?.node && + hasOwn(beamStream.node.akashaBeamStreamList.edges[0].node, 'status') + ) { + return beamStream.node.akashaBeamStreamList.edges[0].node.status; + } + return null; +} + +export function getBeamData(beamById: GetBeamByIdQuery) { + if (beamById?.node && hasOwn(beamById.node, 'id')) { + return beamById?.node; + } + return null; +} diff --git a/extensions/apps/antenna/src/components/app-routes/index.tsx b/extensions/apps/antenna/src/components/app-routes/index.tsx index 65b40fe042..7d497fb8e7 100644 --- a/extensions/apps/antenna/src/components/app-routes/index.tsx +++ b/extensions/apps/antenna/src/components/app-routes/index.tsx @@ -26,7 +26,14 @@ import { Await, } from '@tanstack/react-router'; import { CreateRouter, RouterContext } from '@akashaorg/typings/lib/ui'; -import { getBeamById, getBeamStreamId, getReflectionById } from './data-loaders'; +import { + getBeamById, + getBeamData, + getBeamStatus, + getBeamStreamId, + getReflectionById, +} from './data-loaders'; +import { mapBeamEntryData } from '@akashaorg/ui-awf-hooks'; const rootRoute = createRootRouteWithContext()({ component: Outlet, @@ -76,7 +83,15 @@ const beamRoute = createRoute({ {beamStreamData => ( - {beamData => } + {beamById => { + return ( + + ); + }} )} @@ -96,7 +111,15 @@ const beamReflectRoute = createRoute({ {beamStreamData => ( - {beamData => } + {beamById => { + return ( + + ); + }} )} diff --git a/extensions/apps/antenna/src/components/pages/entry-page/beam-page.tsx b/extensions/apps/antenna/src/components/pages/entry-page/beam-page.tsx index ef28729757..0fea508350 100644 --- a/extensions/apps/antenna/src/components/pages/entry-page/beam-page.tsx +++ b/extensions/apps/antenna/src/components/pages/entry-page/beam-page.tsx @@ -8,7 +8,6 @@ import Divider from '@akashaorg/design-system-core/lib/components/Divider'; import ErrorBoundary from '@akashaorg/design-system-core/lib/components/ErrorBoundary'; import { hasOwn, - mapBeamEntryData, useAkashaStore, useAnalytics, useNsfwToggling, @@ -18,20 +17,17 @@ import { useTranslation } from 'react-i18next'; import { ReflectionPreview } from '@akashaorg/ui-lib-feed'; import { AkashaBeamStreamModerationStatus } from '@akashaorg/typings/lib/sdk/graphql-types-new'; import { useNavigate } from '@tanstack/react-router'; -import { - GetBeamByIdQuery, - GetBeamStreamQuery, -} from '@akashaorg/typings/lib/sdk/graphql-operation-types-new'; import { EditableReflectionResolver, ReflectFeed } from '@akashaorg/ui-lib-feed'; +import { BeamEntryData } from '@akashaorg/typings/lib/ui'; type BeamPageProps = { beamId: string; - beamStream: GetBeamStreamQuery; - beam: GetBeamByIdQuery; + beamStatus: AkashaBeamStreamModerationStatus; + entryData: BeamEntryData; }; const BeamPage: React.FC = props => { - const { beamId, beamStream, beam } = props; + const { beamId, beamStatus, entryData } = props; const { t } = useTranslation('app-antenna'); const { navigateToModal, logger } = useRootComponentProps(); const { @@ -65,27 +61,6 @@ const BeamPage: React.FC = props => { } }, [reflectionStreamQuery.data]); - /** - * Check the current moderation status of the beam - */ - const moderationData = React.useMemo(() => { - if ( - beamStream && - hasOwn(beamStream, 'node') && - hasOwn(beamStream.node, 'akashaBeamStreamList') && - beamStream.node.akashaBeamStreamList.edges?.[0]?.node && - hasOwn(beamStream.node.akashaBeamStreamList.edges[0].node, 'status') - ) { - return beamStream.node.akashaBeamStreamList.edges[0].node.status; - } - }, [beamStream]); - - const entryData = React.useMemo(() => { - if (beam && hasOwn(beam, 'node') && hasOwn(beam.node, 'id')) { - return beam.node; - } - }, [beam]); - const showLoginModal = (title?: string, message?: string) => { navigateToModal({ name: 'login', @@ -103,10 +78,10 @@ const BeamPage: React.FC = props => { */ const showNsfwCard = React.useMemo(() => { return ( - moderationData === AkashaBeamStreamModerationStatus.Nsfw && + beamStatus === AkashaBeamStreamModerationStatus.Nsfw && (!showNsfw || (!isLoggedIn && !authenticating)) ); - }, [authenticating, isLoggedIn, moderationData, showNsfw]); + }, [authenticating, beamStatus, isLoggedIn, showNsfw]); useLayoutEffect(() => { //resets initial scroll to top when page mounts @@ -119,7 +94,7 @@ const BeamPage: React.FC = props => { header={ diff --git a/extensions/apps/auth-app/src/components/__tests__/connect.spec.tsx b/extensions/apps/auth-app/src/components/__tests__/connect.spec.tsx deleted file mode 100644 index 11b5ea154b..0000000000 --- a/extensions/apps/auth-app/src/components/__tests__/connect.spec.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import * as React from 'react'; -import ChooseProvider from '../pages/choose-provider'; - -import { act, screen, renderWithAllProviders, genAppProps } from '@akashaorg/af-testing'; -import { AnalyticsProvider } from '@akashaorg/ui-awf-hooks/lib/use-analytics'; - -describe('< SignIn /> component', () => { - const BaseComponent = ( - - ; - - ); - beforeEach(async () => { - await act(async () => { - renderWithAllProviders(BaseComponent, {}); - }); - }); - - it.skip('should render sign in page', async () => { - expect(screen.getByText(/Welcome to AKASHA World/i)).toBeInTheDocument(); - expect(screen.getByText('Connect your wallet')).toBeInTheDocument(); - }); - - it.skip('has a connect option', async () => { - const walletConnect = screen.getByText(/Connect your wallet using/i); - expect(walletConnect).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/extensions/src/components/__tests__/apps-page.spec.tsx b/extensions/apps/extensions/src/components/__tests__/apps-page.spec.tsx deleted file mode 100644 index 01066d46fd..0000000000 --- a/extensions/apps/extensions/src/components/__tests__/apps-page.spec.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import * as React from 'react'; -import AppsPage from '../pages/apps-page'; - -import { screen, renderWithAllProviders, act } from '@akashaorg/af-testing'; - -describe('< AppsPage /> component', () => { - const BaseComponent = ; - - beforeEach(async () => { - await act(async () => { - renderWithAllProviders(BaseComponent, {}); - }); - }); - - it('should render apps page', async () => { - expect(screen.getByText(/Newest Apps/i)).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/extensions/src/components/__tests__/explore-page.spec.tsx b/extensions/apps/extensions/src/components/__tests__/explore-page.spec.tsx deleted file mode 100644 index 56bd5c977d..0000000000 --- a/extensions/apps/extensions/src/components/__tests__/explore-page.spec.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import * as React from 'react'; -import ExplorePage from '../pages/explore-page'; - -import { screen, renderWithAllProviders, act, genReleaseInfo } from '@akashaorg/af-testing'; - -describe('< ExplorePage /> component', () => { - const BaseComponent = ; - - beforeEach(async () => { - await act(async () => { - renderWithAllProviders(BaseComponent, {}); - }); - }); - - it('should render explore page', async () => { - expect(screen.getByText(/Latest Apps/i)).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/extensions/src/components/__tests__/my-apps-page.spec.tsx b/extensions/apps/extensions/src/components/__tests__/my-apps-page.spec.tsx deleted file mode 100644 index 689823a634..0000000000 --- a/extensions/apps/extensions/src/components/__tests__/my-apps-page.spec.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import * as React from 'react'; -import MyAppsPage from '../pages/my-apps-page'; - -import { screen, renderWithAllProviders, act } from '@akashaorg/af-testing'; - -describe('< MyAppsPage /> component', () => { - const BaseComponent = ; - - beforeEach(async () => { - await act(async () => { - renderWithAllProviders(BaseComponent, {}); - }); - }); - - it('should render my apps page', async () => { - expect(screen.getByText(/Installed Apps/i)).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/extensions/src/components/__tests__/my-widgets-page.spec.tsx b/extensions/apps/extensions/src/components/__tests__/my-widgets-page.spec.tsx deleted file mode 100644 index b39fd77d6c..0000000000 --- a/extensions/apps/extensions/src/components/__tests__/my-widgets-page.spec.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import * as React from 'react'; -import MyWidgetsPage from '../pages/my-widgets-page'; - -import { screen, renderWithAllProviders, act } from '@akashaorg/af-testing'; - -describe('< MyWidgetsPage /> component', () => { - const BaseComponent = ; - - beforeEach(async () => { - await act(async () => { - renderWithAllProviders(BaseComponent, {}); - }); - }); - - it('should render my widgets page', async () => { - expect(screen.getByText(/Newest Widgets/i)).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/notifications/src/components/__tests__/customize-notification-page.spec.tsx b/extensions/apps/notifications/src/components/__tests__/customize-notification-page.spec.tsx deleted file mode 100644 index 1f62974880..0000000000 --- a/extensions/apps/notifications/src/components/__tests__/customize-notification-page.spec.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import * as React from 'react'; -import CustomiseNotificationPage from '../pages/customise-notification-page'; -import { screen, renderWithAllProviders, act } from '@akashaorg/af-testing'; - -describe(' component', () => { - const BaseComponent = ; - beforeEach(async () => { - await act(async () => { - renderWithAllProviders(BaseComponent, {}); - }); - }); - - it.skip("should render the notifications app's customization page", async () => { - expect(screen.getByText(/Customise Your Notifications/)).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/notifications/src/components/__tests__/welcome-page.spec.tsx b/extensions/apps/notifications/src/components/__tests__/welcome-page.spec.tsx deleted file mode 100644 index 5533a5b1ed..0000000000 --- a/extensions/apps/notifications/src/components/__tests__/welcome-page.spec.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import * as React from 'react'; -import WelcomePage from '../pages/welcome-page'; - -import { screen, renderWithAllProviders, act, genAppProps } from '@akashaorg/af-testing'; -import { AnalyticsProvider } from '@akashaorg/ui-awf-hooks/lib/use-analytics'; - -describe('< WelcomePage /> component', () => { - const BaseComponent = ( - - - - ); - beforeEach(async () => { - await act(async () => { - renderWithAllProviders(BaseComponent, {}); - }); - }); - - it.skip("should render the notifications app's welcome page", async () => { - expect(screen.getByText(/Uh-oh! You are not connected!/)).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/profile/jest.setup.js b/extensions/apps/profile/jest.setup.js index 4bd37afa9a..d5615dfb30 100644 --- a/extensions/apps/profile/jest.setup.js +++ b/extensions/apps/profile/jest.setup.js @@ -3,12 +3,14 @@ import * as mediaHooks from '@akashaorg/ui-awf-hooks/lib/utils/media-utils'; import * as loginHook from '@akashaorg/ui-awf-hooks/lib/use-login.new'; import * as reactUse from 'react-use'; import ResizeObserver from 'resize-observer-polyfill'; -import { genUser } from '@akashaorg/af-testing'; +import { genProfileByDID } from '@akashaorg/af-testing'; global.ResizeObserver = ResizeObserver; jest.spyOn(loginHook, 'useGetLogin').mockReturnValue({ - data: { id: genUser('did:pkh:eip155:5:0xc47a483494db8fe455ba29a53a7f75349dfc02ff')?.did?.id }, + data: { + id: genProfileByDID('did:pkh:eip155:5:0xc47a483494db8fe455ba29a53a7f75349dfc02ff')?.did?.id, + }, loading: false, error: null, }); diff --git a/extensions/apps/profile/src/components/__tests__/profile-edit-general.spec.tsx b/extensions/apps/profile/src/components/__tests__/profile-edit-general.spec.tsx deleted file mode 100644 index 4f5440f19a..0000000000 --- a/extensions/apps/profile/src/components/__tests__/profile-edit-general.spec.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import React from 'react'; -import EditProfilePage from '../pages/edit-profile'; -import userEvent from '@testing-library/user-event'; -import * as hooks from '@akashaorg/ui-awf-hooks/lib/generated/apollo'; -import { - renderWithAllProvidersAndApollo, - act, - screen, - genUser, - waitFor, -} from '@akashaorg/af-testing'; -import { Profile } from '@akashaorg/typings/lib/ui'; - -const fakeDID = 'did:pkh:eip155:5:0xc47a483494db8fe455ba29a53a7f75349dfc02ff'; - -describe('', () => { - const BaseComponent = ; - - const profile = genUser(fakeDID); - - beforeEach(async () => { - userEvent.setup(); - await act(async () => { - renderWithAllProvidersAndApollo(BaseComponent, {}); - }); - }); - - beforeAll(() => { - ( - jest.spyOn(hooks, 'useGetProfileByDidSuspenseQuery') as unknown as jest.SpyInstance<{ - data: { - node: { - isViewer: boolean; - akashaProfile: Profile; - }; - }; - }> - ).mockReturnValue({ data: { node: { isViewer: true, akashaProfile: profile } } }); - }); - - it('should render edit page', async () => { - expect(screen.getByRole('heading', { name: 'Avatar & Cover Image' })).toBeInTheDocument(); - }); - - it('should initially have a disabled save button', async () => { - expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled(); - }); - - it('should have an enabled save button when name changes', async () => { - const nameInput = screen.getByLabelText(/Name/i); - - await userEvent.clear(nameInput); - await userEvent.type(nameInput, 'Orion'); - await waitFor(() => expect(screen.getByRole('button', { name: 'Save' })).toBeEnabled()); - }); - - it('should show error when name contains illegal characters', async () => { - const nameInput = screen.getByLabelText(/Name/i); - - await userEvent.clear(nameInput); - await userEvent.type(nameInput, '&**$$'); - await waitFor(() => - expect( - screen.getByText('Name should contain only alphabets, numbers or -_.'), - ).toBeInTheDocument(), - ); - }); - - it('should show error when name is less than 3 characters long', async () => { - const nameInput = screen.getByLabelText(/Name/i); - - await userEvent.clear(nameInput); - await userEvent.type(nameInput, 'O'); - await waitFor(() => - expect(screen.getByText('Must be at least 3 characters')).toBeInTheDocument(), - ); - }); -}); diff --git a/extensions/apps/profile/src/components/__tests__/profile-info.spec.tsx b/extensions/apps/profile/src/components/__tests__/profile-info.spec.tsx deleted file mode 100644 index f99d843009..0000000000 --- a/extensions/apps/profile/src/components/__tests__/profile-info.spec.tsx +++ /dev/null @@ -1,110 +0,0 @@ -import React from 'react'; -import ProfileInfoPage from '../pages/profile-info'; -import userEvent from '@testing-library/user-event'; -import * as statHook from '@akashaorg/ui-awf-hooks/lib/use-profile-stats'; -import * as apolloHooks from '@akashaorg/ui-awf-hooks/lib/generated/apollo'; -import { - renderWithAllProvidersAndApollo, - act, - screen, - genUser, - waitFor, -} from '@akashaorg/af-testing'; -import { truncateDid } from '@akashaorg/design-system-core/lib/utils/did-utils'; -import { Profile } from '@akashaorg/typings/lib/ui'; -import { AkashaFollow } from '@akashaorg/typings/lib/sdk/graphql-types-new'; - -const fakeDID = 'did:pkh:eip155:5:0xc47a483494db8fe455ba29a53a7f75349dfc02ff'; - -describe('< ProfileInfoPage />', () => { - const navigateTo = jest.fn(); - - const BaseComponent = ; - const profile = genUser(fakeDID); - - beforeEach(async () => { - userEvent.setup(); - await act(async () => { - renderWithAllProvidersAndApollo(BaseComponent, {}); - }); - }); - - beforeAll(() => { - ( - jest.spyOn(apolloHooks, 'useGetProfileByDidQuery') as unknown as jest.SpyInstance<{ - data: { - node: { isViewer: boolean; akashaProfile: Profile }; - }; - status: 'success' | 'error' | 'loading'; - }> - ).mockReturnValue({ - data: { node: { isViewer: true, akashaProfile: profile } }, - status: 'success', - }); - - ( - jest.spyOn(apolloHooks, 'useGetProfileByDidSuspenseQuery') as unknown as jest.SpyInstance<{ - data: { - node: { isViewer: boolean; akashaProfile: Profile }; - }; - }> - ).mockReturnValue({ data: { node: { isViewer: true, akashaProfile: profile } } }); - - ( - jest.spyOn(statHook, 'useProfileStats') as unknown as jest.SpyInstance<{ - data: { - totalFollowing: number; - totalFollowers: number; - totalBeams: number; - totalTopics: number; - }; - }> - ).mockReturnValue({ - data: { totalFollowing: 10, totalFollowers: 2, totalBeams: 4, totalTopics: 0 }, - }); - - ( - jest.spyOn( - apolloHooks, - 'useGetFollowDocumentsByDidSuspenseQuery', - ) as unknown as jest.SpyInstance<{ - data: { - isViewer: boolean; - akashaFollowList: { edges: AkashaFollow[] }; - }; - }> - ).mockReturnValue({ - data: { isViewer: true, akashaFollowList: { edges: [] } }, - }); - }); - it('should render profile info page', async () => { - expect(screen.getByTestId('avatar-image')).toBeInTheDocument(); - }); - - it('should render profile header', async () => { - expect(screen.getByTestId('avatar-image')).toBeInTheDocument(); - expect(screen.getByText(profile.name)).toBeInTheDocument(); - expect(screen.getByText(truncateDid(fakeDID))).toBeInTheDocument(); - }); - - it('should render profile description', async () => { - expect(screen.getByText(profile.description || '')).toBeInTheDocument(); - }); - - it('should render social links', async () => { - expect(screen.getByText(profile.links?.[0]?.href || '')).toBeInTheDocument(); - expect(screen.getByText(profile.links?.[1]?.href || '')).toBeInTheDocument(); - }); - - it('should render profile statistics', async () => { - expect(screen.getByTestId('avatar-image')).toBeInTheDocument(); - expect(screen.getByText(profile.name)).toBeInTheDocument(); - expect(screen.getByText(truncateDid(fakeDID))).toBeInTheDocument(); - }); - - // @TODO: fix test - it.skip('should go to edit page when edit icon is clicked', async () => { - await userEvent.click(screen.getByRole('button', { name: 'edit' })); - await waitFor(() => expect(navigateTo).toHaveBeenCalled()); - }); -}); diff --git a/extensions/apps/search/src/components/__tests__/search-page.spec.tsx b/extensions/apps/search/src/components/__tests__/search-page.spec.tsx deleted file mode 100644 index 78c58202d3..0000000000 --- a/extensions/apps/search/src/components/__tests__/search-page.spec.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import React from 'react'; -import SearchPage from '../pages/search-page'; -import { screen, renderWithAllProviders, act, genAppProps } from '@akashaorg/af-testing'; -import { AnalyticsProvider } from '@akashaorg/ui-awf-hooks/lib/use-analytics'; - -const mockLocationValue = { - pathname: '/search/', - search: '', - hash: '', - state: null, -}; - -const mockRouteParams = { - searchKeyword: '', -}; - -jest.mock('react-router', () => ({ - ...jest.requireActual('react-router'), - useLocation: jest.fn().mockImplementation(() => { - return mockLocationValue; - }), - useParams: jest.fn().mockImplementation(() => { - return mockRouteParams; - }), -})); - -describe('', () => { - const BaseComponent = ( - - - - ); - beforeEach(async () => { - await act(async () => { - await renderWithAllProviders(BaseComponent, {}); - }); - }); - it('should render search page', () => { - expect(screen.getByText(/Search/)).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/search/src/components/pages/entry-renderer.tsx b/extensions/apps/search/src/components/pages/entry-renderer.tsx index f8ade8c8bf..6c98332cd9 100644 --- a/extensions/apps/search/src/components/pages/entry-renderer.tsx +++ b/extensions/apps/search/src/components/pages/entry-renderer.tsx @@ -91,7 +91,7 @@ const EntryCardRenderer = (props: EntryCardRendererProps) => { onEntryRemove={handleEntryRemove} onEntryFlag={handleFlag} hideActionButtons={hideActionButtons} - profileAvatarExt={ + profileAvatar={ component', () => { - const BaseComponent = ; - beforeEach(async () => { - await act(async () => { - renderWithAllProviders(BaseComponent, {}); - }); - }); - - it('should render settings page', async () => { - expect(screen.getByText(/settings/i)).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/vibes-console/src/components/__tests__/dashboard.spec.tsx b/extensions/apps/vibes-console/src/components/__tests__/dashboard.spec.tsx deleted file mode 100644 index f5742ae7e1..0000000000 --- a/extensions/apps/vibes-console/src/components/__tests__/dashboard.spec.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import * as React from 'react'; - -import { renderWithAllProviders, act, cleanup } from '@akashaorg/af-testing'; - -import { Dashboard } from '../../pages'; - -describe(' component', () => { - const Base = ; - - let componentWrapper = renderWithAllProviders(<>, {}); - - beforeEach(() => { - act(() => { - componentWrapper = renderWithAllProviders(Base, {}); - }); - }); - - afterEach(() => { - act(() => componentWrapper.unmount()); - cleanup(); - }); - - it('should render component', async () => { - expect(componentWrapper.getByText(/content review/i)).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/vibes/src/components/__tests__/moderators.spec.tsx b/extensions/apps/vibes/src/components/__tests__/moderators.spec.tsx deleted file mode 100644 index 67609c5894..0000000000 --- a/extensions/apps/vibes/src/components/__tests__/moderators.spec.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import * as React from 'react'; - -import { renderWithAllProviders, act, cleanup } from '@akashaorg/af-testing'; - -import { Moderators } from '../../pages'; - -describe(' component', () => { - const Base = ; - - let componentWrapper = renderWithAllProviders(<>, {}); - - beforeEach(() => { - act(() => { - componentWrapper = renderWithAllProviders(Base, {}); - }); - }); - - afterEach(() => { - act(() => componentWrapper.unmount()); - cleanup(); - }); - - it('should render component', async () => { - expect(componentWrapper.baseElement).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/vibes/src/components/__tests__/no-items-found.spec.tsx b/extensions/apps/vibes/src/components/__tests__/no-items-found.spec.tsx deleted file mode 100644 index 833819b7bf..0000000000 --- a/extensions/apps/vibes/src/components/__tests__/no-items-found.spec.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import * as React from 'react'; - -import { renderWithAllProviders, act, cleanup } from '@akashaorg/af-testing'; - -import NoItemFound from '../error-cards/no-items-found'; - -describe(' component', () => { - const Base = ( - - ); - - let componentWrapper = renderWithAllProviders(<>, {}); - - beforeEach(() => { - act(() => { - componentWrapper = renderWithAllProviders(Base, {}); - }); - }); - - afterEach(() => { - act(() => componentWrapper.unmount()); - cleanup(); - }); - - it('should render component', async () => { - expect(componentWrapper.getByText('No pending items')).toBeInTheDocument(); - }); -}); diff --git a/extensions/apps/vibes/src/components/__tests__/overview.spec.tsx b/extensions/apps/vibes/src/components/__tests__/overview.spec.tsx deleted file mode 100644 index 2413ed2e5c..0000000000 --- a/extensions/apps/vibes/src/components/__tests__/overview.spec.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import * as React from 'react'; - -import { renderWithAllProviders, act, cleanup } from '@akashaorg/af-testing'; - -import { Overview } from '../../pages'; - -describe(' component', () => { - const Base = ; - - let componentWrapper = renderWithAllProviders(<>, {}); - - beforeEach(() => { - act(() => { - componentWrapper = renderWithAllProviders(Base, {}); - }); - }); - - afterEach(() => { - act(() => componentWrapper.unmount()); - cleanup(); - }); - - it('should render component', async () => { - expect(componentWrapper.getByText(/Welcome to/i)).toBeInTheDocument(); - }); -}); diff --git a/extensions/jest.setup.js b/extensions/jest.setup.js index db81248ef8..00e4341b1b 100644 --- a/extensions/jest.setup.js +++ b/extensions/jest.setup.js @@ -1,9 +1,42 @@ -/* eslint-disable @typescript-eslint/no-empty-function */ -import { genAppProps, getUserInfo, getUserStore } from '@akashaorg/af-testing'; import * as useRootComponentProps from '@akashaorg/ui-awf-hooks/lib/use-root-props'; import * as useAkashaStore from '@akashaorg/ui-awf-hooks/lib/store/use-akasha-store'; +import { genAppProps, getUserInfo, getUserStore } from '@akashaorg/af-testing'; +import '@testing-library/jest-dom'; + +class ResizeObserver { + observe() { + return; + } + unobserve() { + return; + } + disconnect() { + return; + } +} + +global.ResizeObserver = ResizeObserver; -require('@testing-library/jest-dom/extend-expect'); +jest.mock('@tanstack/react-router', () => ({ + ...jest.requireActual('@tanstack/react-router'), + useNavigate: jest.fn().mockImplementation(() => { + return jest.fn(); + }), + useRouterState: jest.fn().mockImplementation(() => { + return { + location: { + pathname: '', + }, + }; + }), +})); + +jest.mock('react-use', () => ({ + ...jest.requireActual('react-use'), + useMedia: jest.fn().mockImplementation(() => { + return false; + }), +})); /** * sdk mock for Apps package. @@ -68,3 +101,16 @@ jest.spyOn(useRootComponentProps, 'useRootComponentProps').mockReturnValue({ ... jest .spyOn(useAkashaStore, 'useAkashaStore') .mockReturnValue({ userStore: getUserStore(), data: getUserInfo() }); + +const mockIntersectionObserver = jest.fn(); + +mockIntersectionObserver.mockReturnValue({ + observe: () => null, + unobserve: () => null, + disconnect: () => null, +}); + +global.IntersectionObserver = mockIntersectionObserver; + +//TODO revisit this mock +global.scrollTo = jest.fn(); diff --git a/extensions/widgets/analytics/src/components/__tests__/cookie-widget.spec.tsx b/extensions/widgets/analytics/src/components/__tests__/cookie-widget.spec.tsx deleted file mode 100644 index 2ad1be635b..0000000000 --- a/extensions/widgets/analytics/src/components/__tests__/cookie-widget.spec.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import * as React from 'react'; -import CookieWidget from '../cookie-widget'; - -import { RenderResult, renderWithAllProviders } from '@akashaorg/af-testing'; - -describe('< CookieWidget />', () => { - let renderResult: RenderResult; - const BaseComponent = ; - beforeEach(() => { - renderResult = renderWithAllProviders(BaseComponent, {}); - }); - it('should render 2 buttons - `Accept all`, `Only essential`', async () => { - const acceptButton = await renderResult.findByText('Accept all'); - const essentialButton = await renderResult.findByText('Only essential'); - expect(acceptButton).toBeDefined(); - expect(essentialButton).toBeDefined(); - }); -}); diff --git a/extensions/widgets/sidebar/src/components/__tests__/sidebar-widget.spec.tsx b/extensions/widgets/sidebar/src/components/__tests__/sidebar-widget.spec.tsx deleted file mode 100644 index 53330c4da6..0000000000 --- a/extensions/widgets/sidebar/src/components/__tests__/sidebar-widget.spec.tsx +++ /dev/null @@ -1,32 +0,0 @@ -// import * as React from 'react'; -// import SidebarWidget from '../Sidebar-widget'; - -// import { -// RenderResult, -// renderWithAllProviders, -// globalChannelMock, -// act, -// } from '@akashaorg/af-testing'; -// import i18next from 'i18next'; - -describe('', () => { - // let renderResult: RenderResult; - // const BaseComponent = ( - // - // ); - beforeEach(() => { - // act(() => { - // renderResult = renderWithAllProviders(BaseComponent, {}); - // }); - }); - it.skip('has an old code, skipping', () => { - // renderResult.debug(); - }); -}); diff --git a/extensions/widgets/top-bar/src/components/__tests__/topbar-component.spec.tsx b/extensions/widgets/top-bar/src/components/__tests__/topbar-component.spec.tsx deleted file mode 100644 index b0376ed2e1..0000000000 --- a/extensions/widgets/top-bar/src/components/__tests__/topbar-component.spec.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import * as React from 'react'; -import TopbarComponent from '../topbar-component'; - -import { RenderResult, renderWithAllProviders, act } from '@akashaorg/af-testing'; - -const mockLocationValue = { - pathname: '/profile', - search: '', - hash: '', - state: null, -}; - -jest.mock('react-router', () => - Object.assign(jest.requireActual('react-router'), { - useLocation: jest.fn().mockImplementation(() => { - return mockLocationValue; - }), - }), -); - -describe('', () => { - let renderResult: RenderResult; - const BaseComponent = ; - beforeEach(async () => { - await act(async () => { - renderResult = await renderWithAllProviders(BaseComponent, {}); - }); - }); - it('should render brand name', async () => { - const brandNode = await renderResult.findByText('AKASHA World'); - expect(brandNode).toBeDefined(); - }); -}); diff --git a/extensions/widgets/trending/src/components/__tests__/trending-widget-component.spec.tsx b/extensions/widgets/trending/src/components/__tests__/trending-widget-component.spec.tsx deleted file mode 100644 index cc4640be99..0000000000 --- a/extensions/widgets/trending/src/components/__tests__/trending-widget-component.spec.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import * as React from 'react'; -import TrendingWidgetComponent from '../trending-widget-component'; - -import { RenderResult, renderWithAllProviders, act, genAppProps } from '@akashaorg/af-testing'; -import { AnalyticsProvider } from '@akashaorg/ui-awf-hooks/lib/use-analytics'; - -describe(' component', () => { - let renderResult: RenderResult; - - const BaseComponent = ( - - - - ); - - beforeEach(() => { - act(() => { - renderResult = renderWithAllProviders(BaseComponent, {}); - }); - }); - it('should render `Trending Right Now` title', async () => { - const titleNode = await renderResult.findByText('Trending Right Now'); - expect(titleNode).toBeDefined(); - }); -}); diff --git a/libs/design-system-components/jest.setup.js b/libs/design-system-components/jest.setup.js index 550d89db53..3c7e419c2e 100644 --- a/libs/design-system-components/jest.setup.js +++ b/libs/design-system-components/jest.setup.js @@ -1,4 +1,4 @@ -require('@testing-library/jest-dom/extend-expect'); +import '@testing-library/jest-dom'; import { install } from '@twind/core'; import twindConfig from './.storybook/twind.config.js'; diff --git a/libs/design-system-components/src/components/Entry/EntryCard/index.tsx b/libs/design-system-components/src/components/Entry/EntryCard/index.tsx index a024e6811c..0fa5d046f3 100644 --- a/libs/design-system-components/src/components/Entry/EntryCard/index.tsx +++ b/libs/design-system-components/src/components/Entry/EntryCard/index.tsx @@ -35,7 +35,7 @@ type ReflectProps = { export type EntryCardProps = { entryData: EntryData; - profileAvatarExt: ReactNode; + profileAvatar: ReactNode; flagAsLabel?: string; moderatedContentLabel?: string; ctaLabel?: string; @@ -81,7 +81,7 @@ export type EntryCardProps = { const EntryCard: React.FC = props => { const { entryData, - profileAvatarExt, + profileAvatar, ref, flagAsLabel, removed, @@ -164,7 +164,7 @@ const EntryCard: React.FC = props => { const entryCardUi = ( - {profileAvatarExt} + {profileAvatar} , diff --git a/libs/design-system-components/src/stories/dscomponents/entry-card.stories.tsx b/libs/design-system-components/src/stories/dscomponents/entry-card.stories.tsx index c295adf46a..914a74610d 100644 --- a/libs/design-system-components/src/stories/dscomponents/entry-card.stories.tsx +++ b/libs/design-system-components/src/stories/dscomponents/entry-card.stories.tsx @@ -50,7 +50,7 @@ const baseArgs: Story = { args: { isLoggedIn, entryData, - profileAvatarExt: ( + profileAvatar: ( ), itemType: EntityTypes?.REFLECT, diff --git a/libs/design-system-components/src/stories/dscomponents/vibes-console-content-card.stories.tsx b/libs/design-system-components/src/stories/dscomponents/vibes-console-content-card.stories.tsx index 1499157131..5e453f67b8 100644 --- a/libs/design-system-components/src/stories/dscomponents/vibes-console-content-card.stories.tsx +++ b/libs/design-system-components/src/stories/dscomponents/vibes-console-content-card.stories.tsx @@ -27,7 +27,7 @@ const sampleEntryData: EntryCardProps = { createdAt: '12/12/2023', id: 'kshggg55555', }, - profileAvatarExt: ( + profileAvatar: ( ), itemType: EntityTypes?.REFLECT, diff --git a/libs/design-system-core/jest.config.cjs b/libs/design-system-core/jest.config.cjs index eeb082aa39..647bcc175a 100644 --- a/libs/design-system-core/jest.config.cjs +++ b/libs/design-system-core/jest.config.cjs @@ -3,6 +3,5 @@ const baseConfig = require('../../jest.config.base'); module.exports = Object.assign(baseConfig, { automock: false, - // preset: 'ts-jest', testEnvironment: 'jsdom', }); diff --git a/libs/design-system-core/jest.setup.js b/libs/design-system-core/jest.setup.js index bc398713d4..b52736bb61 100644 --- a/libs/design-system-core/jest.setup.js +++ b/libs/design-system-core/jest.setup.js @@ -1,5 +1,3 @@ -require('@testing-library/jest-dom/extend-expect'); - import { install } from '@twind/core'; import twindConfig from './src/twind/twind.config.js'; import ResizeObserver from 'resize-observer-polyfill'; diff --git a/libs/design-system-core/src/components/AppAvatar/__tests__/index.test.tsx b/libs/design-system-core/src/components/AppAvatar/__tests__/index.test.tsx index e26aeadd5d..6b8bd222db 100644 --- a/libs/design-system-core/src/components/AppAvatar/__tests__/index.test.tsx +++ b/libs/design-system-core/src/components/AppAvatar/__tests__/index.test.tsx @@ -3,6 +3,7 @@ import { act } from '@testing-library/react'; import { IntegrationTypes } from '@akashaorg/typings/lib/ui'; import AppAvatar from '../'; import { customRender } from '../../../test-utils'; +import '@testing-library/jest-dom'; describe(' Component', () => { let componentWrapper = customRender(<>, {}); diff --git a/libs/design-system-core/tsconfig.json b/libs/design-system-core/tsconfig.json index 8f08be1bda..4281d656fc 100644 --- a/libs/design-system-core/tsconfig.json +++ b/libs/design-system-core/tsconfig.json @@ -11,5 +11,5 @@ "react": ["./node_modules/@types/react"] } }, - "include": ["./src/**/*"] + "include": ["./src/**/*", "jest.setup.js", "jest.config.cjs"] } diff --git a/libs/extensions/jest.setup.js b/libs/extensions/jest.setup.js index 8cba3c5917..6185c48ecd 100644 --- a/libs/extensions/jest.setup.js +++ b/libs/extensions/jest.setup.js @@ -1,6 +1,6 @@ import * as mediaHooks from '@akashaorg/ui-awf-hooks/lib/utils/media-utils'; -require('@testing-library/jest-dom/extend-expect'); +import '@testing-library/jest-dom'; jest.mock('react-i18next', () => ({ ...jest.requireActual('react-i18next'), diff --git a/libs/feed/src/__tests__/__mocks__/get-reflection-feed-mocks.ts b/libs/feed/src/__tests__/__mocks__/get-reflection-feed-mocks.ts new file mode 100644 index 0000000000..81fe22b8c9 --- /dev/null +++ b/libs/feed/src/__tests__/__mocks__/get-reflection-feed-mocks.ts @@ -0,0 +1,85 @@ +import { + genReflectionStream, + genReflectionData, + genProfileByDID, + genReflectReflection, +} from '@akashaorg/af-testing'; +import { + GetProfileByDidDocument, + GetReflectionStreamDocument, + GetReflectionByIdDocument, + GetReflectReflectionsDocument, +} from '@akashaorg/ui-awf-hooks/lib/generated/apollo'; + +interface IGetReflectionFeedMocks { + authorProfileDID: string; + beamId: string; + reflectionId: string; + reflectionContent: string; + reflectionPreviewContent?: string; +} + +export function getReflectionFeedMocks({ + authorProfileDID, + beamId, + reflectionId, + reflectionContent, + reflectionPreviewContent, +}: IGetReflectionFeedMocks) { + const profileData = genProfileByDID(authorProfileDID); + return [ + { + request: { + query: GetProfileByDidDocument, + }, + variableMatcher: () => true, + result: { + data: { + node: profileData, + }, + }, + }, + { + request: { + query: GetReflectionStreamDocument, + }, + variableMatcher: () => true, + result: { + data: { + node: genReflectionStream({ beamId, reflectionId }), + }, + }, + }, + { + request: { + query: GetReflectionByIdDocument, + }, + variableMatcher: () => true, + result: { + data: { + node: genReflectionData({ + reflectionId, + authorProfileDID, + content: reflectionContent, + }), + }, + }, + }, + { + request: { + query: GetReflectReflectionsDocument, + }, + variableMatcher: () => true, + result: { + data: reflectionPreviewContent + ? genReflectReflection({ + beamId, + reflectionId, + authorProfileDID, + content: reflectionPreviewContent, + }) + : null, + }, + }, + ]; +} diff --git a/libs/feed/src/__tests__/__mocks__/index.tsx b/libs/feed/src/__tests__/__mocks__/index.tsx new file mode 100644 index 0000000000..4bc2da7beb --- /dev/null +++ b/libs/feed/src/__tests__/__mocks__/index.tsx @@ -0,0 +1 @@ +export * from './get-reflection-feed-mocks'; diff --git a/libs/feed/src/components/cards/author-profile-avatar/index.tsx b/libs/feed/src/components/cards/author-profile-avatar/index.tsx index 525f492bf3..42b91f4e25 100644 --- a/libs/feed/src/components/cards/author-profile-avatar/index.tsx +++ b/libs/feed/src/components/cards/author-profile-avatar/index.tsx @@ -3,10 +3,11 @@ import Stack from '@akashaorg/design-system-core/lib/components/Stack'; import Text from '@akashaorg/design-system-core/lib/components/Text'; import Tooltip from '@akashaorg/design-system-core/lib/components/Tooltip'; import ProfileAvatarLoading from '@akashaorg/design-system-core/lib/components/ProfileAvatarButton/ProfileAvatarLoading'; -import { Extension } from '@akashaorg/ui-lib-extensions/lib/react/extension'; +import ProfileAvatarButton from '@akashaorg/design-system-core/lib/components/ProfileAvatarButton'; import { formatDate, formatRelativeTime } from '@akashaorg/design-system-core/lib/utils'; -import { useRootComponentProps } from '@akashaorg/ui-awf-hooks'; +import { hasOwn, transformSource, useRootComponentProps } from '@akashaorg/ui-awf-hooks'; import { useTranslation } from 'react-i18next'; +import { useGetProfileByDidQuery } from '@akashaorg/ui-awf-hooks/lib/generated/apollo'; type AuthorProfileAvatarProps = { authorId: string; @@ -17,12 +18,15 @@ type AuthorProfileAvatarProps = { const AuthorProfileAvatar: React.FC = props => { const { authorId, createdAt, hidePublishTime, pending } = props; + const { t } = useTranslation('app-extensions'); const { getTranslationPlugin, getRoutingPlugin } = useRootComponentProps(); const navigateTo = getRoutingPlugin().navigateTo; const locale = getTranslationPlugin().i18n?.languages?.[0] || 'en'; const publishTime = createdAt ? formatRelativeTime(createdAt, locale) : ''; - - const { t } = useTranslation('app-extensions'); + const profileQuery = useGetProfileByDidQuery({ + variables: { id: authorId }, + fetchPolicy: 'cache-first', + }); const onAvatarClick = (id: string) => { navigateTo({ @@ -31,64 +35,59 @@ const AuthorProfileAvatar: React.FC = props => { }); }; + if (profileQuery?.loading) return ; + + if (profileQuery?.error) return null; + + const profileData = + profileQuery.data?.node && hasOwn(profileQuery.data.node, 'isViewer') + ? profileQuery.data.node.akashaProfile + : null; + return ( - } - emptyIndicator={} - extensionData={{ - dataTestId: 'entry-profile-detail', - profileDID: authorId, - href: `/@akashaorg/app-profile/${authorId}`, - metadata: ( - <> - {publishTime && !hidePublishTime && ( - - - · - - - - {publishTime} - - - - )} - {pending && ( - - - · - + + transformSource(alternative), + )} + metadata={ + <> + {publishTime && !hidePublishTime && ( + + + · + + - {t('Pending')}... + {publishTime} - - )} - - ), - onClick: e => { - e.preventDefault(); - onAvatarClick(authorId); - }, + + + )} + {pending && ( + + + · + + + {t('Pending')}... + + + )} + + } + onClick={() => { + onAvatarClick(authorId); }} /> ); diff --git a/libs/feed/src/components/cards/beam-card/index.tsx b/libs/feed/src/components/cards/beam-card/index.tsx index 97cb9ce7a3..38800a87dc 100644 --- a/libs/feed/src/components/cards/beam-card/index.tsx +++ b/libs/feed/src/components/cards/beam-card/index.tsx @@ -167,7 +167,7 @@ const BeamCard: React.FC = props => { }} onContentClick={onContentClick} onEntryFlag={handleFlagBeam} - profileAvatarExt={ + profileAvatar={ = props => { onReflect={onReflect} onEntryFlag={handleFlagReflection} onMentionClick={handleMentionClick} - profileAvatarExt={ + profileAvatar={ = props => { const { data: reflectOfReflectionReq } = useGetReflectReflectionsQuery({ variables: { id: reflectionId, first: MAXIMUM_REFLECTION_PREVIEWS + 1 }, }); - const reflections = reflectOfReflectionReq?.akashaReflectIndex?.edges?.map(edge => ({ ...edge.node, beam: null /*Note: the hook returns partial result for beam, if complete result is needed the result of the hook should be modified*/, diff --git a/package.json b/package.json index 34bd38a503..d43b30be19 100644 --- a/package.json +++ b/package.json @@ -87,8 +87,8 @@ "@tanstack/react-router": "1.16.6", "@tanstack/react-virtual": "3.5.0", "@tanstack/router-devtools": "1.16.6", - "@testing-library/jest-dom": "5.16.5", - "@testing-library/react": "14.0.0", + "@testing-library/jest-dom": "6.4.5", + "@testing-library/react": "16.0.0", "@testing-library/react-hooks": "8.0.1", "@testing-library/user-event": "14.4.3", "@tsconfig/node20": "^20.1.4", @@ -271,7 +271,7 @@ }, "workspaces": [ "libs/*", - "apps/*" + "tests/*" ], "packageManager": "yarn@4.1.1", "engines": { diff --git a/tests/ethereum-world/cypress.config.ts b/tests/ethereum-world/cypress.config.ts deleted file mode 100644 index a78bb9203f..0000000000 --- a/tests/ethereum-world/cypress.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { defineConfig } from 'cypress'; -import { getConfigurationByFile } from './cypress/utils'; - -export default defineConfig({ - e2e: { - specPattern: 'cypress/**/*.spec.{js,jsx,ts,tsx}', - setupNodeEvents(on, config) { - const file = config.env.configFile || 'staging'; - return getConfigurationByFile(file); - }, - }, -}); diff --git a/tests/ethereum-world/cypress/fixtures/example.json b/tests/ethereum-world/cypress/fixtures/example.json deleted file mode 100644 index 02e4254378..0000000000 --- a/tests/ethereum-world/cypress/fixtures/example.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Using fixtures to represent data", - "email": "hello@cypress.io", - "body": "Fixtures are a great way to mock data for responses to routes" -} diff --git a/tests/ethereum-world/cypress/integration/antennapage.spec.ts b/tests/ethereum-world/cypress/integration/antennapage.spec.ts deleted file mode 100644 index 008d070488..0000000000 --- a/tests/ethereum-world/cypress/integration/antennapage.spec.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { TIMEOUT } from '../utils/constants'; -import { TopbarTest } from './partials/topbar.spec'; -import { TrendingWidgetTest } from './partials/trendingWidget.spec'; -import { DismissableNotificationCard } from './partials/layout-widget.spec'; - -describe('Global Antenna Page', () => { - context('Global Antenna Page', () => { - beforeEach(() => { - cy.visit('/@akashaorg/app-antenna/antenna', { timeout: TIMEOUT }); - }); - describe('Should test top bar', () => TopbarTest()); - describe('Should test trending widget', () => TrendingWidgetTest()); - describe('Should test dismissable notification card', () => DismissableNotificationCard()); - it('should redirect to profile page', () => { - cy.get('[data-testid="entry-profile-detail"]', { timeout: TIMEOUT }).first().click(); - cy.location('pathname').should('contain', '/app-profile'); - }); - }); - - describe('Posts', () => { - it('should render posts on the page', () => { - cy.get('a[href^="/@akashaorg/app-profile"]', { timeout: TIMEOUT }) - .its('length') - .should('be.gt', 0); - }); - - it('should mount card actions right extension point', () => { - cy.get('[id*="entry-card-actions-right"]', { timeout: TIMEOUT }) - .its('length') - .should('be.gt', 0); - }); - - it('should mount bookmark button into card actions right extension point', () => { - cy.get('[id*="entry-card-actions-right"]', { timeout: TIMEOUT }) - .children() - .should('have.length.gt', 0); - }); - - it('should render user avatars in posts', () => { - cy.get('[data-page-idx="0"] [data-testid="avatar-image"]', { timeout: TIMEOUT }) - .first() - .should('have.attr', 'src') - .and('not.be.empty'); - }); - - /* @TODO: The test should be active when the kebab menu is functional right now the menu isn't working - it('should open report popup on click', () => { - cy.get('[data-testid="entry-kebab-menu"]', { timeout: TIMEOUT }).click(); - }); - - */ - }); -}); diff --git a/tests/ethereum-world/cypress/integration/bookmarks.spec.ts b/tests/ethereum-world/cypress/integration/bookmarks.spec.ts deleted file mode 100644 index ba9bf21ce2..0000000000 --- a/tests/ethereum-world/cypress/integration/bookmarks.spec.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { TIMEOUT } from '../utils/constants'; - -describe('Lists Page', () => { - context('Lists Page', () => { - before(() => { - cy.visit('/@akashaorg/app-lists', { timeout: TIMEOUT }); - }); - - it('should have lists page visible', () => { - cy.get('[data-testid="lists"]', { timeout: TIMEOUT }).should('be.visible'); - }); - }); -}); diff --git a/tests/ethereum-world/cypress/integration/extensions.spec.ts b/tests/ethereum-world/cypress/integration/extensions.spec.ts deleted file mode 100644 index 3ff6c5fed9..0000000000 --- a/tests/ethereum-world/cypress/integration/extensions.spec.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { TIMEOUT } from '../utils/constants'; - -describe('Extensions-App', () => { - context('Extensions-App', () => { - before(() => { - cy.visit('/@akashaorg/app-extensions', { timeout: TIMEOUT }); - }); - - it('should have akasha verse visible', () => { - cy.get('[data-testid="extensions"]', { timeout: TIMEOUT }).should('be.visible'); - }); - }); -}); diff --git a/tests/ethereum-world/cypress/integration/legalpages.spec.ts b/tests/ethereum-world/cypress/integration/legalpages.spec.ts deleted file mode 100644 index c60dc5a0fc..0000000000 --- a/tests/ethereum-world/cypress/integration/legalpages.spec.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { TIMEOUT } from '../utils/constants'; -import { TopbarTest } from './partials/topbar.spec'; -import { TrendingWidgetTest } from './partials/trendingWidget.spec'; - -describe('Legal Pages', () => { - context('Terms of Service Page', () => { - before(() => { - cy.visit('/@akashaorg/app-legal/terms-of-service', { timeout: TIMEOUT }); - }); - - describe('Should test top bar', () => TopbarTest()); - describe('Should test trending widget', () => TrendingWidgetTest()); - it('should have legal document visible', () => { - cy.get('[data-testid="md-card"]', { timeout: TIMEOUT }).should('be.visible'); - }); - }); - context('Terms of Use Page', () => { - before(() => { - cy.visit('/@akashaorg/app-legal/terms-of-use'); - }); - - describe('Should test top bar', () => TopbarTest()); - describe('Should test trending widget', () => TrendingWidgetTest()); - it('should have legal document visible', () => { - cy.get('[data-testid="md-card"]', { timeout: TIMEOUT }).should('be.visible'); - }); - }); - context('Privacy Policy Page', () => { - before(() => { - cy.visit('/@akashaorg/app-legal/privacy-policy'); - }); - - describe('Should test top bar', () => TopbarTest()); - describe('Should test trending widget', () => TrendingWidgetTest()); - it('should have legal document visible', () => { - cy.get('[data-testid="md-card"]', { timeout: TIMEOUT }).should('be.visible'); - }); - }); - context('Code of Conduct Page', () => { - before(() => { - cy.visit('/@akashaorg/app-legal/code-of-conduct'); - }); - - describe('Should test top bar', () => TopbarTest()); - describe('Should test trending widget', () => TrendingWidgetTest()); - it('should have legal document visible', () => { - cy.get('[data-testid="md-card"]', { timeout: TIMEOUT }).should('be.visible'); - }); - }); - context('Developers Guideline Page', () => { - before(() => { - cy.visit('/@akashaorg/app-legal/developer-guidelines'); - }); - - describe('Should test top bar', () => TopbarTest()); - describe('Should test trending widget', () => TrendingWidgetTest()); - it('should have legal document visible', () => { - cy.get('[data-testid="md-card"]', { timeout: TIMEOUT }).should('be.visible'); - }); - }); -}); diff --git a/tests/ethereum-world/cypress/integration/notifications.spec.ts b/tests/ethereum-world/cypress/integration/notifications.spec.ts deleted file mode 100644 index 715f1c2e2f..0000000000 --- a/tests/ethereum-world/cypress/integration/notifications.spec.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { TIMEOUT } from '../utils/constants'; - -describe('Notifications Page', () => { - context('Notifications Page', () => { - before(() => { - cy.visit('/@akashaorg/app-notifications', { timeout: TIMEOUT }); - }); - - it('should have notifications page visible', () => { - cy.get('[data-testid="notifications"]', { timeout: TIMEOUT }).should('be.visible'); - }); - }); -}); diff --git a/tests/ethereum-world/cypress/integration/partials/layout-widget.spec.ts b/tests/ethereum-world/cypress/integration/partials/layout-widget.spec.ts deleted file mode 100644 index 1cfc1bb1f6..0000000000 --- a/tests/ethereum-world/cypress/integration/partials/layout-widget.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { TIMEOUT } from '../../utils/constants'; - -const FOCUSED_PLUGIN_SLOT_ID = '#focused-plugin-slot'; -export const LayoutWidgetFocused = () => { - it('test layout widget focused (/sign-in and /sign-up) routes', () => { - cy.get(FOCUSED_PLUGIN_SLOT_ID, { timeout: TIMEOUT }).should('exist'); - }); -}; - -export const DismissableNotificationCard = () => { - it('should display the merge notification', () => { - cy.get('[data-testid="the-merge-notification"]', { timeout: TIMEOUT }).should('exist'); - }); - it('should close the merge notification when button clicked', () => { - cy.get('[aria-label="close"]', { timeout: TIMEOUT }).first().click(); - cy.get('[data-testid="the-merge-notification"]', { timeout: TIMEOUT }).should('not.exist'); - }); - it('should not display the merge notification on next visit', () => { - // TODO: Right now the call to graphql api fails when revisiting feed page once it's resolved uncomment the line below - // cy.visit('/@akashaorg/app-antenna/feed'); - cy.get('[data-testid="the-merge-notification"]', { timeout: TIMEOUT }).should('not.exist'); - }); -}; diff --git a/tests/ethereum-world/cypress/integration/partials/topbar.spec.ts b/tests/ethereum-world/cypress/integration/partials/topbar.spec.ts deleted file mode 100644 index 0dbe95bf58..0000000000 --- a/tests/ethereum-world/cypress/integration/partials/topbar.spec.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { TIMEOUT } from '../../utils/constants'; - -export const TopbarTest = () => { - it('test topbar component', () => { - cy.get('#topbar-slot #akashaorg-ui-widget-topbar', { timeout: TIMEOUT }).should('exist'); - }); -}; diff --git a/tests/ethereum-world/cypress/integration/partials/trendingWidget.spec.ts b/tests/ethereum-world/cypress/integration/partials/trendingWidget.spec.ts deleted file mode 100644 index d85b5d130a..0000000000 --- a/tests/ethereum-world/cypress/integration/partials/trendingWidget.spec.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { TIMEOUT } from '../../utils/constants'; - -export const TrendingWidgetTest = () => { - it('test trending widget component', () => { - cy.get('#akashaorg-ui-widget-trending', { timeout: TIMEOUT }).should('exist'); - }); -}; diff --git a/tests/ethereum-world/cypress/integration/profilepage.spec.ts b/tests/ethereum-world/cypress/integration/profilepage.spec.ts deleted file mode 100644 index 3d44e35814..0000000000 --- a/tests/ethereum-world/cypress/integration/profilepage.spec.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { TIMEOUT } from '../utils/constants'; -import { TopbarTest } from './partials/topbar.spec'; -import { TrendingWidgetTest } from './partials/trendingWidget.spec'; - -const profileToVisit = 'did:pkh:eip155:5:0x36c703c4d2fa2437dc883e2e0884e57404e16493'; - -describe('Profile Page', () => { - context('Profile Page', () => { - before(() => { - cy.visit(`/@akashaorg/app-profile/${profileToVisit}`, { timeout: TIMEOUT }); - }); - describe('Should test top bar', () => TopbarTest()); - describe('Should test trending widget', () => TrendingWidgetTest()); - /* @TODO: change tests to reflect the new profile page design - it('should open report popup on click', () => { - cy.get('svg[type="moreDark"]', { timeout: TIMEOUT }).click(); - cy.contains('Report').click(); - cy.get('[data-testid="modal-card-login"]', { timeout: TIMEOUT }).should('be.visible'); - }); - it('should redirect to feed profile page', () => { - cy.visit(`/@akashaorg/app-profile/${profileToVisit}`); - cy.get('[data-testid="posts-button"]', { timeout: TIMEOUT }).first().click(); - cy.location('pathname').should('contain', `/profile-feed/${profileToVisit}`); - }); - it('should open login modal on follow button click', () => { - cy.get('[data-testid="duplex-button"]', { timeout: TIMEOUT }).first().click(); - cy.get('[data-testid="modal-card-login"]', { timeout: TIMEOUT }).should('be.visible'); - }); - */ - }); -}); diff --git a/tests/ethereum-world/cypress/integration/searchpage.spec.ts b/tests/ethereum-world/cypress/integration/searchpage.spec.ts deleted file mode 100644 index e8f222c1aa..0000000000 --- a/tests/ethereum-world/cypress/integration/searchpage.spec.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { TIMEOUT } from '../utils/constants'; -import { TopbarTest } from './partials/topbar.spec'; -import { TrendingWidgetTest } from './partials/trendingWidget.spec'; - -describe('Search Page', () => { - context('Search Page', () => { - before(() => { - cy.visit('/@akashaorg/app-search/results', { timeout: TIMEOUT }); - }); - describe('Should test top bar', () => TopbarTest()); - describe('Should test trending widget', () => TrendingWidgetTest()); - - it('should have search box visible', () => { - cy.get('[data-testid="search-box"]', { timeout: TIMEOUT }).should('be.visible'); - }); - }); -}); diff --git a/tests/ethereum-world/cypress/integration/sign-in-up.spec.ts b/tests/ethereum-world/cypress/integration/sign-in-up.spec.ts deleted file mode 100644 index 5e77b4c50b..0000000000 --- a/tests/ethereum-world/cypress/integration/sign-in-up.spec.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { TIMEOUT } from '../utils/constants'; - -describe('SignIn/SignUp app', () => { - context('Sign in', () => { - before(() => { - cy.visit('/@akashaorg/app-auth-ewa', { timeout: TIMEOUT }); - }); - - it('should have wallets list visible', () => { - cy.get('[data-testid="providers-list"]', { timeout: TIMEOUT }).should('be.visible'); - }); - }); -}); diff --git a/tests/ethereum-world/cypress/integration/tagpage.spec.ts b/tests/ethereum-world/cypress/integration/tagpage.spec.ts deleted file mode 100644 index e6103a427d..0000000000 --- a/tests/ethereum-world/cypress/integration/tagpage.spec.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { TIMEOUT } from '../utils/constants'; -import { TopbarTest } from './partials/topbar.spec'; -import { TrendingWidgetTest } from './partials/trendingWidget.spec'; - -describe('Tag Page', () => { - context('Tag Page', () => { - before(() => { - cy.visit('/@akashaorg/app-antenna/tags/test', { timeout: TIMEOUT }); - }); - describe('Should test top bar', () => TopbarTest()); - describe('Should test trending widget', () => TrendingWidgetTest()); - - it('should redirect to post page', () => { - cy.get('[data-testid="entry-content"]', { timeout: TIMEOUT }).first().click(); - cy.location('pathname').should('contain', '/post'); - }); - it('should redirect to profile page', () => { - cy.visit('/@akashaorg/app-antenna/tags/test'); - cy.get('[data-testid="entry-profile-detail"]', { timeout: TIMEOUT }).first().click(); - cy.location('pathname').should('contain', '/app-profile'); - }); - /* @TODO: revisit the test when login modal works properly - it('should open login modal on subscribe button click', () => { - cy.visit('/@akashaorg/app-antenna/tags/test'); - cy.get('[data-testid="duplex-button"]', { timeout: TIMEOUT }).first().click(); - cy.get('[data-testid="modal-card-login"]', { timeout: TIMEOUT }).should('be.visible'); - }); - */ - }); -}); diff --git a/tests/ethereum-world/cypress/local.json b/tests/ethereum-world/cypress/local.json deleted file mode 100644 index e3d9907a9a..0000000000 --- a/tests/ethereum-world/cypress/local.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "https://localhost:8131", - "viewportWidth": 1920, - "viewportHeight": 1080, - "retries": 3 -} diff --git a/tests/ethereum-world/cypress/production.json b/tests/ethereum-world/cypress/production.json deleted file mode 100644 index 4770bc8a66..0000000000 --- a/tests/ethereum-world/cypress/production.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "https://akasha.ethereum.world", - "viewportWidth": 1920, - "viewportHeight": 1080, - "retries": 3 -} diff --git a/tests/ethereum-world/cypress/pull-request.json b/tests/ethereum-world/cypress/pull-request.json deleted file mode 100644 index 2d93a20c2c..0000000000 --- a/tests/ethereum-world/cypress/pull-request.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "viewportWidth": 1920, - "viewportHeight": 1080, - "retries": 1 -} diff --git a/tests/ethereum-world/cypress/staging.json b/tests/ethereum-world/cypress/staging.json deleted file mode 100644 index 1aa4ee1852..0000000000 --- a/tests/ethereum-world/cypress/staging.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "https://next.akasha-world-framework.pages.dev/", - "viewportWidth": 1920, - "viewportHeight": 1080, - "retries": 3 -} diff --git a/tests/ethereum-world/cypress/support/commands.ts b/tests/ethereum-world/cypress/support/commands.ts deleted file mode 100644 index 0359d69245..0000000000 --- a/tests/ethereum-world/cypress/support/commands.ts +++ /dev/null @@ -1,30 +0,0 @@ -// *********************************************** -// This example commands.js shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** -// -// -// -- This is a parent command -- -// Cypress.Commands.add('login', (email, password) => { ... }) -// -// -// -- This is a child command -- -// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) -Cypress.Commands.add('exposeToWindow', (key: string, value: unknown) => { - cy.window().then(win => { - win[key] = value; - }); -}); diff --git a/tests/ethereum-world/cypress/support/e2e.ts b/tests/ethereum-world/cypress/support/e2e.ts deleted file mode 100644 index 5df9c0186c..0000000000 --- a/tests/ethereum-world/cypress/support/e2e.ts +++ /dev/null @@ -1,20 +0,0 @@ -// *********************************************************** -// This example support/e2e.js is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import './commands'; - -// Alternatively you can use CommonJS syntax: -// require('./commands') diff --git a/tests/ethereum-world/cypress/support/hooks.ts b/tests/ethereum-world/cypress/support/hooks.ts deleted file mode 100644 index 8ca16f225a..0000000000 --- a/tests/ethereum-world/cypress/support/hooks.ts +++ /dev/null @@ -1,4 +0,0 @@ -before(() => { - cy.visit('/social-app/feed'); - cy.wait(60000); -}); diff --git a/tests/ethereum-world/cypress/support/index.ts b/tests/ethereum-world/cypress/support/index.ts deleted file mode 100644 index 5d2ad79bef..0000000000 --- a/tests/ethereum-world/cypress/support/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -// *********************************************************** -// This example support/validator.ts is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.ts using ES2015 syntax: -import './commands'; -import './hooks'; -// Alternatively you can use CommonJS syntax: -// require('./commands') diff --git a/tests/ethereum-world/cypress/tsconfig.json b/tests/ethereum-world/cypress/tsconfig.json deleted file mode 100644 index f87a578b65..0000000000 --- a/tests/ethereum-world/cypress/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "lib": ["es5", "dom"], - "types": ["cypress"] - }, - "include": ["**/*.ts"] -} diff --git a/tests/ethereum-world/cypress/utils/constants.ts b/tests/ethereum-world/cypress/utils/constants.ts deleted file mode 100644 index 7d0185dc67..0000000000 --- a/tests/ethereum-world/cypress/utils/constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const TIMEOUT = 20000; diff --git a/tests/ethereum-world/cypress/utils/index.ts b/tests/ethereum-world/cypress/utils/index.ts deleted file mode 100644 index 81c5338a6f..0000000000 --- a/tests/ethereum-world/cypress/utils/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -const fs = require('fs-extra'); -const path = require('path'); - -export function getConfigurationByFile(file) { - const pathToConfigFile = path.resolve('./', 'cypress', `${file}.json`); - - return fs.readJson(pathToConfigFile); -} diff --git a/tests/src/data-generator/beam.ts b/tests/src/data-generator/beam.ts deleted file mode 100644 index 7172858de4..0000000000 --- a/tests/src/data-generator/beam.ts +++ /dev/null @@ -1,59 +0,0 @@ -import faker from 'faker'; - -const genAuthor = () => ({ id: faker.datatype.uuid(), isViewer: false }); - -const genBeamData = () => { - return { - id: faker.datatype.uuid(), - active: true, - author: genAuthor(), - content: [{ order: 1, blockID: 1 }], - createdAt: new Date(), - reflections: null, - reflectionsCount: 0, - version: '1', - }; -}; - -const genBeamSlate = () => { - return { - content: [ - { - type: 'paragraph', - children: [ - { text: '' }, - { - url: 'https://google.com', - type: 'link', - children: [{ text: '' }], - }, - { - text: ' -> test', - type: 'text', - }, - ], - }, - { - type: 'paragraph', - children: [{ text: 'another line', type: 'text' }], - }, - { - type: 'paragraph', - children: [{ text: '3rd line', type: 'text' }], - }, - { - url: 'https://pbs.twimg.com/profile_banners/3296506527/1556880274/1500x500', - size: { - width: 640, - height: 426, - naturalWidth: 640, - naturalHeight: 426, - }, - type: 'image', - children: [{ text: '' }], - }, - ], - }; -}; - -export { genBeamSlate, genBeamData }; diff --git a/tests/src/data-generator/reflection.ts b/tests/src/data-generator/reflection.ts deleted file mode 100644 index a2eb5f55b4..0000000000 --- a/tests/src/data-generator/reflection.ts +++ /dev/null @@ -1,28 +0,0 @@ -import faker from 'faker'; -import { toBinary } from '../utils/toBinary'; -import { genBeamData } from './beam'; - -const genAuthor = () => ({ id: faker.datatype.uuid(), isViewer: false }); - -const genReflectionData = () => { - return { - id: faker.datatype.uuid(), - active: true, - beam: genBeamData(), - beamID: faker.datatype.uuid(), - createdAt: '12/12/2023', - isReply: false, - author: genAuthor(), - content: [ - { - label: 'AkashaApp', - propertyType: 'slate-block', - value: window.btoa(toBinary(JSON.stringify({ text: 'Reflection content' }))), - }, - ], - mentions: [], - version: '1', - }; -}; - -export { genReflectionData }; diff --git a/tests/src/data-generator/user.ts b/tests/src/data-generator/user.ts deleted file mode 100644 index abcc2f8b70..0000000000 --- a/tests/src/data-generator/user.ts +++ /dev/null @@ -1,59 +0,0 @@ -import faker from 'faker'; -import { AkashaProfile } from '@akashaorg/typings/lib/ui'; - -const genUser = (profileDID?: string): AkashaProfile => { - const avatarUrl = faker.image.avatar(); - const coverImageUrl = faker.image.imageUrl(); - return { - id: '123', - avatar: { default: { src: avatarUrl, width: 200, height: 200 } }, - background: { default: { src: coverImageUrl, width: 200, height: 200 } }, - description: faker.lorem.sentences(3), - links: [ - { href: 'https://github.com/AKASHAorg/akasha-core' }, - { href: 'https://twitter.com/AKASHAorg' }, - ], - name: faker.fake('{{name.firstName}} {{name.lastName}}'), - did: { id: profileDID }, - createdAt: faker.date.past().toISOString(), - followersCount: 0, - }; -}; - -export const genLoggedInState = (loggedIn = false): AkashaProfile => { - if (!loggedIn) return null; - return { - id: '124', - did: { id: 'did:0x92Aa5CF1302883Ba0D470918a46033890Dd36048' }, - name: faker.fake('{{name.firstName}} {{name.lastName}}'), - avatar: { - default: { - src: 'https://api.dicebear.com/6.x/bottts-neutral/svg?seed=0x92Aa5CF1302883Ba0D470918a46033890Dd36048', - width: 200, - height: 200, - }, - }, - background: { - default: { - src: 'https://api.dicebear.com/6.x/avataaars/svg?seed=0x92Aa5CF1302883Ba0D470918a46033890Dd36048', - width: 520, - height: 320, - }, - }, - description: 'profile description', - createdAt: faker.date.past().toISOString(), - followersCount: 2, - }; -}; - -const genLoggedUser = (ethAddress?: string) => { - return { - ...genUser(ethAddress), - }; -}; - -const genEthAddress = () => { - return faker.finance.ethereumAddress(); -}; - -export { genLoggedUser, genEthAddress, genUser }; diff --git a/tests/src/index.ts b/tests/src/index.ts deleted file mode 100644 index 465c9cc4f2..0000000000 --- a/tests/src/index.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { render, RenderOptions } from '@testing-library/react'; -import React from 'react'; -import { AllProviders, AllProvidersWithApollo } from './providers'; -// import reactI18next from 'react-i18next'; - -// const installMocks = (origI18next: typeof reactI18next) => { -// jest.mock('react-i18next', () => ({ -// useTranslation: () => { -// return { -// t: (str: string) => str, -// i18n: { -// changeLanguage: () => new Promise(() => { }), -// }, -// }; -// }, -// I18nextProvider: origI18next.I18nextProvider, -// })); -// } - -// installMocks(reactI18next); - -const renderWithWrapper = ( - component: React.ReactElement, - wrapper: React.ComponentType, - options: RenderOptions, -) => { - return render(component, { wrapper, ...options }); -}; - -/* Utility function to render with all required providers */ -const renderWithAllProviders = (component: React.ReactElement, options: RenderOptions) => { - return render(component, { wrapper: AllProviders, ...options }); -}; - -/*@TODO replacement for renderWithAllProviders when react-query is fully migrated to apollo */ -/* Utility function to render with all required providers with apollo */ -const renderWithAllProvidersAndApollo = (component: React.ReactElement, options: RenderOptions) => { - return render(component, { wrapper: AllProvidersWithApollo, ...options }); -}; - -export * from '@testing-library/react'; -export { renderWithWrapper, renderWithAllProviders, renderWithAllProvidersAndApollo }; - -export * from './data-generator'; -export * from './mocks/operator'; -export * from './mocks/single-spa'; -export * from './mocks/uiEvents'; -export * from './mocks/localStorage'; diff --git a/tests/src/mocks/operator.ts b/tests/src/mocks/operator.ts deleted file mode 100644 index f6592071b1..0000000000 --- a/tests/src/mocks/operator.ts +++ /dev/null @@ -1,9 +0,0 @@ -const genMockOp = (payload?: Record) => { - return jest.fn().mockImplementation(cb => { - if (cb && payload) { - return cb(payload); - } - }); -}; - -export { genMockOp }; diff --git a/tests/src/providers.tsx b/tests/src/providers.tsx deleted file mode 100644 index 08718ac38d..0000000000 --- a/tests/src/providers.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import * as React from 'react'; -import { I18nextProvider, initReactI18next } from 'react-i18next'; -import { MockedProvider } from '@apollo/client/testing'; - -import i18n from 'i18next'; -import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client'; - -const apolloClient = new ApolloClient({ - cache: new InMemoryCache(), - version: '0.1dev', - defaultOptions: { - watchQuery: { - fetchPolicy: 'network-only', - nextFetchPolicy: 'cache-and-network', - }, - }, -}); - -const getI18nInstance = () => { - i18n.use(initReactI18next).init({ - fallbackLng: 'en', - ns: ['translations'], - defaultNS: 'translations', - debug: false, - interpolation: { - escapeValue: false, // not needed for react as it escapes by default - }, - resources: { en: {}, es: {}, de: {} }, - }); - return i18n; -}; - -const TranslationProvider: React.FC<{ children?: React.ReactNode }> = ({ children }) => { - return ( - -
- {children} -
-
- ); -}; - -const AllProviders: React.FC<{ - children: React.ReactElement>; -}> = ({ children }) => { - return ( - - {children} - - ); -}; - -/*@TODO replacement for AllProviders when react-query is fully migrated to apollo */ -const AllProvidersWithApollo: React.FC<{ - children: React.ReactElement>; -}> = ({ children }) => { - return ( - - {children} - - ); -}; - -export { TranslationProvider, AllProviders, AllProvidersWithApollo }; diff --git a/tests/tsconfig.json b/tests/tsconfig.json deleted file mode 100644 index f3b73729f3..0000000000 --- a/tests/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../tsconfig.json", - "include": ["src"], - "compilerOptions": { - "jsx": "react", - "rootDir": "src", - "outDir": "./lib" - } -} diff --git a/tests/package.json b/tests/utils/package.json similarity index 100% rename from tests/package.json rename to tests/utils/package.json diff --git a/tests/project.json b/tests/utils/project.json similarity index 85% rename from tests/project.json rename to tests/utils/project.json index f23fd6e627..39314032cd 100644 --- a/tests/project.json +++ b/tests/utils/project.json @@ -1,7 +1,7 @@ { "name": "@akashaorg/af-testing", "$schema": "../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "tests/src", + "sourceRoot": "tests/utils", "projectType": "application", "targets": { "prepare": { @@ -11,7 +11,7 @@ ], "executor": "nx:run-commands", "options": { - "cwd": "tests/", + "cwd": "tests/utils", "command": "tsc --build" } }, @@ -19,7 +19,7 @@ "dependsOn": ["prepare"], "executor": "nx:run-commands", "options": { - "cwd": "tests/", + "cwd": "tests/utils", "command": "jest" } } diff --git a/tests/src/data-generator/app-loader-extensions.ts b/tests/utils/src/data-generator/app-loader-extensions.ts similarity index 100% rename from tests/src/data-generator/app-loader-extensions.ts rename to tests/utils/src/data-generator/app-loader-extensions.ts diff --git a/tests/utils/src/data-generator/beam.ts b/tests/utils/src/data-generator/beam.ts new file mode 100644 index 0000000000..2ff144599a --- /dev/null +++ b/tests/utils/src/data-generator/beam.ts @@ -0,0 +1,200 @@ +import { toBinary } from '../toBinary'; + +interface IGenBeamData { + beamId: string; + authorProfileDID: string; + isViewer?: boolean; + nsfw?: boolean; + reflectionsCount?: number; +} + +interface IGenBeamStream { + beamId: string; + pageInfo?: { + startCursor: string; + endCursor: string; + hasPreviousPage: boolean; + hasNextPage: boolean; + }; +} + +interface IGenContentBlock { + blockId: string; + authorProfileDID: string; + content: string; +} + +const genBeamData = ({ + beamId, + authorProfileDID, + isViewer = false, + nsfw = false, + reflectionsCount = 0, +}: IGenBeamData) => { + return { + id: beamId, + reflectionsCount, + active: true, + embeddedStream: null, + author: { + id: authorProfileDID, + isViewer, + __typename: 'CeramicAccount', + }, + content: [ + { + blockID: 'kjzl6kcym7w8y51qzk3hsr5l9af8q4q1yacipuyrn8ycmz5tpv1u568x90ux7ks', + order: 0, + __typename: 'BeamBlockRecord', + }, + { + blockID: 'kjzl6kcym7w8y97lrac40t1oa9u6x4a82qi2249ys591b2uvswanuhagrhp6w7b', + order: 1, + __typename: 'BeamBlockRecord', + }, + { + blockID: 'kjzl6kcym7w8y5m9z6mev1llg7lmrmsnyxxd93xm3nq37yih1avtrppmpr2hwb1', + order: 2, + __typename: 'BeamBlockRecord', + }, + ], + tags: [], + mentions: null, + version: + 'k2zn3ty0zptz513z3s2buzbzn0v2o96ql5w592syhkz99pfkusu3f76xivwd1xxdkf1iz77i3zonlnul74i2q657f69oxu9wry816kzucgklvvvbsy1ryth', + createdAt: '2024-06-06T10:15:48.452Z', + nsfw, + reflections: { + edges: [], + pageInfo: { + hasNextPage: false, + hasPreviousPage: false, + startCursor: null, + endCursor: null, + __typename: 'PageInfo', + }, + __typename: 'AkashaReflectInterfaceConnection', + }, + __typename: 'AkashaBeam', + }; +}; + +const genBeamSlate = () => { + return { + content: [ + { + type: 'paragraph', + children: [ + { text: '' }, + { + url: 'https://google.com', + type: 'link', + children: [{ text: '' }], + }, + { + text: ' -> test', + type: 'text', + }, + ], + }, + { + type: 'paragraph', + children: [{ text: 'another line', type: 'text' }], + }, + { + type: 'paragraph', + children: [{ text: '3rd line', type: 'text' }], + }, + { + url: 'https://pbs.twimg.com/profile_banners/3296506527/1556880274/1500x500', + size: { + width: 640, + height: 426, + naturalWidth: 640, + naturalHeight: 426, + }, + type: 'image', + children: [{ text: '' }], + }, + ], + }; +}; + +const genBeamStream = ({ + beamId, + pageInfo = { + startCursor: + 'eyJ0eXBlIjoiY49udGVudCIsImlkIjoiazJ0Nnd6aGtoYWJ6NjJ6dzJqY2JydHhrb2Y2cWZhYTg1YWxkc295Z2dqZDd6YWNjYnB5Z2p3c3BmZjE2YXAiLCJ2YWx1ZSI6eyJjcmVhdGVkQXQiOiIyMDI0LTA2LTA1VDA5OjQ5OjU1LjU5M1oifX0', + endCursor: + 'eyJ0eXBlIjoiY29udGVudCIsImlkIjoiazJ0Nnd6aGtoYWJ6NjgxdWU2bzd2YWM5a2cyM3d2bWxkdXRpc21wNGk3bzg3ZmFxeG5jbGIzaXl6OTMwY3AiLCJ2YWx1ZSI6eyJjcmVhdGVkQXQiOiIyMDI0LTA2LTA0VDA5OjIzOjEyLjMwNVoifX0', + hasNextPage: false, + hasPreviousPage: false, + }, +}: IGenBeamStream) => { + return { + akashaBeamStreamList: { + edges: [ + { + node: { + beamID: beamId, + createdAt: '2024-06-05T09:49:55.593Z', + active: true, + status: null, + moderationID: null, + __typename: 'AkashaBeamStream', + }, + cursor: pageInfo.startCursor, + __typename: 'AkashaBeamStreamEdge', + }, + ], + pageInfo: { + ...pageInfo, + __typename: 'PageInfo', + }, + __typename: 'AkashaBeamStreamConnection', + }, + isViewer: false, + __typename: 'CeramicAccount', + }; +}; + +const genContentBlock = ({ blockId, content, authorProfileDID }: IGenContentBlock) => { + return { + id: blockId, + content: [ + { + propertyType: 'slate-block', + value: window.btoa(toBinary(JSON.stringify({ text: content }))), + label: '@akashaorg/app-antenna', + __typename: 'BlockLabeledValue', + }, + ], + active: true, + appVersion: { + application: { + name: 'antenna-test', + displayName: 'Antenna App', + id: 'k2t6wzhkhabz6gwifgv2ru08ghnitdv8dwwx7r823mt2s4ziz54aw1bsrv2ejc', + __typename: 'AkashaApp', + }, + applicationID: 'k2t6wzhkhabz6gwifgv2ru08ghnitdv8dwwx7r823mt2s4ziz54aw1bsrv2ejc', + id: 'k2t4wzhkhabz3aut9p2mhjzp80hzo7bee18l1pt94syakfbfcj7phve27kiwwp', + version: '0.1.0', + __typename: 'AkashaAppRelease', + }, + appVersionID: 'k2t4wzhkhabz3aut9p2mhjzp80hzo7bee18l1pt94syakfbfcj7phve27kiwwp', + createdAt: '2024-06-06T07:25:01.861Z', + kind: 'TEXT', + author: { + id: authorProfileDID, + isViewer: false, + __typename: 'CeramicAccount', + }, + version: + 'k6zn3ty0zptz511iyp1e3gnb5guv5gndv1fmfocbfcttijcbn3afe8zes6tg1ik5k8ojha8ea3fvl91b1hlb15w488ni7q38sz9sbmy674hubm2o31b1cxj', + nsfw: false, + __typename: 'AkashaContentBlock', + }; +}; + +export { genBeamSlate, genBeamStream, genContentBlock, genBeamData }; diff --git a/tests/src/data-generator/index.ts b/tests/utils/src/data-generator/index.ts similarity index 100% rename from tests/src/data-generator/index.ts rename to tests/utils/src/data-generator/index.ts diff --git a/tests/src/data-generator/integrations.ts b/tests/utils/src/data-generator/integrations.ts similarity index 93% rename from tests/src/data-generator/integrations.ts rename to tests/utils/src/data-generator/integrations.ts index d0cd371e05..2ec9e34163 100644 --- a/tests/src/data-generator/integrations.ts +++ b/tests/utils/src/data-generator/integrations.ts @@ -49,7 +49,12 @@ export const genAppProps = (): RootComponentProps & { getUrlForApp: jest.fn(), }), getTranslationPlugin: () => ({ i18n: {} }), - getExtensionsPlugin: () => ({}), + getExtensionsPlugin: () => ({ + //TODO revisit this mock + contentBlockStore: { + getMatchingBlocks: () => [], + }, + }), parseQueryString: () => ({}), plugins: {}, baseRouteName: '', diff --git a/tests/utils/src/data-generator/reflection.ts b/tests/utils/src/data-generator/reflection.ts new file mode 100644 index 0000000000..b8a9a1bd37 --- /dev/null +++ b/tests/utils/src/data-generator/reflection.ts @@ -0,0 +1,179 @@ +import { toBinary } from '../toBinary'; + +interface IGenReflectionData { + reflectionId: string; + authorProfileDID: string; + content: string; +} + +interface IGenReflectionStream { + beamId: string; + reflectionId: string; + replyTo?: string | null; + isReply?: boolean; + pageInfo?: { + startCursor: string; + endCursor: string; + hasPreviousPage: boolean; + hasNextPage: boolean; + }; +} + +interface IGenReflectReflectionStream { + beamId: string; + reflectionId: string; + authorProfileDID: string; + content: string; + pageInfo?: { + startCursor: string; + endCursor: string; + hasPreviousPage: boolean; + hasNextPage: boolean; + }; +} + +const genReflectionData = ({ reflectionId, authorProfileDID, content }: IGenReflectionData) => { + return { + id: reflectionId, + author: { + id: authorProfileDID, + isViewer: false, + __typename: 'CeramicAccount', + }, + version: + 'k6zn4ty0zptz50nar1csfls500hpgk8xvx7cyfbktkl11kpzb3bvs0uvn4rm00tq9agvu1tre2la3r8lyr0e0705jx2ybuj8p54ze1ktlrgvwv0rof0j9ll', + active: true, + content: [ + { + label: 'AkashaApp', + propertyType: 'slate-block', + value: window.btoa(toBinary(JSON.stringify({ text: content }))), + __typename: 'ReflectProviderValue', + }, + ], + isReply: null, + reflection: null, + createdAt: '2024-06-05T07:42:04.736Z', + beam: { + id: 'kjzl6kcym7w8yam23sr1xc4z842m4rv5u8y1j513hi6g3q28656dmjs5vysffs6', + author: { + id: 'did:pkh:eip155:11155111:0x205616bf38125c5a73edd5b506d0ce820074arae', + isViewer: false, + __typename: 'CeramicAccount', + }, + __typename: 'AkashaBeam', + }, + nsfw: null, + __typename: 'AkashaReflect', + }; +}; + +const genReflectionStream = ({ + beamId, + reflectionId, + isReply = false, + replyTo = null, + pageInfo = { + startCursor: + 'eyJ0eXBlIjoiY29udGVudCIsImlkIjoiazJ0Nnd6aGtoYWJ6M212Ym9jYjhrNGIyeDJkeWpxOWYzbWl4cWFkN25sc3d4d2dmdTV4ZDl4MmxsNTBwajQiLCJ2YWx1ZSI6eyJjcmVhdGVkQXQiOiIyMDI0LTA2LTA1VDA3OjQyOjEwLjUzOVoifX0', + endCursor: + 'eyJ0eXBlIjoiY29udGVudCIsImlkIjoiazJ0Nnd6aGtoYWJ6M3Q0NTJkZHNrcDNqZ3hkdWF0ZXp4NzdyMTFoMmJkYzdnNnkyZHZudWhmOXNhZWI2aHIiLCJ2YWx1ZSI6eyJjcmVhdGVkQXQiOiIyMDI0LTA2LTA1VDA3OjQyOjAxLjczMloifX0', + hasNextPage: false, + hasPreviousPage: false, + }, +}: IGenReflectionStream) => { + return { + akashaReflectStreamList: { + edges: [ + { + node: { + reflectionID: reflectionId, + moderationID: null, + beamID: beamId, + active: true, + status: null, + createdAt: '2024-06-05T07:42:10.539Z', + isReply, + replyTo, + __typename: 'AkashaReflectStream', + }, + cursor: pageInfo.startCursor, + __typename: 'AkashaReflectStreamEdge', + }, + ], + pageInfo: { + ...pageInfo, + __typename: 'PageInfo', + }, + __typename: 'AkashaReflectStreamConnection', + }, + isViewer: false, + __typename: 'CeramicAccount', + }; +}; + +const genReflectReflection = ({ + beamId, + reflectionId, + authorProfileDID, + content, + pageInfo = { + startCursor: + 'eyJ0eXBlIjoiY29udGVudCIsImlkIjoiazJ0Nnd6aGtoYWJ6M212Ym9jYjhrNGIyeDJkeWpxOWYzbWl4cWFkN25sc3d4d2dmdTV4ZDl4MmxsNTBwajQiLCJ2YWx1ZSI6eyJjcmVhdGVkQXQiOiIyMDI0LTA2LTA1VDA3OjQyOjEwLjUzOVoifX0', + endCursor: + 'eyJ0eXBlIjoiY29udGVudCIsImlkIjoiazJ0Nnd6aGtoYWJ6M3Q0NTJkZHNrcDNqZ3hkdWF0ZXp4NzdyMTFoMmJkYzdnNnkyZHZudWhmOXNhZWI2aHIiLCJ2YWx1ZSI6eyJjcmVhdGVkQXQiOiIyMDI0LTA2LTA1VDA3OjQyOjAxLjczMloifX0', + hasNextPage: false, + hasPreviousPage: false, + }, +}: IGenReflectReflectionStream) => { + return { + akashaReflectIndex: { + edges: [ + { + node: { + id: reflectionId, + author: { + id: authorProfileDID, + isViewer: false, + __typename: 'CeramicAccount', + }, + version: + 'k6zn3ty0zptz4zzkgnhmaisirhupfb9sqr5zuaez5hagmrbtlnacz3yyv1izq1gjzmopqi6eleka07qet2rtn9x8y838v9gkrkv1h5uvfpbwwdh54zsbcbe', + active: true, + content: [ + { + label: 'AkashaApp', + propertyType: 'slate-block', + value: window.btoa(toBinary(JSON.stringify({ text: content }))), + __typename: 'ReflectProviderValue', + }, + ], + isReply: true, + reflection: 'kjzl6kcym7w8yagwc0lxn4hwgdzttqmv36vfvb52thc67hqdtg5rp9kt65zofxw', + createdAt: '2024-06-06T08:33:35.747Z', + beam: { + id: beamId, + author: { + id: 'did:pkh:eip155:11155111:0x7fe1697d026268fa519f4df90637cf1ebcccf252', + isViewer: false, + __typename: 'CeramicAccount', + }, + __typename: 'AkashaBeam', + }, + nsfw: null, + __typename: 'AkashaReflect', + }, + cursor: pageInfo.startCursor, + __typename: 'AkashaReflectEdge', + }, + ], + pageInfo: { + ...pageInfo, + __typename: 'PageInfo', + }, + __typename: 'AkashaReflectConnection', + }, + }; +}; + +export { genReflectionData, genReflectionStream, genReflectReflection }; diff --git a/tests/src/data-generator/store.ts b/tests/utils/src/data-generator/store.ts similarity index 83% rename from tests/src/data-generator/store.ts rename to tests/utils/src/data-generator/store.ts index 10b7b72f23..9849a744b3 100644 --- a/tests/src/data-generator/store.ts +++ b/tests/utils/src/data-generator/store.ts @@ -1,5 +1,5 @@ import { IUserState, IUserStore } from '@akashaorg/typings/lib/ui/store'; -import { genUser } from './user'; +import { genProfileByDID } from './user'; import { AkashaProfile } from '@akashaorg/typings/lib/ui'; export function getUserInfo(): IUserState { @@ -32,7 +32,7 @@ export function getUserStore(initialState: IUserState): IUserStor () => setState({ ...state, - authenticatedProfile: genUser(fakeDID), + authenticatedProfile: genProfileByDID(fakeDID).akashaProfile, authenticatedDID: fakeDID, }), 1000, @@ -45,7 +45,11 @@ export function getUserStore(initialState: IUserState): IUserStor setState({ ...state, isAuthenticating: true }); setTimeout( () => - setState({ ...state, authenticatedProfile: genUser(fakeDID), authenticatedDID: fakeDID }), + setState({ + ...state, + authenticatedProfile: genProfileByDID(fakeDID).akashaProfile, + authenticatedDID: fakeDID, + }), 1000, ); }, diff --git a/tests/utils/src/data-generator/user.ts b/tests/utils/src/data-generator/user.ts new file mode 100644 index 0000000000..4fd92de728 --- /dev/null +++ b/tests/utils/src/data-generator/user.ts @@ -0,0 +1,34 @@ +const genProfileByDID = (profileDID?: string) => { + return { + akashaProfile: { + id: 'k2t6wzhkhabz4h6cyxd7y7uodszszzgaid7jkh6k7hs0hplj4jvk03s0e5b2lx', + did: { + id: profileDID, + isViewer: false, + __typename: 'CeramicAccount', + }, + name: 'CoffeeLover', + links: [], + background: null, + description: 'AKASHA', + avatar: null, + followers: { + pageInfo: { + startCursor: null, + endCursor: null, + hasPreviousPage: false, + hasNextPage: false, + __typename: 'PageInfo', + }, + __typename: 'AkashaFollowInterfaceConnection', + }, + createdAt: '2024-05-24T07:45:26.191Z', + nsfw: false, + __typename: 'AkashaProfile', + }, + isViewer: false, + __typename: 'CeramicAccount', + }; +}; + +export { genProfileByDID }; diff --git a/tests/src/data-generator/world-config.ts b/tests/utils/src/data-generator/world-config.ts similarity index 100% rename from tests/src/data-generator/world-config.ts rename to tests/utils/src/data-generator/world-config.ts diff --git a/tests/utils/src/index.ts b/tests/utils/src/index.ts new file mode 100644 index 0000000000..a5aaaf7f21 --- /dev/null +++ b/tests/utils/src/index.ts @@ -0,0 +1,32 @@ +import React from 'react'; +import { render, RenderOptions } from '@testing-library/react'; +import { AllProviders } from './providers'; +import { MockedResponse } from '@apollo/client/testing'; + +const renderWithWrapper = ( + component: React.ReactElement, + wrapper: React.ComponentType, + options: RenderOptions, +) => { + return render(component, { wrapper, ...options }); +}; + +/* Utility function to render with all required providers */ +const renderWithAllProviders = ( + component: React.ReactElement, + options: RenderOptions, + providerProps?: { mocks: MockedResponse[] }, +) => { + return render(component, { + wrapper: () => React.createElement(AllProviders, { providerProps }, component), + ...options, + }); +}; + +export * from '@testing-library/react'; +export { renderWithWrapper, renderWithAllProviders }; + +export * from './data-generator'; +export * from './mocks/single-spa'; +export * from './mocks/uiEvents'; +export * from './mocks/localStorage'; diff --git a/tests/src/mocks/localStorage.ts b/tests/utils/src/mocks/localStorage.ts similarity index 100% rename from tests/src/mocks/localStorage.ts rename to tests/utils/src/mocks/localStorage.ts diff --git a/tests/src/mocks/single-spa.ts b/tests/utils/src/mocks/single-spa.ts similarity index 100% rename from tests/src/mocks/single-spa.ts rename to tests/utils/src/mocks/single-spa.ts diff --git a/tests/src/mocks/uiEvents.ts b/tests/utils/src/mocks/uiEvents.ts similarity index 53% rename from tests/src/mocks/uiEvents.ts rename to tests/utils/src/mocks/uiEvents.ts index 2ff159f503..f9de2b386e 100644 --- a/tests/src/mocks/uiEvents.ts +++ b/tests/utils/src/mocks/uiEvents.ts @@ -1,4 +1,4 @@ import { Subject } from 'rxjs'; -import { UIEventData, AnalyticsEventData } from '@akashaorg/typings/lib/ui'; +import { UIEventData } from '@akashaorg/typings/lib/ui'; export const uiEventsMock = new Subject(); diff --git a/tests/utils/src/providers.tsx b/tests/utils/src/providers.tsx new file mode 100644 index 0000000000..6ba42fc064 --- /dev/null +++ b/tests/utils/src/providers.tsx @@ -0,0 +1,42 @@ +import React, { PropsWithChildren } from 'react'; +import i18n from 'i18next'; +import { I18nextProvider, initReactI18next } from 'react-i18next'; +import { MockedProvider, MockedResponse } from '@apollo/client/testing'; + +const getI18nInstance = () => { + i18n.use(initReactI18next).init({ + fallbackLng: 'en', + ns: ['translations'], + defaultNS: 'translations', + debug: false, + interpolation: { + escapeValue: false, // not needed for react as it escapes by default + }, + resources: { en: {}, es: {}, de: {} }, + }); + return i18n; +}; + +const TranslationProvider: React.FC<{ children?: React.ReactNode }> = ({ children }) => { + return ( + +
+ {children} +
+
+ ); +}; + +const AllProviders: React.FC< + PropsWithChildren<{ + providerProps: { mocks: MockedResponse[] }; + }> +> = ({ providerProps, children }) => { + return ( + + {children} + + ); +}; + +export { TranslationProvider, AllProviders }; diff --git a/tests/src/utils/toBinary.ts b/tests/utils/src/toBinary.ts similarity index 100% rename from tests/src/utils/toBinary.ts rename to tests/utils/src/toBinary.ts diff --git a/tests/utils/tsconfig.json b/tests/utils/tsconfig.json new file mode 100644 index 0000000000..3583d3304b --- /dev/null +++ b/tests/utils/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "include": ["./src"], + "compilerOptions": { + "jsx": "react", + "rootDir": "./src", + "outDir": "./lib" + } +} diff --git a/yarn.lock b/yarn.lock index e626f2b471..36348b40ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -26,6 +26,12 @@ __metadata: languageName: node linkType: hard +"@akashaorg/af-testing@workspace:tests/utils": + version: 0.0.0-use.local + resolution: "@akashaorg/af-testing@workspace:tests/utils" + languageName: unknown + linkType: soft + "@akashaorg/awf-sdk@workspace:libs/sdk": version: 0.0.0-use.local resolution: "@akashaorg/awf-sdk@workspace:libs/sdk" @@ -10672,24 +10678,7 @@ __metadata: languageName: node linkType: hard -"@testing-library/jest-dom@npm:5.16.5": - version: 5.16.5 - resolution: "@testing-library/jest-dom@npm:5.16.5" - dependencies: - "@adobe/css-tools": "npm:^4.0.1" - "@babel/runtime": "npm:^7.9.2" - "@types/testing-library__jest-dom": "npm:^5.9.1" - aria-query: "npm:^5.0.0" - chalk: "npm:^3.0.0" - css.escape: "npm:^1.5.1" - dom-accessibility-api: "npm:^0.5.6" - lodash: "npm:^4.17.15" - redent: "npm:^3.0.0" - checksum: 10/472a14b6295a18af28b5133ecaf4d22a7bb9c50bf05e1f04a076b2e2d7c596e76cdd56a95387ad6d2a4dda0c46bc93d95cbca5b314fabe0fd13362f29118749e - languageName: node - linkType: hard - -"@testing-library/jest-dom@npm:^6.1.2": +"@testing-library/jest-dom@npm:6.4.5, @testing-library/jest-dom@npm:^6.1.2": version: 6.4.5 resolution: "@testing-library/jest-dom@npm:6.4.5" dependencies: @@ -10744,17 +10733,23 @@ __metadata: languageName: node linkType: hard -"@testing-library/react@npm:14.0.0": - version: 14.0.0 - resolution: "@testing-library/react@npm:14.0.0" +"@testing-library/react@npm:16.0.0": + version: 16.0.0 + resolution: "@testing-library/react@npm:16.0.0" dependencies: "@babel/runtime": "npm:^7.12.5" - "@testing-library/dom": "npm:^9.0.0" - "@types/react-dom": "npm:^18.0.0" peerDependencies: + "@testing-library/dom": ^10.0.0 + "@types/react": ^18.0.0 + "@types/react-dom": ^18.0.0 react: ^18.0.0 react-dom: ^18.0.0 - checksum: 10/1f2a4f78d107e741b35671e9c7dd992d5c9f49b48ee24112ccfe636179be72f3c62a65b1405901b59eb6cde996176ebc2c99099e04d9f14575641e46688747f0 + peerDependenciesMeta: + "@types/react": + optional: true + "@types/react-dom": + optional: true + checksum: 10/b32894be94e31276138decfa6bcea69dfebc0c37cf91499ff6c878f41eb1154a43a7df6eb1e72e7bede78468af6cb67ca59e4acd3206b41f3ecdae2c6efdf67e languageName: node linkType: hard @@ -11330,16 +11325,6 @@ __metadata: languageName: node linkType: hard -"@types/jest@npm:*, @types/jest@npm:^29.4.0": - version: 29.5.12 - resolution: "@types/jest@npm:29.5.12" - dependencies: - expect: "npm:^29.0.0" - pretty-format: "npm:^29.0.0" - checksum: 10/312e8dcf92cdd5a5847d6426f0940829bca6fe6b5a917248f3d7f7ef5d85c9ce78ef05e47d2bbabc40d41a930e0e36db2d443d2610a9e3db9062da2d5c904211 - languageName: node - linkType: hard - "@types/jest@npm:28.1.3": version: 28.1.3 resolution: "@types/jest@npm:28.1.3" @@ -11350,6 +11335,16 @@ __metadata: languageName: node linkType: hard +"@types/jest@npm:^29.4.0": + version: 29.5.12 + resolution: "@types/jest@npm:29.5.12" + dependencies: + expect: "npm:^29.0.0" + pretty-format: "npm:^29.0.0" + checksum: 10/312e8dcf92cdd5a5847d6426f0940829bca6fe6b5a917248f3d7f7ef5d85c9ce78ef05e47d2bbabc40d41a930e0e36db2d443d2610a9e3db9062da2d5c904211 + languageName: node + linkType: hard + "@types/js-cookie@npm:^2.2.6": version: 2.2.7 resolution: "@types/js-cookie@npm:2.2.7" @@ -11620,15 +11615,6 @@ __metadata: languageName: node linkType: hard -"@types/react-dom@npm:^18.0.0": - version: 18.3.0 - resolution: "@types/react-dom@npm:18.3.0" - dependencies: - "@types/react": "npm:*" - checksum: 10/6ff53f5a7b7fba952a68e114d3b542ebdc1e87a794234785ebab0bcd9bde7fb4885f21ebaf93d26dc0a1b5b93287f42cad68b78ae04dddf6b20da7aceff0beaf - languageName: node - linkType: hard - "@types/react-test-renderer@npm:18.0.0": version: 18.0.0 resolution: "@types/react-test-renderer@npm:18.0.0" @@ -11805,15 +11791,6 @@ __metadata: languageName: node linkType: hard -"@types/testing-library__jest-dom@npm:^5.9.1": - version: 5.14.9 - resolution: "@types/testing-library__jest-dom@npm:5.14.9" - dependencies: - "@types/jest": "npm:*" - checksum: 10/e257de95a4a9385cc09ae4ca3396d23ad4b5cfb8e021a1ca3454c424c34636075f6fe151b2f881f79bf9d497aa04fbfae62449b135f293e8d2d614fa899898a8 - languageName: node - linkType: hard - "@types/tough-cookie@npm:*": version: 4.0.5 resolution: "@types/tough-cookie@npm:4.0.5" @@ -18249,7 +18226,7 @@ __metadata: languageName: node linkType: hard -"dom-accessibility-api@npm:^0.5.6, dom-accessibility-api@npm:^0.5.9": +"dom-accessibility-api@npm:^0.5.9": version: 0.5.16 resolution: "dom-accessibility-api@npm:0.5.16" checksum: 10/377b4a7f9eae0a5d72e1068c369c99e0e4ca17fdfd5219f3abd32a73a590749a267475a59d7b03a891f9b673c27429133a818c44b2e47e32fec024b34274e2ca @@ -26572,7 +26549,7 @@ __metadata: languageName: node linkType: hard -"lodash@npm:^4, lodash@npm:^4.17.11, lodash@npm:^4.17.14, lodash@npm:^4.17.15, lodash@npm:^4.17.20, lodash@npm:^4.17.21, lodash@npm:^4.17.4, lodash@npm:~4.17.0": +"lodash@npm:^4, lodash@npm:^4.17.11, lodash@npm:^4.17.14, lodash@npm:^4.17.20, lodash@npm:^4.17.21, lodash@npm:^4.17.4, lodash@npm:~4.17.0": version: 4.17.21 resolution: "lodash@npm:4.17.21" checksum: 10/c08619c038846ea6ac754abd6dd29d2568aa705feb69339e836dfa8d8b09abbb2f859371e86863eda41848221f9af43714491467b5b0299122431e202bb0c532 @@ -32674,8 +32651,8 @@ __metadata: "@tanstack/react-router": "npm:1.16.6" "@tanstack/react-virtual": "npm:3.5.0" "@tanstack/router-devtools": "npm:1.16.6" - "@testing-library/jest-dom": "npm:5.16.5" - "@testing-library/react": "npm:14.0.0" + "@testing-library/jest-dom": "npm:6.4.5" + "@testing-library/react": "npm:16.0.0" "@testing-library/react-hooks": "npm:8.0.1" "@testing-library/user-event": "npm:14.4.3" "@tsconfig/node20": "npm:^20.1.4"