refactor this code with the DRY principle. output the new full code
import { test, Page, expect } from "@playwright/test";
import { startTestCase, TIMEOUT } from "./helpers/setup";
import { mockLaunchDarkly } from "./api-mocks/mockLaunchDarkly";

test("Results page - should display plan results", async ({ page }) => {
  await mockLaunchDarkly(page);
  test.setTimeout(TIMEOUT);

  await test.step("move through steps list", async () => {
    // Multi-member household
    await startTestCase(page, {
      name: "100927424",
      params: { planYear: "2016" },
    });

    // Start from step list
    await expect(
      page.getByRole("heading", {
        name: "You’re eligible to enroll in Marketplace coverage",
      })
    ).toBeVisible();
    await page.getByRole("link", { name: "Start" }).click();
    // Skip tobacco use
    await page.getByLabel("None").click();
    await page.getByRole("button", { name: "Save & continue" }).click();
    // Skip ETYC
    await page.getByRole("button", { name: "Skip" }).click();
    // Skip Coverables
    await page.getByRole("button", { name: "Skip" }).click();
  });

  await test.step("view plan results", async () => {
    //View plans for household
    await expect(
      page.getByRole("heading", {
        name: "Health plan groups for your household",
      })
    ).toBeVisible();
    await page.getByRole("link", { name: "View plans" }).click();

    // Close Joyride Modal
    await expect(
      page.getByRole("heading", {
        name: "Help comparing plans",
      })
    ).toBeVisible();
    await page.getByRole("button", { name: "Close" }).click();

    // Await plan results load
    await expect(page.getByText(/plans \(no filters added\)/i)).toBeVisible();
    await expect(page).toHaveScreenshot("plan-results.png", { fullPage: true });
  });
});

test("Results page - should display plan unavailable message", async ({
  page,
}) => {
  await mockLaunchDarkly(page);
  test.setTimeout(TIMEOUT);

  await startTestCase(page, {
    name: "140512322_sepv_example_reenroll",
    params: { planYear: "2017", oe: "true" },
  });

  // Start from step list
  await expect(
    page.getByRole("heading", {
      name: "Renew or change your 2017 coverage",
    })
  ).toBeVisible();
  await page.getByRole("link", { name: "Start" }).click();
  // Skip APTC
  await page.getByLabel("NONE").click();
  await page.getByRole("button", { name: "Save & continue" }).click();
  // Skip tobacco use
  await page.getByLabel("No").click();
  await page.getByRole("button", { name: "Save & continue" }).click();
  // Skip ETYC
  await page.getByRole("button", { name: "Skip" }).click();
  // Skip Coverables
  await page.getByRole("button", { name: "Skip" }).click();

  // Close Joyride Modal
  await expect(
    page.getByRole("heading", {
      name: "Help comparing plans",
    })
  ).toBeVisible();
  await page.getByRole("button", { name: "Close" }).click();

  // Await plan results with ineligible plan alert
  await expect(
    page.getByText("Your 2016 plan isn’t available in 2017")
  ).toBeVisible();
  await expect(page).toHaveScreenshot("plan-unavailable.png", { fullPage: true });
});

test("Results page - should display ineligible plan message", async ({
  page,
}) => {
  await mockLaunchDarkly(page);
  test.setTimeout(TIMEOUT);

  await startTestCase(page, {
    name: "1459985_ineligible_current_plan",
    params: { planYear: "2016" },
  });

  // Start from step list
  await expect(
    page.getByRole("heading", {
      name: "You’re eligible to enroll in Marketplace coverage",
    })
  ).toBeVisible();
  await page.getByRole("link", { name: "Start" }).click();
  // Skip APTC
  await page.getByLabel("NONE").click();
  await page.getByRole("button", { name: "Save & continue" }).click();
  // Skip tobacco use
  await page.getByLabel("None").click();
  await page.getByRole("button", { name: "Save & continue" }).click();
  // Skip ETYC
  await page.getByRole("button", { name: "Skip" }).click();
  // Skip Coverables
  await page.getByRole("button", { name: "Skip" }).click();

  //View plans for household
  await expect(
    page.getByRole("heading", {
      name: "Health plan groups for your household",
    })
  ).toBeVisible();
  await page.getByRole("link", { name: "View plans" }).click();
  // Close Joyride Modal
  await expect(
    page.getByRole("heading", {
      name: "Help comparing plans",
    })
  ).toBeVisible();
  await page.getByRole("button", { name: "Close" }).click();

  // Await plan results with ineligible plan alert
  await expect(
    page.getByText(
      "Because your circumstances have changed, you're no longer eligible for your current plan"
    )
  ).toBeVisible();
  await expect(page).toHaveScreenshot("ineligible-plan.png", { fullPage: true });
});

test("Results page - should display crosswalk message", async ({
  page,
}) => {
  await mockLaunchDarkly(page);
  test.setTimeout(TIMEOUT);
  await startTestCase(page, {
    name: "crosswalk_b2b_currentPolicyNotAvailable",
    params: { planYear: "2023", oe: "true" },
  });
  await page.waitForSelector("#snowfall-body");
  // Start from step list
  await expect(
    page.getByRole("heading", {
      name: "You’re eligible to enroll in Marketplace coverage",
    })
  ).toBeVisible();
  await page.getByRole("link", { name: "Start" }).click();
  // Skip APTC
  await page.getByLabel("NONE").click();
  await page.getByRole("button", { name: "Save & continue" }).click();
  // Skip tobacco use
  await page.getByLabel("No").click();
  await page.getByRole("button", { name: "Save & continue" }).click();
  // Skip ETYC
  await page.getByRole("button", { name: "Skip" }).click();
  // Skip Coverables
  await page.getByRole("button", { name: "Skip" }).click();

  // Close Joyride Modal
  await expect(
    page.getByRole("heading", {
      name: "Help comparing plans",
    })
  ).toBeVisible();
  await page.getByRole("button", { name: "Close" }).click();

  // Await plan results with crosswalk 'Current or Alternate Plan'
  await expect(
    page.getByRole("heading", {
      name: "Current or Alternate Plan",
    })
  ).toBeVisible();
  await expect(page).toHaveScreenshot("crosswalk-plan.png", { fullPage: true });

});


test("Results page - should display current plan", async ({ page }) => {
  await mockLaunchDarkly(page);
  test.setTimeout(TIMEOUT);

  await startTestCase(page, {
    name: "1459985_current_plan",
    params: { planYear: "2016" },
  });
  await page.waitForSelector("#snowfall-body");
  // Start from step list
  await expect(
    page.getByRole("heading", {
      name: "You’re eligible to enroll in Marketplace coverage",
    })
  ).toBeVisible();
  await page.getByRole("link", { name: "Start" }).click();
  // Skip APTC
  await page.getByLabel("NONE").click();
  await page.getByRole("button", { name: "Save & continue" }).click();
  // Skip tobacco use
  await page.getByLabel("None").click();
  await page.getByRole("button", { name: "Save & continue" }).click();
  // Skip ETYC
  await page.getByRole("button", { name: "Skip" }).click();
  // Skip Coverables
  await page.getByRole("button", { name: "Skip" }).click();

  //View plans for household
  await expect(
    page.getByRole("heading", {
      name: "Health plan groups for your household",
    })
  ).toBeVisible();
  await page.getByRole("link", { name: "View plans" }).click();
  // Close Joyride Modal
  await expect(
    page.getByRole("heading", {
      name: "Help comparing plans",
    })
  ).toBeVisible();
  await page.getByRole("button", { name: "Close" }).click();

  // Await plan results with 'current plan' heading
  await expect(
    page.getByRole("heading", {
      name: "Plan you picked before (ends 12/31/2016)",
    })
  ).toBeVisible();
  await expect(page).toHaveScreenshot("current-plan.png", { fullPage: true });
});

//TODO find working payload
test.skip("Results page - should display closed current plan", async ({ page }) => {
  await mockLaunchDarkly(page);
  test.setTimeout(TIMEOUT);

  await startTestCase(page, {
    name: "4390543520_closed_current_plan",
    params: { planYear: "2024" },
  });

  // Start from step list
  await expect(
    page.getByRole("heading", {
      name: "You’re eligible to enroll in Marketplace coverage",
    })
  ).toBeVisible();
  await page.getByRole("link", { name: "Start" }).click();
  // Skip tobacco use
  await page.getByLabel("No").click();
  await page.getByRole("button", { name: "Save & continue" }).click();
  // Skip ETYC
  await page.getByRole("button", { name: "Skip" }).click();
  // Skip Coverables
  await page.getByRole("button", { name: "Skip" }).click();

  // Close Joyride Modal
  await expect(
    page.getByRole("heading", {
      name: "Help comparing plans",
    })
  ).toBeVisible();
  await page.getByRole("button", { name: "Close" }).click();

  // Await plan results with current plan text
  await expect(
    page.getByText(
      "Plan you picked before (ends 03/31/2024)"
    )
  ).toBeVisible();

  // Verify screenshot with no 'Enroll' button for closed current plan
  await expect(page).toHaveScreenshot("closed-current-plan.png", {
    fullPage: true,
  });
});