Skip to content

Free & Open-Source Invoice Generator - No Sign-Up, No Ads, Instant PDF Export, 100% In-Browser, and Fully Customizable Templates.

3.9 KB
Raw Blame
import { expect, test } from "@playwright/test";

import {
  DISCORD_COMMUNITY_URL,
  REDDIT_COMMUNITY_URL,
  VIDEO_DEMO_YOUTUBE_URL,
  YOUTUBE_VIDEO_HOW_TO_ADD_BUYER,
  YOUTUBE_VIDEO_HOW_TO_ADD_SELLER,
} from "@/config";

import { expectYouTubeEmbedToShow } from "./utils/youtube-embed";

test.describe("How it works page", () => {
  test("should display page content and video tutorials", async ({ page }) => {
    await page.goto("/how-it-works");

    await expect(page).toHaveURL("/how-it-works");

    const header = page.locator("header");
    await expect(header).toBeVisible();

    const goToAppButton = header.getByRole("link", {
      name: "Open app",
      exact: true,
    });

    await expect(goToAppButton).toBeVisible();
    await expect(goToAppButton).toHaveAttribute("href", "/");

    await expect(page.getByTestId("how-it-works-page-title")).toBeVisible();
    await expect(
      page.getByRole("heading", {
        level: 1,
        name: "How EasyInvoicePDF Works",
        exact: true,
      }),
    ).toBeVisible();

    await expect(
      page.getByText(
        "Learn how to create, customize, download, and share professional PDF invoices online with EasyInvoicePDF. These step-by-step videos show you how to use our free invoice generator, save seller and buyer details, add branding, set up VAT or your own tax label, and prepare weekly invoices. Whether you need an invoice maker for a one-off bill or a small business invoice template you can reuse, you can start in seconds.",
      ),
    ).toBeVisible();

    const embed = page.getByTestId("how-it-works-video");

    await expect(embed).toBeVisible();
    await expectYouTubeEmbedToShow({ embed, embedUrl: VIDEO_DEMO_YOUTUBE_URL });
    await expect(embed).toHaveAttribute("title", "EasyInvoicePDF Demo Video");

    const sellerItem = page.getByTestId(
      "how-it-works-playlist-item-add-seller",
    );

    await sellerItem.click();
    await expectYouTubeEmbedToShow({
      embed,
      embedUrl: YOUTUBE_VIDEO_HOW_TO_ADD_SELLER,
    });

    await expect(sellerItem).toBeVisible();
    await expect(sellerItem).toHaveAttribute("aria-current", "true");
    await expect(
      page.getByTestId("how-it-works-playlist-item-overview"),
    ).not.toHaveAttribute("aria-current");

    const discordLink = page.getByTestId("how-it-works-discord");
    const redditLink = page.getByTestId("how-it-works-reddit");

    await expect(discordLink).toBeVisible();
    await expect(discordLink).toHaveAttribute("href", DISCORD_COMMUNITY_URL);
    await expect(redditLink).toBeVisible();
    await expect(redditLink).toHaveAttribute("href", REDDIT_COMMUNITY_URL);

    await expect(page.getByTestId("how-it-works-tutorial-index")).toBeVisible();
    await expect(
      page.getByRole("heading", { level: 2, name: "All tutorials" }),
    ).toBeVisible();

    const buttonCta = page.getByRole("link", {
      name: "Start Invoicing",
      exact: true,
    });
    await expect(buttonCta).toBeVisible();
    await expect(buttonCta).toHaveAttribute("href", "/");

    const footer = page.locator("footer");
    await expect(footer).toBeVisible();

    const howItWorksFooterLink = footer.getByRole("link", {
      name: "How it works",
      exact: true,
    });
    await expect(howItWorksFooterLink).toBeVisible();
    await expect(howItWorksFooterLink).toHaveAttribute("href", "/how-it-works");
  });

  test("should support video deep link via query param", async ({ page }) => {
    await page.goto("/how-it-works?video=add-buyer");

    await expect(page).toHaveURL("/how-it-works?video=add-buyer");

    const embed = page.getByTestId("how-it-works-video");

    await expectYouTubeEmbedToShow({
      embed,
      embedUrl: YOUTUBE_VIDEO_HOW_TO_ADD_BUYER,
    });

    const buyerItem = page.getByTestId("how-it-works-playlist-item-add-buyer");
    await expect(buyerItem).toBeVisible();

    await expect(buyerItem).toHaveAttribute("aria-current", "true");
  });
});