notifications view sidebar

This commit is contained in:
Martti Malmi 2023-08-21 17:49:46 +03:00
parent ab95376df4
commit 8c65913af7
10 changed files with 55 additions and 24 deletions

View File

@ -0,0 +1,29 @@
import { cleanup, render, screen } from '@testing-library/preact';
import { afterEach, describe, expect, it } from 'vitest';
import localState from '@/state/LocalState.ts';
import { translate as t } from '@/translations/Translation.mjs';
import Header from './Header.tsx';
describe('Header Component Rendering', () => {
afterEach(cleanup);
it('renders iris logo for homepage', () => {
localState.get('activeRoute').put('/');
render(<Header />);
const logo = screen.getByText('iris');
expect(logo).not.toBeNull();
});
it('renders login and signup buttons when not logged in', () => {
render(<Header />);
const loginBtn = screen.getByText(t('log_in'));
expect(loginBtn).not.toBeNull();
const signupBtn = screen.getByText(t('sign_up'));
expect(signupBtn).not.toBeNull();
});
});

View File

@ -3,16 +3,15 @@ import { Cog8ToothIcon, HeartIcon } from '@heroicons/react/24/outline';
import { ArrowLeftIcon, HeartIcon as HeartIconFull } from '@heroicons/react/24/solid'; import { ArrowLeftIcon, HeartIcon as HeartIconFull } from '@heroicons/react/24/solid';
import { Link, route } from 'preact-router'; import { Link, route } from 'preact-router';
import Component from '../BaseComponent'; import Component from '../../BaseComponent.ts';
import Key from '../nostr/Key'; import Key from '../../nostr/Key.ts';
import Relays from '../nostr/Relays'; import Relays from '../../nostr/Relays.ts';
import localState from '../state/LocalState.ts'; import localState from '../../state/LocalState.ts';
import { translate as t } from '../translations/Translation.mjs'; import { translate as t } from '../../translations/Translation.mjs';
import Icons from '../utils/Icons'; import Icons from '../../utils/Icons.tsx';
import Show from '../helpers/Show.tsx';
import Show from './helpers/Show'; import SearchBox from '../searchbox/SearchBox.tsx';
import SearchBox from './searchbox/SearchBox.tsx'; import Name from '../user/Name.tsx';
import Name from './user/Name';
declare global { declare global {
interface Window { interface Window {

View File

@ -4,7 +4,7 @@ import Show from '@/components/helpers/Show';
import { RouteProps } from '@/views/types'; import { RouteProps } from '@/views/types';
import Follow from '../components/buttons/Follow'; import Follow from '../components/buttons/Follow';
import Header from '../components/Header'; import Header from '../components/header/Header.tsx';
import Avatar from '../components/user/Avatar'; import Avatar from '../components/user/Avatar';
import Name from '../components/user/Name'; import Name from '../components/user/Name';
import { translate as t } from '../translations/Translation.mjs'; import { translate as t } from '../translations/Translation.mjs';

View File

@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { RouteProps } from '@/views/types.ts'; import { RouteProps } from '@/views/types.ts';
import Header from '../components/Header'; import Header from '../components/header/Header.tsx';
import Key from '../nostr/Key'; import Key from '../nostr/Key';
import { translate as t } from '../translations/Translation.mjs'; import { translate as t } from '../translations/Translation.mjs';

View File

@ -1,6 +1,6 @@
import { RouteProps } from '@/views/types'; import { RouteProps } from '@/views/types';
import Header from '../components/Header'; import Header from '../components/header/Header.tsx';
import { translate as t } from '../translations/Translation.mjs'; import { translate as t } from '../translations/Translation.mjs';
const Subscribe: React.FC<RouteProps> = () => ( const Subscribe: React.FC<RouteProps> = () => (

View File

@ -2,7 +2,7 @@ import debounce from 'lodash/debounce';
import { useEffect, useRef } from 'preact/hooks'; import { useEffect, useRef } from 'preact/hooks';
import ErrorBoundary from '../components/ErrorBoundary'; import ErrorBoundary from '../components/ErrorBoundary';
import Header from '../components/Header'; import Header from '../components/header/Header.tsx';
import Show from '../components/helpers/Show'; import Show from '../components/helpers/Show';
import Search from './Search'; import Search from './Search';

View File

@ -6,6 +6,7 @@ import EventDB from '@/nostr/EventDB';
import Events from '@/nostr/Events'; import Events from '@/nostr/Events';
import Key from '@/nostr/Key'; import Key from '@/nostr/Key';
import { RouteProps } from '@/views/types.ts'; import { RouteProps } from '@/views/types.ts';
import View from '@/views/View.tsx';
import Feed from '../../components/feed/Feed'; import Feed from '../../components/feed/Feed';
import Session from '../../nostr/Session'; import Session from '../../nostr/Session';
@ -60,6 +61,7 @@ const Notifications: React.FC<RouteProps> = () => {
}, [updateNotificationsLastOpened]); }, [updateNotificationsLastOpened]);
return ( return (
<View>
<Feed <Feed
key="notifications" key="notifications"
showDisplayAs={false} showDisplayAs={false}
@ -67,6 +69,7 @@ const Notifications: React.FC<RouteProps> = () => {
filterOptions={filterOptions} filterOptions={filterOptions}
fetchEvents={fetchEvents} fetchEvents={fetchEvents}
/> />
</View>
); );
}; };

View File

@ -7,7 +7,7 @@ import Login from '@/views/login/Login.tsx';
describe('Login View Rendering', () => { describe('Login View Rendering', () => {
afterEach(cleanup); afterEach(cleanup);
it('renders login form', () => { it('renders login form', async () => {
render(<Login />); render(<Login />);
const loginInput = screen.getByPlaceholderText(t('whats_your_name')); const loginInput = screen.getByPlaceholderText(t('whats_your_name'));

View File

@ -6,7 +6,7 @@ import { ID } from '@/utils/UniqueIds.ts';
import { RouteProps } from '@/views/types.ts'; import { RouteProps } from '@/views/types.ts';
import Upload from '../../components/buttons/Upload.tsx'; import Upload from '../../components/buttons/Upload.tsx';
import Header from '../../components/Header.tsx'; import Header from '../../components/header/Header.tsx';
import SafeImg from '../../components/SafeImg.tsx'; import SafeImg from '../../components/SafeImg.tsx';
import Key from '../../nostr/Key.ts'; import Key from '../../nostr/Key.ts';
import SocialNetwork from '../../nostr/SocialNetwork.ts'; import SocialNetwork from '../../nostr/SocialNetwork.ts';

View File

@ -1,4 +1,4 @@
import Header from '../../components/Header'; import Header from '../../components/header/Header.tsx';
import SettingsContent from './SettingsContent'; import SettingsContent from './SettingsContent';
import SettingsMenu from './SettingsMenu'; import SettingsMenu from './SettingsMenu';