@luigi-project/testing-utilities 2.8.1-dev.20240221203 → 2.8.1-dev.20240221333

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.
@@ -50,7 +50,6 @@ export class LuigiMockEngine {
50
50
  },
51
51
  mockListeners: {
52
52
  'luigi.navigation.pathExists': (event) => {
53
- console.log('######luigi.navigation.pathExists');
54
53
  const mockData = window.sessionStorage.getItem('luigiMockData');
55
54
  let mockDataParsed = mockData ? JSON.parse(mockData) : undefined;
56
55
  const inputPath = event.data.data.link;
@@ -137,7 +136,6 @@ export class LuigiMockEngine {
137
136
  * which holds data that is useful for e2e testing.
138
137
  */
139
138
  static visualize(data) {
140
- console.log('#######testsetset visualize');
141
139
  let luigiVisualizationContainer = document.querySelector('#luigi-debug-vis-cnt');
142
140
  // Construct element structure if not already constructed
143
141
  if (!luigiVisualizationContainer) {
@@ -5,21 +5,9 @@ export class LuigiMockUtil {
5
5
  * @param mockContext an object representing the context to be mocked
6
6
  */
7
7
  this.mockContext = (mockContext) => {
8
- const postMessageToLuigi = (context) => {
9
- globalThis.postMessage({ msg: 'luigi.get-context', context }, '*');
10
- };
11
- try {
12
- if (this.browser.executeScript) {
13
- this.browser.executeScript(postMessageToLuigi, mockContext);
14
- }
15
- else {
16
- console.log('mockContext');
17
- this.browser(postMessageToLuigi, mockContext);
18
- }
19
- }
20
- catch (e) {
21
- console.debug('Failed to mock context: ', e);
22
- }
8
+ this.browser.executeScript((mockContext) => {
9
+ globalThis.postMessage({ msg: 'luigi.get-context', context: mockContext }, '*');
10
+ }, mockContext);
23
11
  };
24
12
  /**
25
13
  * This method serves as a mock for the luigi client pathExists() function.
@@ -38,7 +26,7 @@ export class LuigiMockUtil {
38
26
  *
39
27
  */
40
28
  this.mockPathExists = (path, exists) => {
41
- const setPathExistsMockData = (path, exists) => {
29
+ this.browser.executeScript((path, exists) => {
42
30
  globalThis.sessionStorage.clear();
43
31
  let pathExistsMockData = {
44
32
  pathExists: {
@@ -46,20 +34,7 @@ export class LuigiMockUtil {
46
34
  }
47
35
  };
48
36
  globalThis.sessionStorage.setItem('luigiMockData', JSON.stringify(pathExistsMockData));
49
- };
50
- try {
51
- if (this.browser.executeScript) {
52
- this.browser.executeScript(setPathExistsMockData, path, exists);
53
- }
54
- else {
55
- console.log('mockPathExists');
56
- this.browser(setPathExistsMockData, path, exists);
57
- }
58
- }
59
- catch (e) {
60
- console.debug('Failed to mock path exists: ', e);
61
- }
62
- this.browser.executeScript ? this.browser.executeScript(setPathExistsMockData, path, exists) : this.browser(setPathExistsMockData, path, exists);
37
+ }, path, exists);
63
38
  };
64
39
  this.messages = [];
65
40
  this.browser = browser;
@@ -69,11 +44,7 @@ export class LuigiMockUtil {
69
44
  */
70
45
  async parseLuigiMockedMessages() {
71
46
  try {
72
- const getTextNodeValues = async () => Array.from(document.getElementById('luigi-debug-vis-cnt').childNodes).map((item) => item.textContent);
73
- console.log('parseLuigiMockedMessages');
74
- const textElements = this.browser.executeScript
75
- ? await this.browser.executeScript(getTextNodeValues)
76
- : await this.browser(getTextNodeValues);
47
+ const textElements = await this.browser.executeScript(() => Array.from(document.getElementById('luigi-debug-vis-cnt').childNodes).map(item => item.textContent));
77
48
  this.messages = textElements
78
49
  .map((item) => {
79
50
  try {
@@ -83,7 +54,7 @@ export class LuigiMockUtil {
83
54
  return undefined;
84
55
  }
85
56
  })
86
- .filter((item) => item !== undefined);
57
+ .filter(item => item !== undefined);
87
58
  }
88
59
  catch (e) {
89
60
  console.debug('Failed to parse luigi mocked messages: ', e);
package/package.json CHANGED
@@ -2,11 +2,21 @@
2
2
  "name": "@luigi-project/testing-utilities",
3
3
  "description": "Luigi testing utilities for standalone testing of microfrontends",
4
4
  "license": "Apache-2.0",
5
- "main": "index.js",
6
- "types": "index.d.ts",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build": "tsc && npm run copy",
9
+ "copy": "ncp package.json ./dist/package.json && ncp README.md ./dist/README.md",
10
+ "bundle": "npm run build"
11
+ },
12
+ "types": "dist/index.d.ts",
7
13
  "publishConfig": {
8
14
  "tag": "testing-utilities"
9
15
  },
16
+ "devDependencies": {
17
+ "ncp": "^2.0.0",
18
+ "typescript": "4.8.2"
19
+ },
10
20
  "repository": {
11
21
  "type": "git",
12
22
  "url": "ssh://github.com/SAP/luigi.git"
@@ -19,7 +29,7 @@
19
29
  "microfrontends",
20
30
  "testing"
21
31
  ],
22
- "version": "2.8.1-dev.20240221203",
32
+ "version": "2.8.1-dev.20240221333",
23
33
  "engines": {
24
34
  "node": ">=18"
25
35
  }