@baseline-ui/test-utils 0.0.0-nightly-20250403000606

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.
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { StylingProps, I18nProviderProps, ThemeProviderProps } from '@baseline-ui/core';
3
+ import { FrameComponentProps } from 'react-frame-component';
4
+
5
+ declare const IFrame: React.ForwardRefExoticComponent<Omit<IFrameProps, "ref"> & React.RefAttributes<HTMLIFrameElement>>;
6
+ interface IFrameProps extends FrameComponentProps, StylingProps {
7
+ }
8
+ declare const ShadowRoot: React.ForwardRefExoticComponent<ShadowRootProps & React.RefAttributes<HTMLDivElement>>;
9
+ interface ShadowRootProps {
10
+ children?: React.ReactNode;
11
+ style?: React.CSSProperties;
12
+ }
13
+
14
+ declare const ProvidersContainer: React.FC<ProvidersContainerProps>;
15
+ interface ProvidersContainerProps extends I18nProviderProps, Pick<ThemeProviderProps, "theme"> {
16
+ disableThemeProvider?: boolean;
17
+ disableFrameProvider?: boolean;
18
+ themeStyle?: React.CSSProperties;
19
+ }
20
+
21
+ /**
22
+ * Vanilla extract appends styles to the head of the main document. This will
23
+ * collect all the styles and append them to the head of the iframe.
24
+ */
25
+ declare function getRootStyles(): string;
26
+
27
+ export { IFrame, type IFrameProps, ProvidersContainer, ShadowRoot, type ShadowRootProps, getRootStyles };
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { StylingProps, I18nProviderProps, ThemeProviderProps } from '@baseline-ui/core';
3
+ import { FrameComponentProps } from 'react-frame-component';
4
+
5
+ declare const IFrame: React.ForwardRefExoticComponent<Omit<IFrameProps, "ref"> & React.RefAttributes<HTMLIFrameElement>>;
6
+ interface IFrameProps extends FrameComponentProps, StylingProps {
7
+ }
8
+ declare const ShadowRoot: React.ForwardRefExoticComponent<ShadowRootProps & React.RefAttributes<HTMLDivElement>>;
9
+ interface ShadowRootProps {
10
+ children?: React.ReactNode;
11
+ style?: React.CSSProperties;
12
+ }
13
+
14
+ declare const ProvidersContainer: React.FC<ProvidersContainerProps>;
15
+ interface ProvidersContainerProps extends I18nProviderProps, Pick<ThemeProviderProps, "theme"> {
16
+ disableThemeProvider?: boolean;
17
+ disableFrameProvider?: boolean;
18
+ themeStyle?: React.CSSProperties;
19
+ }
20
+
21
+ /**
22
+ * Vanilla extract appends styles to the head of the main document. This will
23
+ * collect all the styles and append them to the head of the iframe.
24
+ */
25
+ declare function getRootStyles(): string;
26
+
27
+ export { IFrame, type IFrameProps, ProvidersContainer, ShadowRoot, type ShadowRootProps, getRootStyles };
@@ -0,0 +1,11 @@
1
+ 'use strict';var n=require('react'),R=require('react-frame-component'),S=require('react-dom/client'),core=require('@baseline-ui/core'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var n__default=/*#__PURE__*/_interopDefault(n);var R__default=/*#__PURE__*/_interopDefault(R);var S__default=/*#__PURE__*/_interopDefault(S);/**
2
+ * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
+ *
4
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
5
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.
6
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
7
+ * This notice may not be removed from this file.
8
+ *
9
+ */
10
+ function u(...e){return e.length===1&&e[0]?e[0]:r=>{for(let o of e)typeof o=="function"?o(r):o!=null&&(o.current=r);}}function x(){let e=[],r=document;for(let o=0;o<r.styleSheets.length;o++){let t=r.styleSheets[o];if(t.cssRules){let s=t.cssRules;for(let c of s)e.push(c.cssText);}}return e.join(`
11
+ `)}var E=n__default.default.forwardRef(({head:e=jsxRuntime.jsx("style",{children:x()}),...r},o)=>jsxRuntime.jsx(R__default.default,{style:{width:"100vw",height:"100vh",border:"none"},ref:o,...r,head:e}));E.displayName="IFrame";var g=n__default.default.forwardRef(({children:e,style:r},o)=>{let t=n__default.default.useRef(null),s=n__default.default.useRef(null),c=n__default.default.useMemo(()=>x(),[]);return n.useEffect(()=>{let f=null;if(t.current&&!s.current){let d=t.current.attachShadow({mode:"open"});s.current=d;let $=document.createElement("style");$.textContent=c,d.append($);let i=document.createElement("div");i.className="content-container",d.append(i);let m=document.createElement("div");m.className="overlay-portal",d.append(m),f=S__default.default.createRoot(i),f.render(jsxRuntime.jsx(core.PortalContainerProvider,{portalContainer:m,children:e}));}return ()=>{f&&f.unmount();}},[c,e]),jsxRuntime.jsx("div",{style:r,ref:u(o,t)})});g.displayName="ShadowRoot";var K=({children:e,locale:r,theme:o,themeStyle:t,disableThemeProvider:s=false,disableFrameProvider:c=false,messages:f})=>{let[d,$]=n.useState(),i=[s?void 0:({children:a})=>jsxRuntime.jsx(core.ThemeProvider,{theme:o,style:t,children:a}),c?void 0:({children:a})=>jsxRuntime.jsx(core.FrameProvider,{portalContainer:d,children:a})].filter(Boolean);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(core.I18nProvider,{locale:r,messages:f,children:jsxRuntime.jsx(({children:a})=>{let l=a;for(let P of [...i].reverse())l=P?.({children:l});return l},{children:e})}),jsxRuntime.jsx("div",{id:"portal-container",ref:a=>{$(a??void 0);}})]})};exports.IFrame=E;exports.ProvidersContainer=K;exports.ShadowRoot=g;exports.getRootStyles=x;
@@ -0,0 +1,11 @@
1
+ import n,{useEffect,useState}from'react';import R from'react-frame-component';import S from'react-dom/client';import {PortalContainerProvider,I18nProvider,ThemeProvider,FrameProvider}from'@baseline-ui/core';import {jsx,jsxs,Fragment}from'react/jsx-runtime';/**
2
+ * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
+ *
4
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
5
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.
6
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
7
+ * This notice may not be removed from this file.
8
+ *
9
+ */
10
+ function u(...e){return e.length===1&&e[0]?e[0]:r=>{for(let o of e)typeof o=="function"?o(r):o!=null&&(o.current=r);}}function x(){let e=[],r=document;for(let o=0;o<r.styleSheets.length;o++){let t=r.styleSheets[o];if(t.cssRules){let s=t.cssRules;for(let c of s)e.push(c.cssText);}}return e.join(`
11
+ `)}var E=n.forwardRef(({head:e=jsx("style",{children:x()}),...r},o)=>jsx(R,{style:{width:"100vw",height:"100vh",border:"none"},ref:o,...r,head:e}));E.displayName="IFrame";var g=n.forwardRef(({children:e,style:r},o)=>{let t=n.useRef(null),s=n.useRef(null),c=n.useMemo(()=>x(),[]);return useEffect(()=>{let f=null;if(t.current&&!s.current){let d=t.current.attachShadow({mode:"open"});s.current=d;let $=document.createElement("style");$.textContent=c,d.append($);let i=document.createElement("div");i.className="content-container",d.append(i);let m=document.createElement("div");m.className="overlay-portal",d.append(m),f=S.createRoot(i),f.render(jsx(PortalContainerProvider,{portalContainer:m,children:e}));}return ()=>{f&&f.unmount();}},[c,e]),jsx("div",{style:r,ref:u(o,t)})});g.displayName="ShadowRoot";var K=({children:e,locale:r,theme:o,themeStyle:t,disableThemeProvider:s=false,disableFrameProvider:c=false,messages:f})=>{let[d,$]=useState(),i=[s?void 0:({children:a})=>jsx(ThemeProvider,{theme:o,style:t,children:a}),c?void 0:({children:a})=>jsx(FrameProvider,{portalContainer:d,children:a})].filter(Boolean);return jsxs(Fragment,{children:[jsx(I18nProvider,{locale:r,messages:f,children:jsx(({children:a})=>{let l=a;for(let P of [...i].reverse())l=P?.({children:l});return l},{children:e})}),jsx("div",{id:"portal-container",ref:a=>{$(a??void 0);}})]})};export{E as IFrame,K as ProvidersContainer,g as ShadowRoot,x as getRootStyles};
@@ -0,0 +1,63 @@
1
+ import * as _playwright_test from '@playwright/test';
2
+ import { SinonSpy } from 'sinon';
3
+
4
+ declare const expect: _playwright_test.Expect<{
5
+ toBeWithinDelta(this: _playwright_test.ExpectMatcherState, received: number, expected: number, delta: number): {
6
+ message: () => string;
7
+ pass: true;
8
+ } | {
9
+ message: () => string;
10
+ pass: false;
11
+ };
12
+ toBeCalledOnce(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
13
+ message: () => string;
14
+ pass: true;
15
+ } | {
16
+ message: () => string;
17
+ pass: false;
18
+ }>;
19
+ toBeCalledTwice(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
20
+ message: () => string;
21
+ pass: true;
22
+ } | {
23
+ message: () => string;
24
+ pass: false;
25
+ }>;
26
+ toBeCalledThrice(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
27
+ message: () => string;
28
+ pass: true;
29
+ } | {
30
+ message: () => string;
31
+ pass: false;
32
+ }>;
33
+ toBeCalledWith(this: _playwright_test.ExpectMatcherState, fn: SinonSpy, ...args: unknown[]): Promise<{
34
+ message: () => string;
35
+ pass: true;
36
+ } | {
37
+ message: () => string;
38
+ pass: false;
39
+ }>;
40
+ toBeCalledWithExactly(this: _playwright_test.ExpectMatcherState, fn: SinonSpy, ...args: unknown[]): Promise<{
41
+ message: () => string;
42
+ pass: true;
43
+ } | {
44
+ message: () => string;
45
+ pass: false;
46
+ }>;
47
+ toBeCalled(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): {
48
+ message: () => string;
49
+ pass: true;
50
+ } | {
51
+ message: () => string;
52
+ pass: false;
53
+ };
54
+ toBeCalledTimes(this: _playwright_test.ExpectMatcherState, fn: SinonSpy, times: number): Promise<{
55
+ message: () => string;
56
+ pass: true;
57
+ } | {
58
+ message: () => string;
59
+ pass: false;
60
+ }>;
61
+ }>;
62
+
63
+ export { expect };
@@ -0,0 +1,63 @@
1
+ import * as _playwright_test from '@playwright/test';
2
+ import { SinonSpy } from 'sinon';
3
+
4
+ declare const expect: _playwright_test.Expect<{
5
+ toBeWithinDelta(this: _playwright_test.ExpectMatcherState, received: number, expected: number, delta: number): {
6
+ message: () => string;
7
+ pass: true;
8
+ } | {
9
+ message: () => string;
10
+ pass: false;
11
+ };
12
+ toBeCalledOnce(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
13
+ message: () => string;
14
+ pass: true;
15
+ } | {
16
+ message: () => string;
17
+ pass: false;
18
+ }>;
19
+ toBeCalledTwice(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
20
+ message: () => string;
21
+ pass: true;
22
+ } | {
23
+ message: () => string;
24
+ pass: false;
25
+ }>;
26
+ toBeCalledThrice(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): Promise<{
27
+ message: () => string;
28
+ pass: true;
29
+ } | {
30
+ message: () => string;
31
+ pass: false;
32
+ }>;
33
+ toBeCalledWith(this: _playwright_test.ExpectMatcherState, fn: SinonSpy, ...args: unknown[]): Promise<{
34
+ message: () => string;
35
+ pass: true;
36
+ } | {
37
+ message: () => string;
38
+ pass: false;
39
+ }>;
40
+ toBeCalledWithExactly(this: _playwright_test.ExpectMatcherState, fn: SinonSpy, ...args: unknown[]): Promise<{
41
+ message: () => string;
42
+ pass: true;
43
+ } | {
44
+ message: () => string;
45
+ pass: false;
46
+ }>;
47
+ toBeCalled(this: _playwright_test.ExpectMatcherState, fn: SinonSpy): {
48
+ message: () => string;
49
+ pass: true;
50
+ } | {
51
+ message: () => string;
52
+ pass: false;
53
+ };
54
+ toBeCalledTimes(this: _playwright_test.ExpectMatcherState, fn: SinonSpy, times: number): Promise<{
55
+ message: () => string;
56
+ pass: true;
57
+ } | {
58
+ message: () => string;
59
+ pass: false;
60
+ }>;
61
+ }>;
62
+
63
+ export { expect };
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ 'use strict';var test=require('@playwright/test');/**
2
+ * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
+ *
4
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
5
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.
6
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
7
+ * This notice may not be removed from this file.
8
+ *
9
+ */
10
+ var o=test.expect.extend({toBeWithinDelta(t,e,s){return Math.abs(t-e)<=s?{message:()=>`expected ${t} not to be within ${s} of ${e}`,pass:true}:{message:()=>`expected ${t} to be within ${s} of ${e}`,pass:false}},async toBeCalledOnce(t){try{return await test.expect.poll(()=>t.callCount).toBe(1),{message:()=>"Expected function to be called once.",pass:!0}}catch(e){return {message:()=>e.message,pass:false}}},async toBeCalledTwice(t){try{return await test.expect.poll(()=>t.callCount).toBe(2),{message:()=>"Expected function to be called twice.",pass:!0}}catch(e){return {message:()=>e.message,pass:false}}},async toBeCalledThrice(t){try{return await test.expect.poll(()=>t.callCount).toBe(3),{message:()=>"Expected function to be called thrice.",pass:!0}}catch(e){return {message:()=>e.message,pass:false}}},async toBeCalledWith(t,...e){try{return await test.expect(()=>{for(let[s,r]of e.entries())test.expect(t.lastCall?.args?.[s]).toStrictEqual(r);}).toPass(),{message:()=>`Expected function to be called with ${e.join(", ")}.`,pass:!0}}catch(s){return {message:()=>s.message,pass:false}}},async toBeCalledWithExactly(t,...e){try{return await test.expect.poll(()=>t.lastCall?.args).toStrictEqual(e),{message:()=>`Expected function to be called with exactly ${e.join(", ")}.`,pass:!0}}catch(s){return {message:()=>s.message,pass:false}}},toBeCalled(t){try{return test.expect(t.called).toBeTruthy(),{message:()=>"Expected function to be called.",pass:!0}}catch(e){return {message:()=>e.message,pass:false}}},async toBeCalledTimes(t,e){try{return await test.expect.poll(()=>t.callCount).toBe(e),{message:()=>`Expected function to be called ${e} times.`,pass:!0}}catch(s){return {message:()=>s.message,pass:false}}}});exports.expect=o;
package/dist/index.mjs ADDED
@@ -0,0 +1,10 @@
1
+ import {expect}from'@playwright/test';/**
2
+ * Copyright (c) 2023-2024 PSPDFKit GmbH. All rights reserved.
3
+ *
4
+ * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
5
+ * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.
6
+ * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
7
+ * This notice may not be removed from this file.
8
+ *
9
+ */
10
+ var o=expect.extend({toBeWithinDelta(t,e,s){return Math.abs(t-e)<=s?{message:()=>`expected ${t} not to be within ${s} of ${e}`,pass:true}:{message:()=>`expected ${t} to be within ${s} of ${e}`,pass:false}},async toBeCalledOnce(t){try{return await expect.poll(()=>t.callCount).toBe(1),{message:()=>"Expected function to be called once.",pass:!0}}catch(e){return {message:()=>e.message,pass:false}}},async toBeCalledTwice(t){try{return await expect.poll(()=>t.callCount).toBe(2),{message:()=>"Expected function to be called twice.",pass:!0}}catch(e){return {message:()=>e.message,pass:false}}},async toBeCalledThrice(t){try{return await expect.poll(()=>t.callCount).toBe(3),{message:()=>"Expected function to be called thrice.",pass:!0}}catch(e){return {message:()=>e.message,pass:false}}},async toBeCalledWith(t,...e){try{return await expect(()=>{for(let[s,r]of e.entries())expect(t.lastCall?.args?.[s]).toStrictEqual(r);}).toPass(),{message:()=>`Expected function to be called with ${e.join(", ")}.`,pass:!0}}catch(s){return {message:()=>s.message,pass:false}}},async toBeCalledWithExactly(t,...e){try{return await expect.poll(()=>t.lastCall?.args).toStrictEqual(e),{message:()=>`Expected function to be called with exactly ${e.join(", ")}.`,pass:!0}}catch(s){return {message:()=>s.message,pass:false}}},toBeCalled(t){try{return expect(t.called).toBeTruthy(),{message:()=>"Expected function to be called.",pass:!0}}catch(e){return {message:()=>e.message,pass:false}}},async toBeCalledTimes(t,e){try{return await expect.poll(()=>t.callCount).toBe(e),{message:()=>`Expected function to be called ${e} times.`,pass:!0}}catch(s){return {message:()=>s.message,pass:false}}}});export{o as expect};
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@baseline-ui/test-utils",
3
+ "version": "0.0.0-nightly-20250403000606",
4
+ "description": "A collection of test utilities for Baseline UI",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "style": "dist/index.css",
9
+ "files": [
10
+ "dist",
11
+ "License.md",
12
+ "Acknowledgements.md",
13
+ "client"
14
+ ],
15
+ "source": "src/index.ts",
16
+ "author": "",
17
+ "license": "SEE LICENSE IN https://pspdfkit.com/legal/License.pdf",
18
+ "peerDependencies": {
19
+ "react": "^18.0.0",
20
+ "react-dom": "^18.0.0",
21
+ "sinon": ">=19.0.0"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "dependencies": {
27
+ "@playwright/test": "1.51.0",
28
+ "@react-aria/utils": "3.24.1",
29
+ "react-frame-component": "^5.2.7",
30
+ "@baseline-ui/core": "0.0.0-nightly-20250403000606"
31
+ },
32
+ "scripts": {
33
+ "build": "tsup",
34
+ "acknowledgements": "pnpm-licenses generate-disclaimer --prod --output-file=Acknowledgements.md"
35
+ }
36
+ }