import { provideHttpClient } from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { provideRouter } from '@angular/router';
import { AUTH_BFF_BASE_URL, AUTH_CSRF_COOKIE_NAME, AUTH_NAVIGATOR } from 'feature-auth';
import { App } from './app';

describe('App', () => {
  beforeEach(async () => {
    await TestBed.configureTestingModule({
      imports: [App],
      providers: [
        provideRouter([]),
        provideHttpClient(),
        provideHttpClientTesting(),
        { provide: AUTH_BFF_BASE_URL, useValue: 'http://bff.test/api' },
        { provide: AUTH_CSRF_COOKIE_NAME, useValue: 'portal_csrf' },
        { provide: AUTH_NAVIGATOR, useValue: vi.fn() },
      ],
    }).compileComponents();
  });

  it('renders the admin shell — skip link, header, sidebar, main landmark, footer', async () => {
    const fixture = TestBed.createComponent(App);
    await fixture.whenStable();
    const root = fixture.nativeElement as HTMLElement;
    expect(root.querySelector('a.skip-link')).not.toBeNull();
    expect(root.querySelector('main#main-content')).not.toBeNull();
    expect(root.querySelector('app-admin-header')).not.toBeNull();
    expect(root.querySelector('app-admin-sidebar')).not.toBeNull();
    expect(root.querySelector('app-admin-footer')).not.toBeNull();
  });
});
