@manufac/general-tests 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -10
- package/dist/config/projects.d.ts +20 -2
- package/dist/config/projects.js +14 -13
- package/dist/specs/utils.js +2 -2
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -24,18 +24,38 @@ Then wire it into the app's `playwright.config.ts` using the project-builder hel
|
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
26
|
import { defineConfig } from "@playwright/test";
|
|
27
|
-
import {
|
|
27
|
+
import { Breakpoints, createProject } from "@manufac/general-tests/config/projects.js";
|
|
28
28
|
|
|
29
29
|
export default defineConfig({
|
|
30
30
|
use: {
|
|
31
31
|
baseURL: "http://localhost:8080",
|
|
32
32
|
},
|
|
33
33
|
projects: [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
createProject({
|
|
35
|
+
name: "Desktop Chrome",
|
|
36
|
+
device: "Desktop Chrome",
|
|
37
|
+
configuration: { projectType: "desktop", breakpoint: Breakpoints.Desktop },
|
|
38
|
+
}),
|
|
39
|
+
createProject({
|
|
40
|
+
name: "Desktop Safari",
|
|
41
|
+
device: "Desktop Safari",
|
|
42
|
+
configuration: { projectType: "desktop", breakpoint: Breakpoints.Desktop },
|
|
43
|
+
}),
|
|
44
|
+
createProject({
|
|
45
|
+
name: "Desktop Firefox",
|
|
46
|
+
device: "Desktop Firefox",
|
|
47
|
+
configuration: { projectType: "desktop", breakpoint: Breakpoints.Desktop },
|
|
48
|
+
}),
|
|
49
|
+
createProject({
|
|
50
|
+
name: "Mobile Safari",
|
|
51
|
+
device: "iPhone 12",
|
|
52
|
+
configuration: { projectType: "mobile", breakpoint: Breakpoints.MobileM },
|
|
53
|
+
}),
|
|
54
|
+
createProject({
|
|
55
|
+
name: "Mobile Chrome",
|
|
56
|
+
device: "Pixel 5",
|
|
57
|
+
configuration: { projectType: "mobile", breakpoint: Breakpoints.MobileM },
|
|
58
|
+
}),
|
|
39
59
|
],
|
|
40
60
|
webServer: {
|
|
41
61
|
command: "npm run start",
|
|
@@ -45,14 +65,18 @@ export default defineConfig({
|
|
|
45
65
|
});
|
|
46
66
|
```
|
|
47
67
|
|
|
48
|
-
- `
|
|
49
|
-
- `
|
|
50
|
-
-
|
|
68
|
+
- `createProject({ name, device, configuration })` builds a Playwright project for the given device.
|
|
69
|
+
- `configuration.projectType: "desktop"` runs the `shared` + `desktop-only` specs, and requires `configuration.breakpoint: Breakpoints.Desktop` (1440x900).
|
|
70
|
+
- `configuration.projectType: "mobile"` runs the `shared` + `mobile-only` specs, and requires `configuration.breakpoint: Breakpoints.MobileM` (390x844).
|
|
51
71
|
|
|
52
72
|
By default every spec runs against `/`. To point a project at a different page, override the `targetPage` fixture option:
|
|
53
73
|
|
|
54
74
|
```ts
|
|
55
|
-
|
|
75
|
+
createProject({
|
|
76
|
+
name: "Desktop Chrome — pricing",
|
|
77
|
+
device: "Desktop Chrome",
|
|
78
|
+
configuration: { projectType: "desktop", breakpoint: Breakpoints.Desktop },
|
|
79
|
+
}),
|
|
56
80
|
// then, in that project's `use`:
|
|
57
81
|
use: { targetPage: "/pricing" }
|
|
58
82
|
```
|
|
@@ -37,5 +37,23 @@ export declare const Breakpoints: {
|
|
|
37
37
|
readonly height: 1080;
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
declare const ProjectTypes: {
|
|
41
|
+
readonly Mobile: "mobile";
|
|
42
|
+
readonly Desktop: "desktop";
|
|
43
|
+
};
|
|
44
|
+
export type ProjectType = (typeof ProjectTypes)[keyof typeof ProjectTypes];
|
|
45
|
+
export interface MobileConfig {
|
|
46
|
+
projectType: typeof ProjectTypes.Mobile;
|
|
47
|
+
breakpoint: typeof Breakpoints.MobileM;
|
|
48
|
+
}
|
|
49
|
+
export interface DesktopConfig {
|
|
50
|
+
projectType: typeof ProjectTypes.Desktop;
|
|
51
|
+
breakpoint: typeof Breakpoints.Desktop;
|
|
52
|
+
}
|
|
53
|
+
export interface CreateProjectParams {
|
|
54
|
+
name: string;
|
|
55
|
+
device: keyof typeof devices;
|
|
56
|
+
configuration: MobileConfig | DesktopConfig;
|
|
57
|
+
}
|
|
58
|
+
export declare function createProject({ configuration, device, name }: CreateProjectParams): Project;
|
|
59
|
+
export {};
|
package/dist/config/projects.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Breakpoints = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.createMobileProject = createMobileProject;
|
|
4
|
+
exports.createProject = createProject;
|
|
6
5
|
const test_1 = require("@playwright/test");
|
|
7
6
|
const node_path_1 = require("node:path");
|
|
8
7
|
// Section 3 of the Landing Page Test Plan — breakpoints / viewports.
|
|
@@ -19,19 +18,21 @@ const SpecsDirectory = (0, node_path_1.join)(__dirname, "..", "specs");
|
|
|
19
18
|
const SharedTestMatch = "shared/**/*.spec.js";
|
|
20
19
|
const DesktopOnlyTestMatch = "desktop-only/**/*.spec.js";
|
|
21
20
|
const MobileOnlyTestMatch = "mobile-only/**/*.spec.js";
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
use: { ...test_1.devices[device], viewport: { width: breakpoint.width, height: breakpoint.height } },
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function createMobileProject(name, device, breakpoint = exports.Breakpoints.MobileM) {
|
|
21
|
+
const ProjectTypes = {
|
|
22
|
+
Mobile: "mobile",
|
|
23
|
+
Desktop: "desktop",
|
|
24
|
+
};
|
|
25
|
+
function createProject({ configuration, device, name }) {
|
|
31
26
|
return {
|
|
32
27
|
name,
|
|
33
28
|
testDir: SpecsDirectory,
|
|
34
|
-
testMatch: [
|
|
35
|
-
|
|
29
|
+
testMatch: [
|
|
30
|
+
SharedTestMatch,
|
|
31
|
+
configuration.projectType === ProjectTypes.Desktop ? DesktopOnlyTestMatch : MobileOnlyTestMatch,
|
|
32
|
+
],
|
|
33
|
+
use: {
|
|
34
|
+
...test_1.devices[device],
|
|
35
|
+
viewport: { width: configuration.breakpoint.width, height: configuration.breakpoint.height },
|
|
36
|
+
},
|
|
36
37
|
};
|
|
37
38
|
}
|
package/dist/specs/utils.js
CHANGED
|
@@ -295,7 +295,7 @@ function isCutoffAtViewportEdge(snapshot, viewport) {
|
|
|
295
295
|
rect.bottom > viewport.height + exports.ResponsiveConfig.CutoffTolerancePX);
|
|
296
296
|
return hasDimensions && (isHorizontallyClipped || isVerticallyClipped);
|
|
297
297
|
}
|
|
298
|
-
async function findElementsCutoffAtViewportEdge(page, containerSelector
|
|
298
|
+
async function findElementsCutoffAtViewportEdge(page, containerSelector) {
|
|
299
299
|
const { elements, viewport } = await page.evaluate((selector) => {
|
|
300
300
|
function isRenderedElement(element) {
|
|
301
301
|
const style = window.getComputedStyle(element);
|
|
@@ -328,7 +328,7 @@ async function findElementsCutoffAtViewportEdge(page, containerSelector = "body
|
|
|
328
328
|
}
|
|
329
329
|
return isClipped;
|
|
330
330
|
}
|
|
331
|
-
const renderedElements = Array.from(document.querySelectorAll(selector))
|
|
331
|
+
const renderedElements = Array.from(document.querySelectorAll(selector ?? "body *"))
|
|
332
332
|
.filter(isRenderedElement)
|
|
333
333
|
.filter((element) => {
|
|
334
334
|
return !isClippedByAncestorOverflow(element);
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manufac/general-tests",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "A library for general tests for landing pages",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/manufac-analytics/sculptor.git",
|
|
8
|
+
"directory": "packages/tests"
|
|
9
|
+
},
|
|
5
10
|
"license": "UNLICENSED",
|
|
6
11
|
"exports": {
|
|
7
12
|
"./*": "./dist/*"
|
|
@@ -26,5 +31,8 @@
|
|
|
26
31
|
},
|
|
27
32
|
"peerDependencies": {
|
|
28
33
|
"@playwright/test": "^1.62.0"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
29
37
|
}
|
|
30
38
|
}
|