import { stagingUsers } from '@fixtures/staging-users';
import { AdminDashboardPage } from '@admin-lib/admin_avi/admin_dashboard_section';
import { ReportsBookings } from '@commerce-lib/reports/reports_bookings';
import { ApprovalBookingsPage } from '@admin-lib/approvals/bookings';
import { GroupTravelSettings } from '@admin-lib/settings/overview/group-travel_settings';
import { GuestInvitePage } from '@admin-lib/guest_invites/guest_invites';

const authUserPassword = Cypress.env('newUser').NEW_USER_PASSWORD;
const { adminUser } = stagingUsers.admin;
const PAGE_LOAD_TIMEOUT = 10000;

/**
 * Test suite for local smoke testing of ta-admin-mod pages.
 *
 * Usage:
 *    1. Create reference screenshots from staging-prime:
 *       npm run open -> select `screenshots.cy.ts` from the list
 *    2. Run the test suite:
 *       npm run open:local -> select `screenshots.cy.ts` from the list
 *    3. Most likely tests will fail. That's expected since the threshold (allowed difference in pixels) is set to 0.
 *       Go to `cypress/snapshots/diff` to manually check the differences and assess whether they are acceptable.
 *
 * WARNING: This test suite is not meant to be run in CI.
 */
describe('Admin: visual regression tests', () => {
  beforeEach(() => {
    cy.loginWithAuthToken({
      email: adminUser.email,
      password: authUserPassword,
      isSA: true
    });
  });

  it('C00000: verify dashboard', { tags: ['screenshots'] }, () => {
    AdminDashboardPage.visitAdminDashboardPage();
    cy.wait(PAGE_LOAD_TIMEOUT);
    cy.compareSnapshot('admin_dashboard');
  });

  it('C00000: verify reports', { tags: ['screenshots'] }, () => {
    ReportsBookings.visitReportsBookingsPage();
    cy.wait(PAGE_LOAD_TIMEOUT);
    cy.compareSnapshot('admin_reports');
  });

  it('C00000: verify approval bookings', { tags: ['screenshots'] }, () => {
    ApprovalBookingsPage.visitBookingsPage();
    cy.wait(PAGE_LOAD_TIMEOUT);
    cy.compareSnapshot('admin_approval');
  });

  it('C00000: verify settings', { tags: ['screenshots'] }, () => {
    GroupTravelSettings.visitOverviewPage();
    cy.wait(PAGE_LOAD_TIMEOUT);
    cy.compareSnapshot('admin_settings');
  });

  it('C00000: verify guest invites', { tags: ['screenshots'] }, () => {
    GuestInvitePage.visitGuestInvitePage();
    cy.wait(PAGE_LOAD_TIMEOUT);
    cy.compareSnapshot('admin_guest_invites');
  });
});
