Skip to content

Commit

Permalink
test: html content
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtechVidra committed Jan 18, 2024
1 parent 7eeac9c commit 9eadc2e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/html-content/html-content.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/tests/reset.css" />
<link rel="stylesheet" href="/public/flows.css" />
</head>
<body>
<div
style="background-color: grey; width: 20px; height: 20px; margin: 40px"
class="target"
></div>

<script type="module" src="./html-content.ts"></script>
</body>
</html>
13 changes: 13 additions & 0 deletions tests/html-content/html-content.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expect, test } from "@playwright/test";

test("HTML content in tooltip", async ({ page }) => {
await page.goto("/html-content/html-content.html?tooltip=true");
await expect(page.locator(".flows-tooltip .span-in-title")).toHaveText("span in title");
await expect(page.locator(".flows-tooltip .span-in-body")).toHaveText("span in body");
});

test("HTML content in modal", async ({ page }) => {
await page.goto("/html-content/html-content.html");
await expect(page.locator(".flows-modal .span-in-title")).toHaveText("span in title");
await expect(page.locator(".flows-modal .span-in-body")).toHaveText("span in body");
});
20 changes: 20 additions & 0 deletions tests/html-content/html-content.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { FlowStep, FlowTooltipStep } from "../../dist";
import { init } from "../../dist";

const tooltip = new URLSearchParams(window.location.search).get("tooltip") === "true";

const step: FlowStep = {
title: '<span class="span-in-title">span in title</span>',
body: '<span class="span-in-body">span in body</span>',
};
if (tooltip) (step as FlowTooltipStep).element = ".target";

void init({
flows: [
{
id: "flow",
location: "/",
steps: [step],
},
],
});

0 comments on commit 9eadc2e

Please sign in to comment.