test: fix flaky browser-mode tests in AnnotationShape and OcrTrainingCard specs #547
@@ -107,7 +107,7 @@ describe('AnnotationLayer', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await expect.element(page.getByTestId('annotation-ann-1')).toBeInTheDocument();
|
await expect.element(page.getByTestId('annotation-ann-1')).toBeInTheDocument();
|
||||||
expect(page.getByTestId('annotation-delete-ann-1').query()).toBeNull();
|
await expect.element(page.getByTestId('annotation-delete-ann-1')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not show delete button when canDraw is false even if annotation is active', async () => {
|
it('does not show delete button when canDraw is false even if annotation is active', async () => {
|
||||||
@@ -120,6 +120,6 @@ describe('AnnotationLayer', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await expect.element(page.getByTestId('annotation-ann-1')).toBeInTheDocument();
|
await expect.element(page.getByTestId('annotation-ann-1')).toBeInTheDocument();
|
||||||
expect(page.getByTestId('annotation-delete-ann-1').query()).toBeNull();
|
await expect.element(page.getByTestId('annotation-delete-ann-1')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ describe('AnnotationShape', () => {
|
|||||||
onpointerleave: () => {}
|
onpointerleave: () => {}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(page.getByTestId('annotation-delete-ann-1').query()).toBeNull();
|
await expect.element(page.getByTestId('annotation-delete-ann-1')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not show delete button when showDelete is true but neither hovered nor active', async () => {
|
it('does not show delete button when showDelete is true but neither hovered nor active', async () => {
|
||||||
@@ -60,7 +60,7 @@ describe('AnnotationShape', () => {
|
|||||||
onpointerleave: () => {}
|
onpointerleave: () => {}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(page.getByTestId('annotation-delete-ann-1').query()).toBeNull();
|
await expect.element(page.getByTestId('annotation-delete-ann-1')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows delete button when showDelete is true and isHovered is true', async () => {
|
it('shows delete button when showDelete is true and isHovered is true', async () => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
import { cleanup, render } from 'vitest-browser-svelte';
|
import { cleanup, render } from 'vitest-browser-svelte';
|
||||||
import { page } from 'vitest/browser';
|
import { page } from 'vitest/browser';
|
||||||
import OcrTrainingCard from './OcrTrainingCard.svelte';
|
import OcrTrainingCard from './OcrTrainingCard.svelte';
|
||||||
@@ -74,6 +74,12 @@ describe('OcrTrainingCard — enabled state', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('OcrTrainingCard — success dismiss button', () => {
|
describe('OcrTrainingCard — success dismiss button', () => {
|
||||||
|
beforeEach(() => vi.useFakeTimers());
|
||||||
|
afterEach(() => {
|
||||||
|
vi.runAllTimers();
|
||||||
|
vi.useRealTimers();
|
||||||
|
});
|
||||||
|
|
||||||
it('dismiss button has 44×44px touch target (h-11 w-11)', async () => {
|
it('dismiss button has 44×44px touch target (h-11 w-11)', async () => {
|
||||||
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ ok: true }));
|
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ ok: true }));
|
||||||
|
|
||||||
@@ -108,7 +114,9 @@ describe('OcrTrainingCard — in-flight state', () => {
|
|||||||
// While fetch is still pending the button label becomes "…"
|
// While fetch is still pending the button label becomes "…"
|
||||||
await expect.element(page.getByRole('button', { name: '…' })).toBeInTheDocument();
|
await expect.element(page.getByRole('button', { name: '…' })).toBeInTheDocument();
|
||||||
|
|
||||||
// Cleanup: resolve the pending promise
|
|
||||||
resolveFetch({ ok: false });
|
resolveFetch({ ok: false });
|
||||||
|
await expect
|
||||||
|
.element(page.getByRole('button', { name: /Training starten/i }))
|
||||||
|
.not.toBeDisabled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user