import { describe, expect, it } from 'vitest';
import { resolveRoleApprovedTourSteps, resolveWelcomeTourSteps } from './guided-tour-content';

describe('resolveWelcomeTourSteps', () => {
  it('uses runtime-config welcome steps when provided', () => {
    const steps = resolveWelcomeTourSteps({
      welcome: [
        { title: 'A', body: 'B' },
        { title: 'C', body: 'D' },
      ],
    });
    expect(steps).toHaveLength(2);
    expect(steps[0].title).toBe('A');
  });

  it('falls back to default steps when runtime data is missing', () => {
    const steps = resolveWelcomeTourSteps();
    expect(steps.length).toBeGreaterThan(0);
  });
});

describe('resolveRoleApprovedTourSteps', () => {
  it('returns role-specific defaults for primary roles', () => {
    expect(resolveRoleApprovedTourSteps('COMPANY').length).toBeGreaterThan(0);
    expect(resolveRoleApprovedTourSteps('CUSTOMER').length).toBeGreaterThan(0);
    expect(resolveRoleApprovedTourSteps('JOB_SEEKER').length).toBeGreaterThan(0);
  });

  it('returns professional defaults for non-primary roles', () => {
    const steps = resolveRoleApprovedTourSteps('PHOTOGRAPHER');
    expect(steps.length).toBeGreaterThan(0);
    expect(steps[0].title.toLowerCase()).toContain('photographer');
  });

  it('uses runtime role override when present', () => {
    const steps = resolveRoleApprovedTourSteps('TUTOR', {
      roles: {
        TUTOR: [{ title: 'Tutor Custom', body: 'Custom flow' }],
      },
    });
    expect(steps).toEqual([{ title: 'Tutor Custom', body: 'Custom flow' }]);
  });

  it('uses runtime role approved default when specific role override is absent', () => {
    const steps = resolveRoleApprovedTourSteps('MAKEUP_ARTIST', {
      role_approved_default: [{ title: 'Default Custom', body: 'Default flow' }],
    });
    expect(steps).toEqual([{ title: 'Default Custom', body: 'Default flow' }]);
  });
});
