@ebertjendustries/cstestwrapper 1.0.18 → 1.0.21

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/dist/index.d.mts CHANGED
@@ -195,6 +195,7 @@ declare class HeaderTesting extends AbstractComponentTesting<HeaderWrapper, Fiel
195
195
  expectCounter(counterText: string | RegExp): void;
196
196
  expectContent(content: string | RegExp): void;
197
197
  expectNotContent(content: string | RegExp): void;
198
+ expectLocalisation(variables?: any, alternateNs?: LocalisationNamespace): void;
198
199
  }
199
200
 
200
201
  declare class BoxTesting extends AbstractComponentTesting<BoxWrapper, FieldSpec> {
@@ -546,43 +547,10 @@ declare class MockRestClient implements _ebertjendustries_cswrapper.IRestClient
546
547
  private mockImpl;
547
548
  }
548
549
 
549
- declare class MockServerBuilder {
550
- private port;
551
- private mockData;
552
- private redirectUrls;
553
- private server;
554
- private jsonServer;
555
- constructor(port: number, requireFunc: Function);
556
- addToMockData(key: string, data: any): void;
557
- /**
558
- * Puts mock data: Adds it to internal data structures and prepares it for mocking. It potentially updates
559
- * the overall mock data object later passed into jsonServer router as well as the rewrite object later
560
- * passed into jsonServer.rewriter.
561
- *
562
- * @param key The key of the data
563
- * @param data The data itself
564
- * @param urlRedirects The redirect URLs to be rewritten to the key url
565
- * @param crud Whether this is a crud redirect
566
- * @returns The loaded mock data object
567
- */
568
- putMockData(key: string, data: any, urlRedirects: string[], crud?: boolean): void;
569
- addToRedirects(key: string, urlRedirects: string[], crud: boolean): void;
570
- rewritePostToGet(url: string): void;
571
- static set200WithData(res: any, data: any): void;
572
- static respondWithError(res: any, componentId: string, messageId: string, httpStatus: number, op: string, message: string): void;
573
- mockCall(url: string, callProcessor: (req: any, res: any, next: Function) => void): void;
574
- mockCRUDMulti(urls: string[], allElements: any, finder: (id: number) => any, operationDesc: string): void;
575
- mockCRUD(url: string, allElements: any, finder: (id: number) => any, operationDesc: string): void;
576
- start(): void;
577
- private useCors;
578
- private static allowCors;
579
- private static postRewriteToGet;
580
- }
581
-
582
550
  declare class ViewTestWrapperProps<T> {
583
551
  initialValue: T;
584
552
  view: (value: T, onChange: PropertyChangeFunction) => React.ReactNode;
585
553
  }
586
554
  declare function ViewTestWrapper<T>(props: ViewTestWrapperProps<T>): react_jsx_runtime.JSX.Element;
587
555
 
588
- export { AbstractComponentTesting, AbstractInputTesting, AbstractSelectTesting, AbstractViewTesting, AlertTesting, BoxTesting, ButtonDropdownTesting, ButtonTesting, CSVNoItemsViewTesting, CSVPriceInputViewTesting, CSVSearchFilterViewTesting, CSVTextPromptModalViewTesting, CardsTesting, CheckboxTesting, CollectionPreferencesSetting, CollectionPreferencesTesting, CopyToClipboardTesting, DatePickerTesting, FlashbarTesting, FormTesting, HeaderTesting, IconTesting, LinkTesting, MockBrowserAPIs, MockRestClient, MockServerBuilder, ModalTesting, MultiselectTesting, NumberInputTesting, PaginationTesting, ProgressBarTesting, RatingTesting, SegmentedControlTesting, SelectTesting, StatusIndicatorTesting, StringInputTesting, TableTesting, TabsTesting, TestLocalisation, TestingFactory, TextContentTesting, TextFilterTesting, TextareaTesting, ToggleTesting, ViewTestWrapper, WizardTesting, setupRestClientMock };
556
+ export { AbstractComponentTesting, AbstractInputTesting, AbstractSelectTesting, AbstractViewTesting, AlertTesting, BoxTesting, ButtonDropdownTesting, ButtonTesting, CSVNoItemsViewTesting, CSVPriceInputViewTesting, CSVSearchFilterViewTesting, CSVTextPromptModalViewTesting, CardsTesting, CheckboxTesting, CollectionPreferencesSetting, CollectionPreferencesTesting, CopyToClipboardTesting, DatePickerTesting, FlashbarTesting, FormTesting, HeaderTesting, IconTesting, LinkTesting, MockBrowserAPIs, MockRestClient, ModalTesting, MultiselectTesting, NumberInputTesting, PaginationTesting, ProgressBarTesting, RatingTesting, SegmentedControlTesting, SelectTesting, StatusIndicatorTesting, StringInputTesting, TableTesting, TabsTesting, TestLocalisation, TestingFactory, TextContentTesting, TextFilterTesting, TextareaTesting, ToggleTesting, ViewTestWrapper, WizardTesting, setupRestClientMock };
package/dist/index.d.ts CHANGED
@@ -195,6 +195,7 @@ declare class HeaderTesting extends AbstractComponentTesting<HeaderWrapper, Fiel
195
195
  expectCounter(counterText: string | RegExp): void;
196
196
  expectContent(content: string | RegExp): void;
197
197
  expectNotContent(content: string | RegExp): void;
198
+ expectLocalisation(variables?: any, alternateNs?: LocalisationNamespace): void;
198
199
  }
199
200
 
200
201
  declare class BoxTesting extends AbstractComponentTesting<BoxWrapper, FieldSpec> {
@@ -546,43 +547,10 @@ declare class MockRestClient implements _ebertjendustries_cswrapper.IRestClient
546
547
  private mockImpl;
547
548
  }
548
549
 
549
- declare class MockServerBuilder {
550
- private port;
551
- private mockData;
552
- private redirectUrls;
553
- private server;
554
- private jsonServer;
555
- constructor(port: number, requireFunc: Function);
556
- addToMockData(key: string, data: any): void;
557
- /**
558
- * Puts mock data: Adds it to internal data structures and prepares it for mocking. It potentially updates
559
- * the overall mock data object later passed into jsonServer router as well as the rewrite object later
560
- * passed into jsonServer.rewriter.
561
- *
562
- * @param key The key of the data
563
- * @param data The data itself
564
- * @param urlRedirects The redirect URLs to be rewritten to the key url
565
- * @param crud Whether this is a crud redirect
566
- * @returns The loaded mock data object
567
- */
568
- putMockData(key: string, data: any, urlRedirects: string[], crud?: boolean): void;
569
- addToRedirects(key: string, urlRedirects: string[], crud: boolean): void;
570
- rewritePostToGet(url: string): void;
571
- static set200WithData(res: any, data: any): void;
572
- static respondWithError(res: any, componentId: string, messageId: string, httpStatus: number, op: string, message: string): void;
573
- mockCall(url: string, callProcessor: (req: any, res: any, next: Function) => void): void;
574
- mockCRUDMulti(urls: string[], allElements: any, finder: (id: number) => any, operationDesc: string): void;
575
- mockCRUD(url: string, allElements: any, finder: (id: number) => any, operationDesc: string): void;
576
- start(): void;
577
- private useCors;
578
- private static allowCors;
579
- private static postRewriteToGet;
580
- }
581
-
582
550
  declare class ViewTestWrapperProps<T> {
583
551
  initialValue: T;
584
552
  view: (value: T, onChange: PropertyChangeFunction) => React.ReactNode;
585
553
  }
586
554
  declare function ViewTestWrapper<T>(props: ViewTestWrapperProps<T>): react_jsx_runtime.JSX.Element;
587
555
 
588
- export { AbstractComponentTesting, AbstractInputTesting, AbstractSelectTesting, AbstractViewTesting, AlertTesting, BoxTesting, ButtonDropdownTesting, ButtonTesting, CSVNoItemsViewTesting, CSVPriceInputViewTesting, CSVSearchFilterViewTesting, CSVTextPromptModalViewTesting, CardsTesting, CheckboxTesting, CollectionPreferencesSetting, CollectionPreferencesTesting, CopyToClipboardTesting, DatePickerTesting, FlashbarTesting, FormTesting, HeaderTesting, IconTesting, LinkTesting, MockBrowserAPIs, MockRestClient, MockServerBuilder, ModalTesting, MultiselectTesting, NumberInputTesting, PaginationTesting, ProgressBarTesting, RatingTesting, SegmentedControlTesting, SelectTesting, StatusIndicatorTesting, StringInputTesting, TableTesting, TabsTesting, TestLocalisation, TestingFactory, TextContentTesting, TextFilterTesting, TextareaTesting, ToggleTesting, ViewTestWrapper, WizardTesting, setupRestClientMock };
556
+ export { AbstractComponentTesting, AbstractInputTesting, AbstractSelectTesting, AbstractViewTesting, AlertTesting, BoxTesting, ButtonDropdownTesting, ButtonTesting, CSVNoItemsViewTesting, CSVPriceInputViewTesting, CSVSearchFilterViewTesting, CSVTextPromptModalViewTesting, CardsTesting, CheckboxTesting, CollectionPreferencesSetting, CollectionPreferencesTesting, CopyToClipboardTesting, DatePickerTesting, FlashbarTesting, FormTesting, HeaderTesting, IconTesting, LinkTesting, MockBrowserAPIs, MockRestClient, ModalTesting, MultiselectTesting, NumberInputTesting, PaginationTesting, ProgressBarTesting, RatingTesting, SegmentedControlTesting, SelectTesting, StatusIndicatorTesting, StringInputTesting, TableTesting, TabsTesting, TestLocalisation, TestingFactory, TextContentTesting, TextFilterTesting, TextareaTesting, ToggleTesting, ViewTestWrapper, WizardTesting, setupRestClientMock };
package/dist/index.js CHANGED
@@ -55,7 +55,6 @@ __export(index_exports, {
55
55
  LinkTesting: () => LinkTesting,
56
56
  MockBrowserAPIs: () => MockBrowserAPIs,
57
57
  MockRestClient: () => MockRestClient,
58
- MockServerBuilder: () => MockServerBuilder,
59
58
  ModalTesting: () => ModalTesting,
60
59
  MultiselectTesting: () => MultiselectTesting,
61
60
  NumberInputTesting: () => NumberInputTesting,
@@ -836,6 +835,9 @@ var HeaderTesting = class extends AbstractComponentTesting {
836
835
  expectNotContent(content) {
837
836
  (0, import_vitest11.expect)(this.getElementWrapper().findHeadingText().getElement()).not.toHaveTextContent(content);
838
837
  }
838
+ expectLocalisation(variables, alternateNs) {
839
+ this.expectContent(this.getLocalisedField(variables, alternateNs).children.trim());
840
+ }
839
841
  };
840
842
 
841
843
  // src/components/BoxTesting.ts
@@ -1796,140 +1798,6 @@ var MockRestClient = class {
1796
1798
  }
1797
1799
  };
1798
1800
 
1799
- // src/mocks/MockServerBuilder.ts
1800
- var MockServerBuilder = class _MockServerBuilder {
1801
- constructor(port, requireFunc) {
1802
- this.port = port;
1803
- this.mockData = {};
1804
- this.redirectUrls = {};
1805
- this.jsonServer = requireFunc("json-server");
1806
- this.server = this.jsonServer.create();
1807
- this.server.use(this.jsonServer.bodyParser);
1808
- }
1809
- addToMockData(key, data) {
1810
- this.mockData[key] = data;
1811
- }
1812
- /**
1813
- * Puts mock data: Adds it to internal data structures and prepares it for mocking. It potentially updates
1814
- * the overall mock data object later passed into jsonServer router as well as the rewrite object later
1815
- * passed into jsonServer.rewriter.
1816
- *
1817
- * @param key The key of the data
1818
- * @param data The data itself
1819
- * @param urlRedirects The redirect URLs to be rewritten to the key url
1820
- * @param crud Whether this is a crud redirect
1821
- * @returns The loaded mock data object
1822
- */
1823
- putMockData(key, data, urlRedirects, crud) {
1824
- this.addToMockData(key, data);
1825
- if (crud !== void 0) {
1826
- this.addToRedirects(key, urlRedirects, crud);
1827
- } else {
1828
- this.addToRedirects(key, urlRedirects, false);
1829
- }
1830
- }
1831
- addToRedirects(key, urlRedirects, crud) {
1832
- urlRedirects.forEach((urlRedirect) => this.redirectUrls[urlRedirect] = "/" + key);
1833
- if (crud) {
1834
- urlRedirects.forEach((urlRedirect) => this.redirectUrls[urlRedirect + "/:id"] = "/" + key + "/:id");
1835
- }
1836
- }
1837
- rewritePostToGet(url) {
1838
- this.useCors(url);
1839
- this.server.use(url, _MockServerBuilder.postRewriteToGet);
1840
- }
1841
- static set200WithData(res, data) {
1842
- res.status(200).jsonp({ content: data });
1843
- }
1844
- static respondWithError(res, componentId, messageId, httpStatus, op, message) {
1845
- res.status(httpStatus).jsonp({
1846
- messages: [
1847
- {
1848
- "code": {
1849
- "componentId": componentId,
1850
- "httpStatusCode": httpStatus,
1851
- "localCode": messageId,
1852
- "messageSeverity": "ERR",
1853
- "uniqueCode": componentId + messageId
1854
- },
1855
- "correlationId": "N/A",
1856
- "detailMessage": message,
1857
- "operation": op,
1858
- "timestamp": "2022-05-10T15:17:08Z"
1859
- }
1860
- ]
1861
- });
1862
- }
1863
- mockCall(url, callProcessor) {
1864
- this.useCors(url);
1865
- this.server.use(url, callProcessor);
1866
- }
1867
- mockCRUDMulti(urls, allElements, finder, operationDesc) {
1868
- urls.forEach((url) => this.mockCRUD(url, allElements, finder, operationDesc));
1869
- }
1870
- mockCRUD(url, allElements, finder, operationDesc) {
1871
- this.mockCall(`${url}${url.endsWith("/") ? "" : "/"}:id`, async (req, res, next) => {
1872
- const method = req.method;
1873
- const id = parseInt(req.params["id"]);
1874
- console.log(`Calling ${operationDesc} CRUD ${method} with id ${id}`);
1875
- if (method === "GET") {
1876
- let returnedEntity = finder(id);
1877
- _MockServerBuilder.set200WithData(res, returnedEntity);
1878
- } else {
1879
- _MockServerBuilder.set200WithData(res, {});
1880
- }
1881
- });
1882
- this.mockCall(`${url}`, async (req, res, next) => {
1883
- const method = req.method;
1884
- console.log(`Calling ${operationDesc} CRUD ${method}${method === "GET" ? " ALL" : ""}`);
1885
- if (method === "GET") {
1886
- _MockServerBuilder.set200WithData(res, allElements);
1887
- } else if (method === "PUT") {
1888
- _MockServerBuilder.set200WithData(res, req.body);
1889
- } else {
1890
- _MockServerBuilder.set200WithData(res, {});
1891
- }
1892
- });
1893
- }
1894
- start() {
1895
- console.log("Mock data keys: " + Object.keys(this.mockData));
1896
- console.log("Redirect URLs: ", this.redirectUrls);
1897
- const router = this.jsonServer.router(this.mockData);
1898
- const middlewares = this.jsonServer.defaults();
1899
- this.server.use(this.jsonServer.rewriter(this.redirectUrls));
1900
- Object.keys(this.redirectUrls).forEach((redirectUrl) => {
1901
- this.useCors(redirectUrl);
1902
- });
1903
- this.server.use(middlewares);
1904
- this.server.use(router);
1905
- router.render = function(req, res) {
1906
- res.jsonp({
1907
- content: res.locals.data
1908
- });
1909
- };
1910
- this.server.listen(this.port, () => {
1911
- console.log("JSON Server is running on port " + this.port);
1912
- });
1913
- }
1914
- useCors(url) {
1915
- console.log("Configuring CORS for: ", url);
1916
- this.server.use(url, _MockServerBuilder.allowCors);
1917
- }
1918
- static allowCors(req, res, next) {
1919
- res.header("Access-Control-Allow-Origin", "*");
1920
- res.header("Access-Control-Allow-Headers", "*");
1921
- res.header("Access-Control-Allow-Methods", "*");
1922
- next();
1923
- }
1924
- static postRewriteToGet(req, res, next) {
1925
- if (req.method === "POST") {
1926
- console.log(`Received POST request, rewriting to GET: ` + req.url);
1927
- req.method = "GET";
1928
- }
1929
- next();
1930
- }
1931
- };
1932
-
1933
1801
  // src/utils/ViewTestWrapper.tsx
1934
1802
  var import_react30 = require("react");
1935
1803
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -1964,7 +1832,6 @@ function ViewTestWrapper(props) {
1964
1832
  LinkTesting,
1965
1833
  MockBrowserAPIs,
1966
1834
  MockRestClient,
1967
- MockServerBuilder,
1968
1835
  ModalTesting,
1969
1836
  MultiselectTesting,
1970
1837
  NumberInputTesting,
package/dist/index.mjs CHANGED
@@ -754,6 +754,9 @@ var HeaderTesting = class extends AbstractComponentTesting {
754
754
  expectNotContent(content) {
755
755
  expect11(this.getElementWrapper().findHeadingText().getElement()).not.toHaveTextContent(content);
756
756
  }
757
+ expectLocalisation(variables, alternateNs) {
758
+ this.expectContent(this.getLocalisedField(variables, alternateNs).children.trim());
759
+ }
757
760
  };
758
761
 
759
762
  // src/components/BoxTesting.ts
@@ -1716,140 +1719,6 @@ var MockRestClient = class {
1716
1719
  }
1717
1720
  };
1718
1721
 
1719
- // src/mocks/MockServerBuilder.ts
1720
- var MockServerBuilder = class _MockServerBuilder {
1721
- constructor(port, requireFunc) {
1722
- this.port = port;
1723
- this.mockData = {};
1724
- this.redirectUrls = {};
1725
- this.jsonServer = requireFunc("json-server");
1726
- this.server = this.jsonServer.create();
1727
- this.server.use(this.jsonServer.bodyParser);
1728
- }
1729
- addToMockData(key, data) {
1730
- this.mockData[key] = data;
1731
- }
1732
- /**
1733
- * Puts mock data: Adds it to internal data structures and prepares it for mocking. It potentially updates
1734
- * the overall mock data object later passed into jsonServer router as well as the rewrite object later
1735
- * passed into jsonServer.rewriter.
1736
- *
1737
- * @param key The key of the data
1738
- * @param data The data itself
1739
- * @param urlRedirects The redirect URLs to be rewritten to the key url
1740
- * @param crud Whether this is a crud redirect
1741
- * @returns The loaded mock data object
1742
- */
1743
- putMockData(key, data, urlRedirects, crud) {
1744
- this.addToMockData(key, data);
1745
- if (crud !== void 0) {
1746
- this.addToRedirects(key, urlRedirects, crud);
1747
- } else {
1748
- this.addToRedirects(key, urlRedirects, false);
1749
- }
1750
- }
1751
- addToRedirects(key, urlRedirects, crud) {
1752
- urlRedirects.forEach((urlRedirect) => this.redirectUrls[urlRedirect] = "/" + key);
1753
- if (crud) {
1754
- urlRedirects.forEach((urlRedirect) => this.redirectUrls[urlRedirect + "/:id"] = "/" + key + "/:id");
1755
- }
1756
- }
1757
- rewritePostToGet(url) {
1758
- this.useCors(url);
1759
- this.server.use(url, _MockServerBuilder.postRewriteToGet);
1760
- }
1761
- static set200WithData(res, data) {
1762
- res.status(200).jsonp({ content: data });
1763
- }
1764
- static respondWithError(res, componentId, messageId, httpStatus, op, message) {
1765
- res.status(httpStatus).jsonp({
1766
- messages: [
1767
- {
1768
- "code": {
1769
- "componentId": componentId,
1770
- "httpStatusCode": httpStatus,
1771
- "localCode": messageId,
1772
- "messageSeverity": "ERR",
1773
- "uniqueCode": componentId + messageId
1774
- },
1775
- "correlationId": "N/A",
1776
- "detailMessage": message,
1777
- "operation": op,
1778
- "timestamp": "2022-05-10T15:17:08Z"
1779
- }
1780
- ]
1781
- });
1782
- }
1783
- mockCall(url, callProcessor) {
1784
- this.useCors(url);
1785
- this.server.use(url, callProcessor);
1786
- }
1787
- mockCRUDMulti(urls, allElements, finder, operationDesc) {
1788
- urls.forEach((url) => this.mockCRUD(url, allElements, finder, operationDesc));
1789
- }
1790
- mockCRUD(url, allElements, finder, operationDesc) {
1791
- this.mockCall(`${url}${url.endsWith("/") ? "" : "/"}:id`, async (req, res, next) => {
1792
- const method = req.method;
1793
- const id = parseInt(req.params["id"]);
1794
- console.log(`Calling ${operationDesc} CRUD ${method} with id ${id}`);
1795
- if (method === "GET") {
1796
- let returnedEntity = finder(id);
1797
- _MockServerBuilder.set200WithData(res, returnedEntity);
1798
- } else {
1799
- _MockServerBuilder.set200WithData(res, {});
1800
- }
1801
- });
1802
- this.mockCall(`${url}`, async (req, res, next) => {
1803
- const method = req.method;
1804
- console.log(`Calling ${operationDesc} CRUD ${method}${method === "GET" ? " ALL" : ""}`);
1805
- if (method === "GET") {
1806
- _MockServerBuilder.set200WithData(res, allElements);
1807
- } else if (method === "PUT") {
1808
- _MockServerBuilder.set200WithData(res, req.body);
1809
- } else {
1810
- _MockServerBuilder.set200WithData(res, {});
1811
- }
1812
- });
1813
- }
1814
- start() {
1815
- console.log("Mock data keys: " + Object.keys(this.mockData));
1816
- console.log("Redirect URLs: ", this.redirectUrls);
1817
- const router = this.jsonServer.router(this.mockData);
1818
- const middlewares = this.jsonServer.defaults();
1819
- this.server.use(this.jsonServer.rewriter(this.redirectUrls));
1820
- Object.keys(this.redirectUrls).forEach((redirectUrl) => {
1821
- this.useCors(redirectUrl);
1822
- });
1823
- this.server.use(middlewares);
1824
- this.server.use(router);
1825
- router.render = function(req, res) {
1826
- res.jsonp({
1827
- content: res.locals.data
1828
- });
1829
- };
1830
- this.server.listen(this.port, () => {
1831
- console.log("JSON Server is running on port " + this.port);
1832
- });
1833
- }
1834
- useCors(url) {
1835
- console.log("Configuring CORS for: ", url);
1836
- this.server.use(url, _MockServerBuilder.allowCors);
1837
- }
1838
- static allowCors(req, res, next) {
1839
- res.header("Access-Control-Allow-Origin", "*");
1840
- res.header("Access-Control-Allow-Headers", "*");
1841
- res.header("Access-Control-Allow-Methods", "*");
1842
- next();
1843
- }
1844
- static postRewriteToGet(req, res, next) {
1845
- if (req.method === "POST") {
1846
- console.log(`Received POST request, rewriting to GET: ` + req.url);
1847
- req.method = "GET";
1848
- }
1849
- next();
1850
- }
1851
- };
1852
-
1853
1722
  // src/utils/ViewTestWrapper.tsx
1854
1723
  import { useState } from "react";
1855
1724
  import { jsx } from "react/jsx-runtime";
@@ -1883,7 +1752,6 @@ export {
1883
1752
  LinkTesting,
1884
1753
  MockBrowserAPIs,
1885
1754
  MockRestClient,
1886
- MockServerBuilder,
1887
1755
  ModalTesting,
1888
1756
  MultiselectTesting,
1889
1757
  NumberInputTesting,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebertjendustries/cstestwrapper",
3
- "version": "1.0.18",
3
+ "version": "1.0.21",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -93,5 +93,5 @@
93
93
  "last 1 safari version"
94
94
  ]
95
95
  },
96
- "packageManager": "yarn@4.9.1"
96
+ "packageManager": "yarn@4.9.2"
97
97
  }