Skip to content

Commit

Permalink
test: arrow test
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtechVidra committed Jan 11, 2024
1 parent 0b68bb8 commit d207624
Show file tree
Hide file tree
Showing 45 changed files with 145 additions and 48 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tsup.config.ts
playwright.config.ts
vite.config.js
dist
examples
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"test": "jest",
"test:watch": "jest --watch",
"tsc": "tsc -p tsconfig.lib.json",
"playwright": "playwright test"
"playwright": "playwright test",
"serve:test": "vite"
},
"dependencies": {
"@floating-ui/dom": "^1.5.3",
Expand All @@ -52,7 +53,8 @@
"prettier": "^3.1.0",
"ts-jest": "^29.1.1",
"tsup": "^8.0.1",
"typescript": "^5.3.2"
"typescript": "^5.3.2",
"vite": "^5.0.11"
},
"packageManager": "pnpm@8.7.5"
}
42 changes: 14 additions & 28 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import { defineConfig, devices } from '@playwright/test';
import { defineConfig, devices } from "@playwright/test";

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
testDir: "./tests",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
Expand All @@ -20,31 +11,33 @@ export default defineConfig({
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
baseURL: "http://localhost:3000",

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
trace: "on-first-retry",
},
webServer: {
command: "npm run serve:test",
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
name: "webkit",
use: { ...devices["Desktop Safari"] },
},

/* Test against mobile viewports. */
Expand All @@ -67,11 +60,4 @@ export default defineConfig({
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
59 changes: 59 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions tests/arrow/arrow.html
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" />
<title>Arrow</title>
<link rel="stylesheet" href="/public/flows.css" />
</head>
<body style="margin: 0">
<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="./arrow.ts"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions tests/arrow/arrow.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { test, expect } from "@playwright/test";

const placements = [
"top",
"right",
"bottom",
"left",
"top-start",
"top-end",
"right-start",
"right-end",
"bottom-start",
"bottom-end",
"left-start",
"left-end",
];

placements.forEach((placement) => {
test(placement, async ({ page }) => {
await page.goto(`/arrow/arrow.html?placement=${placement}`);

expect(await page.screenshot({ scale: "css" })).toMatchSnapshot(`arrow-${placement}.png`);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions tests/arrow/arrow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { init } from "../../dist";

void init({
flows: [
{
id: "flow",
location: "/",
steps: [
{
title: "Hello",
element: ".target",
placement: new URLSearchParams(window.location.search).get(
"placement",
) as unknown as "top",
},
],
},
],
});
18 changes: 0 additions & 18 deletions tests/example.spec.ts

This file was deleted.

8 changes: 8 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('vite').UserConfig} */
export default {
server: {
port: 3000,
},
root: "./tests",
publicDir: "../",
};

0 comments on commit d207624

Please # to comment.