mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-07-11 22:47:18 +08:00
- Nest ab-edit-rule's delete confirmation inside the main ab-modal so headlessui suspends the outer dialog's Escape/outside-click while the inner one is open (clicking the delete-files checkbox no longer closes both layers); regression-tested with a nested-modal vitest. - Restore autocomplete passthrough (ab-input prop + ab-setting wiring) so downloader/proxy password fields keep autocomplete=off. - Guarantee 44px touch targets for ab-button sm on touch; repoint or remove the dead .n-button deep selectors in wizard/config/downloader/ log left over from the sweep. - a11y labels: modal X and search closes announce 'Close', tag remove announces 'Remove' (new common.close/common.remove i18n pairs); ab-field renders label[for] only when the control adopts the id, span + aria-labelledby otherwise. - Convert the last NPopconfirms (passkey/search-provider/update-card) to useConfirm with danger icon buttons; drop legacy .notification-action CSS that fought ab-button variants. - Fix missing homepage.rule.offset key (→ episode_offset), normalize test names to the should-convention, run prettier over the branch. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FAxVyRwrY7z5NotTtgnwVs
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
import { mount } from '@vue/test-utils';
|
|
import AbMenu from '../ab-menu.vue';
|
|
|
|
function items(handler = vi.fn()) {
|
|
return [
|
|
{ key: 'enable', label: 'Enable rule', handler },
|
|
{ key: 'archive', label: () => 'Archive rule' },
|
|
{ key: 'delete', label: 'Delete rule', danger: true },
|
|
];
|
|
}
|
|
|
|
describe('ab-menu', () => {
|
|
it('should render item labels (string and function) after opening', async () => {
|
|
const wrapper = mount(AbMenu, {
|
|
props: { items: items() },
|
|
slots: { trigger: '<button type="button">Actions</button>' },
|
|
attachTo: document.body,
|
|
});
|
|
await wrapper.find('button').trigger('click');
|
|
expect(wrapper.text()).toContain('Enable rule');
|
|
expect(wrapper.text()).toContain('Archive rule');
|
|
});
|
|
|
|
it('should call the item handler and emits select on item click', async () => {
|
|
const handler = vi.fn();
|
|
const wrapper = mount(AbMenu, {
|
|
props: { items: items(handler) },
|
|
slots: { trigger: '<button type="button">Actions</button>' },
|
|
attachTo: document.body,
|
|
});
|
|
await wrapper.find('button').trigger('click');
|
|
await wrapper.findAll('[role="menuitem"]')[0].trigger('click');
|
|
expect(handler).toHaveBeenCalledTimes(1);
|
|
expect(wrapper.emitted('select')?.[0]?.[0]).toMatchObject({
|
|
key: 'enable',
|
|
});
|
|
});
|
|
|
|
it('should mark danger items with the danger class', async () => {
|
|
const wrapper = mount(AbMenu, {
|
|
props: { items: items() },
|
|
slots: { trigger: '<button type="button">Actions</button>' },
|
|
attachTo: document.body,
|
|
});
|
|
await wrapper.find('button').trigger('click');
|
|
const entries = wrapper.findAll('[role="menuitem"]');
|
|
expect(entries[2].classes()).toContain('ab-menu-item--danger');
|
|
});
|
|
});
|