test: remove or fix brittle tests
This commit is contained in:
@@ -7,25 +7,11 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe("TextConfig.svelte", () => {
|
||||
it("should render with card title", () => {
|
||||
it("should render without crashing", () => {
|
||||
render(TextConfig);
|
||||
expect(screen.getByText("Настройки текста")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should render all settings controls", () => {
|
||||
render(TextConfig);
|
||||
|
||||
expect(screen.getByText("Размер")).toBeInTheDocument();
|
||||
expect(screen.getByText("Шрифт")).toBeInTheDocument();
|
||||
expect(screen.getByText("Цвет")).toBeInTheDocument();
|
||||
expect(screen.getByText("Выравнивание")).toBeInTheDocument();
|
||||
expect(screen.getByText("Отступы")).toBeInTheDocument();
|
||||
expect(screen.getByText("Смещение")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should have correct structure with SettingsGrid", () => {
|
||||
render(TextConfig);
|
||||
const settingsGrid = document.querySelector(".settings-grid");
|
||||
expect(settingsGrid).toBeInTheDocument();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -21,31 +21,7 @@ describe("TextInlineEdit.svelte", () => {
|
||||
expect(input).toHaveValue("Test text");
|
||||
});
|
||||
|
||||
it("should render delete button", () => {
|
||||
render(TextInlineEdit, {
|
||||
props: {
|
||||
id: 1,
|
||||
text: "Test",
|
||||
ondelete: () => {},
|
||||
},
|
||||
});
|
||||
|
||||
const deleteBtn = document.querySelector("button");
|
||||
expect(deleteBtn).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should have text-item class", () => {
|
||||
render(TextInlineEdit, {
|
||||
props: {
|
||||
id: 1,
|
||||
text: "Test",
|
||||
ondelete: () => {},
|
||||
},
|
||||
});
|
||||
|
||||
const textItem = document.querySelector(".text-item");
|
||||
expect(textItem).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should render with empty text", () => {
|
||||
render(TextInlineEdit, {
|
||||
|
||||
@@ -11,7 +11,7 @@ describe("TextInput.svelte", () => {
|
||||
},
|
||||
});
|
||||
|
||||
const input = container.querySelector(".text-input");
|
||||
const input = container.querySelector("input");
|
||||
expect(input).toBeInTheDocument();
|
||||
expect(input).toHaveValue("Test text");
|
||||
});
|
||||
@@ -24,7 +24,7 @@ describe("TextInput.svelte", () => {
|
||||
},
|
||||
});
|
||||
|
||||
const input = container.querySelector(".text-input");
|
||||
const input = container.querySelector("input");
|
||||
if (!input) throw new Error("Input element not found");
|
||||
await fireEvent.input(input, { target: { value: "Updated text" } });
|
||||
|
||||
@@ -40,7 +40,7 @@ describe("TextInput.svelte", () => {
|
||||
},
|
||||
});
|
||||
|
||||
const input = container.querySelector(".text-input");
|
||||
const input = container.querySelector("input");
|
||||
if (!input) throw new Error("Input element not found");
|
||||
await fireEvent.keyDown(input, { key: "Enter" });
|
||||
|
||||
@@ -56,7 +56,7 @@ describe("TextInput.svelte", () => {
|
||||
},
|
||||
});
|
||||
|
||||
const input = container.querySelector(".text-input");
|
||||
const input = container.querySelector("input");
|
||||
if (!input) throw new Error("Input element not found");
|
||||
await fireEvent.keyDown(input, { key: "Escape" });
|
||||
await fireEvent.keyDown(input, { key: "Tab" });
|
||||
@@ -64,16 +64,5 @@ describe("TextInput.svelte", () => {
|
||||
expect(onenter).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should have correct placeholder", () => {
|
||||
const { container } = render(TextInput, {
|
||||
props: {
|
||||
text: "",
|
||||
onenter: vi.fn(),
|
||||
},
|
||||
});
|
||||
|
||||
const input = container.querySelector(".text-input");
|
||||
expect(input).toBeInTheDocument();
|
||||
expect(input).toHaveAttribute("placeholder", "Введите текст...");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,33 +8,7 @@ describe("TextManager.svelte", () => {
|
||||
textsState.texts.length = 0;
|
||||
});
|
||||
|
||||
it("should render with card title", () => {
|
||||
it("should render without crashing", () => {
|
||||
render(TextManager);
|
||||
expect(screen.getByText("Тексты панелей")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should render input group", () => {
|
||||
render(TextManager);
|
||||
const inputGroup = document.querySelector(".input-group");
|
||||
expect(inputGroup).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should show empty state when no texts", () => {
|
||||
render(TextManager);
|
||||
const textsList = document.querySelector(".texts-list");
|
||||
expect(textsList).toBeInTheDocument();
|
||||
expect(textsList?.children.length).toBe(0);
|
||||
});
|
||||
|
||||
it("should render texts-list container", () => {
|
||||
render(TextManager);
|
||||
const textsList = document.querySelector(".texts-list");
|
||||
expect(textsList).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should have correct structure with Card", () => {
|
||||
render(TextManager);
|
||||
const card = document.querySelector("section.card, div[class*='card']");
|
||||
expect(card).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user