import { describe, expect, it } from 'vitest';

import listSource from './SkillList.vue?raw';

describe('skill list contract', () => {
  it('uses the shared list layout with classification, fuzzy search, and compact filters', () => {
    expect(listSource).toContain('<PageSide');
    expect(listSource).toContain('<HeaderSearch');
    expect(listSource).toContain('搜索技能名称、用途或创建人');
    expect(listSource).toContain('placeholder="范围：全部"');
    expect(listSource).toContain('placeholder="状态：全部"');
    expect(listSource).toContain('placeholder="分类：全部"');
    expect(listSource).toContain('skill-list-page__mobile-category');
    expect(listSource).toContain("text: '批量导入'");
    expect(listSource).toContain("text: '新建技能'");
  });

  it('shows only the agreed business columns and omits status and technical source data', () => {
    for (const label of ['技能', '用途', '创建人', '范围', '操作']) {
      expect(listSource).toContain(`label="${label}"`);
    }
    expect(listSource).not.toContain('label="状态"');
    expect(listSource).not.toContain('label="来源"');
    expect(listSource).not.toContain('label="能力"');
    expect(listSource).not.toContain('<h1>技能库</h1>');
  });

  it('supports publishing, republishing, and taking published skills off shelf from the list', () => {
    expect(listSource).toContain('canPublishRow(row)');
    expect(listSource).toContain("? '重新发布'");
    expect(listSource).toContain(':type="rowPublishButtonType(row)"');
    expect(listSource).toContain("? 'warning'");
    expect(listSource).toContain(": 'success'");
    expect(listSource).toContain('command="offline"');
    expect(listSource).toContain('skill-list-page__danger-action');
    expect(listSource).toContain('color: hsl(var(--destructive))');
    expect(listSource).toContain('validateSkillForPublish(row.id)');
    expect(listSource).toContain(
      'submitSkillPublishApproval(target.id, reason)',
    );
  });
});
