The chat list and header show the listing's type, city and closed/deleted status; the header info button opens the full listing in PostDetailModal with a "show on map" action. Deleted or unpublished listings are marked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.9 KiB
JavaScript
39 lines
1.9 KiB
JavaScript
/**
|
|
* По какому объявлению чат: подпись в списке/шапке (тип, город, статус)
|
|
* и кнопка в шапке, открывающая карточку. Удалённое объявление помечается.
|
|
*/
|
|
import { render, screen, fireEvent } from "@testing-library/react";
|
|
import i18n from "../../i18n";
|
|
import ChatPostMeta from "./ChatPostMeta";
|
|
import ChatHeader from "./ChatHeader";
|
|
import { cachePostsFromChats, getPostForChat } from "../../stores/chatPostStore";
|
|
|
|
const t = i18n.t.bind(i18n);
|
|
|
|
beforeAll(() => i18n.changeLanguage("ru"));
|
|
|
|
test("подпись показывает тип, город и закрытый статус", () => {
|
|
render(<ChatPostMeta post={{ type: "FOUND", status: "CLOSED", city: "Москва" }} t={t} />);
|
|
expect(screen.getByText("Находка")).toBeTruthy();
|
|
expect(screen.getByText("Москва")).toBeTruthy();
|
|
expect(screen.getByText("Закрыто")).toBeTruthy();
|
|
});
|
|
|
|
test("удалённое объявление сохраняет прежний заголовок и помечается", () => {
|
|
cachePostsFromChats([{ id: 501, postId: 9, post: { id: 9, title: "Шляпа", images: [] } }]);
|
|
cachePostsFromChats([{ id: 501, postId: 9, post: null }]);
|
|
|
|
const post = getPostForChat(501);
|
|
expect(post).toMatchObject({ id: 9, title: "Шляпа", removed: true });
|
|
|
|
render(<ChatPostMeta post={post} t={t} />);
|
|
expect(screen.getByText("Объявление удалено")).toBeTruthy();
|
|
});
|
|
|
|
test("кнопка в шапке открывает объявление", () => {
|
|
const onInfo = jest.fn();
|
|
render(<ChatHeader title="Шляпа" onBack={() => {}} onInfo={onInfo} infoLabel="Объявление этого чата" />);
|
|
fireEvent.click(screen.getByLabelText("Объявление этого чата"));
|
|
expect(onInfo).toHaveBeenCalledTimes(1);
|
|
});
|