fix(waf): complete geography match options

Use full country and ISO subdivision data, show localized country names with codes, and add searchable region selection.
This commit is contained in:
ryan
2026-07-13 16:34:18 +08:00
parent a61d55bb1b
commit 0c2961ae6d
10 changed files with 179 additions and 75 deletions
@@ -52,7 +52,7 @@ it('creates any normalized valid geography code', async () => {
const onChange = vi.fn();
render(<NodeProperties node={node} ipGroups={[]} onChange={onChange} />);
fireEvent.click(screen.getByRole('button', { name: '国家代码' }));
fireEvent.change(await screen.findByPlaceholderText('输入代码并添加'), {
fireEvent.change(await screen.findByPlaceholderText('搜索名称或代码'), {
target: { value: 'nz' },
});
fireEvent.click(screen.getByRole('button', { name: '添加代码' }));
@@ -62,3 +62,17 @@ it('creates any normalized valid geography code', async () => {
}),
);
});
it('shows localized country names together with their codes', async () => {
const node: WAFRuleNode = {
id: 'geo',
type: 'geo_match',
position: { x: 0, y: 0 },
config: { countries: [], regions: [] },
};
render(<NodeProperties node={node} ipGroups={[]} onChange={vi.fn()} />);
fireEvent.click(screen.getByRole('button', { name: '国家代码' }));
expect(await screen.findByText('中国')).toBeInTheDocument();
expect(screen.getByText('CN')).toBeInTheDocument();
expect(screen.getByText(/共 249 个国家\/地区/)).toBeInTheDocument();
});