-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7016f65
commit fac5d97
Showing
11 changed files
with
276 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
/* eslint-disable no-console -- We are defining user facing console logs */ | ||
|
||
const badge = "%cFlows%c"; | ||
const badgeCss = "color:#fff;background:#ec6441;padding:2px 4px;border-radius:4px"; | ||
|
||
export const log = { | ||
error: (message: string, ...args: unknown[]): void => { | ||
// eslint-disable-next-line no-console -- ignore | ||
console.error( | ||
`%cFlows%c ${message}`, | ||
"color:#fff;background:#ec6441;padding:2px 4px;border-radius:4px", | ||
"", | ||
...args, | ||
); | ||
console.error(`${badge} ${message}`, badgeCss, "", ...args); | ||
}, | ||
warn: (message: string, ...args: unknown[]): void => { | ||
console.warn(`${badge} ${message}`, badgeCss, "", ...args); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!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="display: grid; place-items: center; height: 100vh"> | ||
<div style="background-color: grey; width: 20px; height: 20px" class="target"></div> | ||
</div> | ||
|
||
<script type="module" src="./buttons.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import { expect, test } from "@playwright/test"; | ||
|
||
test("Close is visible", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html"); | ||
await expect(page.locator(".flows-tooltip")).toBeVisible(); | ||
await expect(page.locator(".flows-cancel")).toBeVisible(); | ||
}); | ||
test("Hides close", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html?hideClose=true"); | ||
await expect(page.locator(".flows-tooltip")).toBeVisible(); | ||
await expect(page.locator(".flows-cancel")).not.toBeVisible(); | ||
}); | ||
|
||
test("Next is visible", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html"); | ||
await expect(page.locator(".flows-continue")).toBeVisible(); | ||
await page.locator(".flows-continue").click(); | ||
await expect(page.locator(".flows-continue")).not.toBeVisible(); | ||
await expect(page.locator(".flows-finish")).toBeVisible(); | ||
}); | ||
test("Hides next", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html?hideNext=true"); | ||
await expect(page.locator(".flows-continue")).not.toBeVisible(); | ||
}); | ||
|
||
test("Prev is visible", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html"); | ||
await expect(page.locator(".flows-back")).not.toBeVisible(); | ||
await page.locator(".flows-continue").click(); | ||
await expect(page.locator(".flows-back")).toBeVisible(); | ||
}); | ||
test("Hides prev", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html?hidePrev=true"); | ||
await expect(page.locator(".flows-back")).not.toBeVisible(); | ||
await page.locator(".flows-continue").click(); | ||
await expect(page.locator(".flows-back")).not.toBeVisible(); | ||
}); | ||
|
||
test("Default next text", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html"); | ||
await expect(page.locator(".flows-continue")).toHaveText("Continue"); | ||
await page.locator(".flows-continue").click(); | ||
await expect(page.locator(".flows-finish")).toHaveText("Finish"); | ||
}); | ||
test("Custom next text", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html?nextText=Next"); | ||
await expect(page.locator(".flows-continue")).toHaveText("Next"); | ||
await page.locator(".flows-continue").click(); | ||
await expect(page.locator(".flows-finish")).toHaveText("Next"); | ||
}); | ||
|
||
test("Default prev text", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html"); | ||
await page.locator(".flows-continue").click(); | ||
await expect(page.locator(".flows-back")).toHaveText("Back"); | ||
}); | ||
test("Custom prev text", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html?prevText=Previous"); | ||
await page.locator(".flows-continue").click(); | ||
await expect(page.locator(".flows-back")).toHaveText("Previous"); | ||
}); | ||
|
||
test("Custom link", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html?customLink=true&hideNext=true"); | ||
await expect(page.locator(".flows-option")).toHaveCount(3); | ||
const firstLink = page.locator(".flows-option").first(); | ||
await expect(firstLink).toBeVisible(); | ||
await expect(firstLink).toHaveText("Google"); | ||
await expect(firstLink).toHaveAttribute("href", "https://google.com"); | ||
await expect(firstLink).not.toHaveAttribute("target", "_blank"); | ||
}); | ||
test("Custom external link", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html?customExternalLink=true&hideNext=true"); | ||
await expect(page.locator(".flows-option")).toHaveCount(3); | ||
const firstLink = page.locator(".flows-option").first(); | ||
await expect(firstLink).toBeVisible(); | ||
await expect(firstLink).toHaveText("Google"); | ||
await expect(firstLink).toHaveAttribute("href", "https://google.com"); | ||
await expect(firstLink).toHaveAttribute("target", "_blank"); | ||
}); | ||
test("Custom action", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html?customAction=true&hideNext=true"); | ||
await expect(page.locator(".flows-option")).toHaveCount(3); | ||
const firstLink = page.locator(".flows-option").first(); | ||
await expect(firstLink).toBeVisible(); | ||
await expect(firstLink).toHaveText("Action"); | ||
await expect(firstLink).toHaveAttribute("data-action", "0"); | ||
await expect(firstLink).not.toHaveAttribute("href"); | ||
await expect(firstLink).not.toHaveAttribute("target"); | ||
}); | ||
test("Custom next", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html?customNext=true&hideNext=true"); | ||
await expect(page.locator(".flows-continue")).toHaveCount(3); | ||
const firstLink = page.locator(".flows-continue").first(); | ||
await expect(firstLink).toBeVisible(); | ||
await expect(firstLink).toHaveText("My Next"); | ||
await expect(firstLink).not.toHaveAttribute("href"); | ||
await expect(firstLink).not.toHaveAttribute("target"); | ||
}); | ||
// TODO: discuss if prev button should be visible when there is no previous step | ||
test("Custom prev", async ({ page }) => { | ||
await page.goto("/buttons/buttons.html?customPrev=true&hideNext=true"); | ||
await expect(page.locator(".flows-back")).toHaveCount(3); | ||
const firstLink = page.locator(".flows-back").first(); | ||
await expect(firstLink).toBeVisible(); | ||
await expect(firstLink).toHaveText("My Prev"); | ||
await expect(firstLink).not.toHaveAttribute("href"); | ||
await expect(firstLink).not.toHaveAttribute("target"); | ||
}); |
Oops, something went wrong.