test(web): add Vitest tests for search, auth, public, and admin layouts
- SearchLayout: verifies children pass-through (3 tests) - AuthLayout: verifies role=main, #main-content, max-w-md centering (5 tests) - PublicLayout: verifies navbar, ticker strip, footer, compare bar, #main-content (8 tests) - AdminLayout: verifies sidebar nav, auth guard, loading state, logout, mobile toggle (10 tests) All 156 web test files pass (1157 total web tests). Pre-existing API test failures in unrelated modules (auth OTP handler, projects, search indexer, admin settings encryption) are outside scope of this task. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/* eslint-disable import-x/order */
|
||||
/**
|
||||
* Kiểm thử SearchLayout: layout đơn giản chỉ render children.
|
||||
*/
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import * as React from 'react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import SearchLayout from '../layout';
|
||||
|
||||
describe('SearchLayout', () => {
|
||||
it('renders children', () => {
|
||||
render(
|
||||
<SearchLayout>
|
||||
<div data-testid="child">Nội dung tìm kiếm</div>
|
||||
</SearchLayout>,
|
||||
);
|
||||
expect(screen.getByTestId('child')).toBeInTheDocument();
|
||||
expect(screen.getByText('Nội dung tìm kiếm')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders multiple children', () => {
|
||||
render(
|
||||
<SearchLayout>
|
||||
<p data-testid="a">A</p>
|
||||
<p data-testid="b">B</p>
|
||||
</SearchLayout>,
|
||||
);
|
||||
expect(screen.getByTestId('a')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('b')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not add extra wrapper markup', () => {
|
||||
const { container } = render(
|
||||
<SearchLayout>
|
||||
<span id="only-child">Span</span>
|
||||
</SearchLayout>,
|
||||
);
|
||||
// The layout returns children directly, so the span should be the root child
|
||||
expect(container.querySelector('#only-child')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user