hass-taste-test 0.0.10 → 0.0.14

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/lib/index.js CHANGED
@@ -37,7 +37,7 @@ Object.defineProperty(exports, "PlaywrightBrowser", { enumerable: true, get: fun
37
37
  /** Sleeps for 100 ms */
38
38
  const sleep = () => new Promise((r) => setTimeout(r, 100));
39
39
  const exec = (command, args) => new Promise((resolve, reject) => {
40
- const proc = child_process_1.spawn(command, args, { stdio: 'inherit' });
40
+ const proc = (0, child_process_1.spawn)(command, args, { stdio: 'inherit' });
41
41
  proc.on('error', (err) => reject(err));
42
42
  proc.on('close', (code) => resolve(code));
43
43
  });
@@ -53,7 +53,7 @@ class HomeAssistant {
53
53
  dashboards = 0;
54
54
  ws;
55
55
  constructor(options) {
56
- this.venvDir = path_1.join(os_1.tmpdir(), 'hasstest-venv');
56
+ this.venvDir = (0, path_1.join)((0, os_1.tmpdir)(), 'hasstest-venv');
57
57
  this.options = {
58
58
  python: 'python3',
59
59
  hassArgs: [],
@@ -67,12 +67,12 @@ class HomeAssistant {
67
67
  ...options,
68
68
  };
69
69
  }
70
- path_confFile = () => path_1.join(this.configDir, 'configuration.yaml');
71
- path_componentsDir = () => path_1.join(this.configDir, 'custom_components');
72
- path_wwwDir = () => path_1.join(this.configDir, 'www');
73
- path_hass = () => path_1.join(this.venvDir, 'bin/hass');
74
- path_pip = () => path_1.join(this.venvDir, 'bin/pip');
75
- path_cache = () => path_1.join(os_1.tmpdir(), 'hasstest-cache');
70
+ path_confFile = () => (0, path_1.join)(this.configDir, 'configuration.yaml');
71
+ path_componentsDir = () => (0, path_1.join)(this.configDir, 'custom_components');
72
+ path_wwwDir = () => (0, path_1.join)(this.configDir, 'www');
73
+ path_hass = () => (0, path_1.join)(this.venvDir, 'bin/hass');
74
+ path_pip = () => (0, path_1.join)(this.venvDir, 'bin/pip');
75
+ path_cache = () => (0, path_1.join)((0, os_1.tmpdir)(), 'hasstest-cache');
76
76
  /** Create and connect to an isolated Home Assistant instance */
77
77
  static async create(config, options) {
78
78
  const hass = new HomeAssistant(options);
@@ -87,7 +87,7 @@ class HomeAssistant {
87
87
  }
88
88
  /** Start the Home Assistant server and connect to its websocket */
89
89
  async start(config) {
90
- this.configDir = await fs.mkdtemp(path_1.join(os_1.tmpdir(), 'hasstest-'));
90
+ this.configDir = await fs.mkdtemp((0, path_1.join)((0, os_1.tmpdir)(), 'hasstest-'));
91
91
  // Step 1: Create necessary directories
92
92
  await Promise.all([
93
93
  fs.mkdir(this.path_wwwDir()),
@@ -103,7 +103,7 @@ class HomeAssistant {
103
103
  ]);
104
104
  await releaseLock();
105
105
  // Step 3: Start Home Assistant and onboard
106
- this.process = child_process_1.spawn(this.path_hass(), ['-c', this.configDir, ...this.options.hassArgs], {
106
+ this.process = (0, child_process_1.spawn)(this.path_hass(), ['-c', this.configDir, ...this.options.hassArgs], {
107
107
  stdio: 'inherit',
108
108
  });
109
109
  this.process.on('error', (e) => {
@@ -127,13 +127,13 @@ class HomeAssistant {
127
127
  }
128
128
  /** Symlink custom component directories to the configuration directory */
129
129
  async linkComponents() {
130
- await Promise.all(this.options.customComponents.map((component) => fs.symlink(component, path_1.join(this.path_componentsDir(), path_1.basename(component)), 'junction')));
130
+ await Promise.all(this.options.customComponents.map((component) => fs.symlink(component, (0, path_1.join)(this.path_componentsDir(), (0, path_1.basename)(component)), 'junction')));
131
131
  }
132
132
  /** Wait for lockfile to become released. Forces HassTest instances to start up one at a time */
133
133
  async acquireLock() {
134
134
  for (let iterations = 0; iterations < 600; iterations++)
135
135
  try {
136
- return await proper_lockfile_1.default.lock(os_1.tmpdir(), { lockfilePath: 'hasstest.lock' });
136
+ return await proper_lockfile_1.default.lock((0, os_1.tmpdir)(), { lockfilePath: 'hasstest.lock' });
137
137
  }
138
138
  catch (e) {
139
139
  if (e.code !== 'ELOCKED')
@@ -190,13 +190,13 @@ class HomeAssistant {
190
190
  }
191
191
  /** Fetch the latest hass version from pypi */
192
192
  async latestHAVersion() {
193
- const latest = await node_fetch_1.default('https://pypi.org/pypi/homeassistant/json').then((r) => r.json());
193
+ const latest = await (0, node_fetch_1.default)('https://pypi.org/pypi/homeassistant/json').then((r) => r.json());
194
194
  return latest.info.version;
195
195
  }
196
196
  /** Finds the version of Home Assistant installed, if any */
197
197
  async hassVersion() {
198
- const libFolders = await fs.readdir(path_1.join(this.venvDir, 'lib'));
199
- const libs = await Promise.all(libFolders.map((f) => fs.readdir(path_1.join(this.venvDir, 'lib', f, 'site-packages'))));
198
+ const libFolders = await fs.readdir((0, path_1.join)(this.venvDir, 'lib'));
199
+ const libs = await Promise.all(libFolders.map((f) => fs.readdir((0, path_1.join)(this.venvDir, 'lib', f, 'site-packages'))));
200
200
  const homeAssistant = libs
201
201
  .flat()
202
202
  .map((f) => f.match(/homeassistant-(.*)\.dist-info/))
@@ -241,7 +241,7 @@ class HomeAssistant {
241
241
  return `${this.url}/${path}?auth_callback=1&code=${encodeURIComponent(code)}&state=${encodeURIComponent(state)}`;
242
242
  }
243
243
  async post(url, body, authorize = false) {
244
- const response = await node_fetch_1.default(this.url + url, {
244
+ const response = await (0, node_fetch_1.default)(this.url + url, {
245
245
  method: 'post',
246
246
  headers: {
247
247
  'Content-Type': 'application/json',
@@ -249,7 +249,7 @@ class HomeAssistant {
249
249
  },
250
250
  body: JSON.stringify({ client_id: this.clientId, ...body }),
251
251
  });
252
- return await response.json();
252
+ return (await response.json());
253
253
  }
254
254
  /** Fetch a access code from username and password */
255
255
  async fetchLoginCode() {
@@ -273,11 +273,11 @@ class HomeAssistant {
273
273
  params.append('client_id', this.clientId);
274
274
  params.append('code', code);
275
275
  params.append('grant_type', 'authorization_code');
276
- const response = await node_fetch_1.default(this.url + '/auth/token', {
276
+ const response = await (0, node_fetch_1.default)(this.url + '/auth/token', {
277
277
  method: 'post',
278
278
  body: params,
279
279
  });
280
- const tokens = await response.json();
280
+ const tokens = (await response.json());
281
281
  this.accessToken = tokens.access_token;
282
282
  const auth = new hass.Auth({
283
283
  ...tokens,
@@ -286,7 +286,7 @@ class HomeAssistant {
286
286
  });
287
287
  this.ws = await hass.createConnection({
288
288
  auth,
289
- createSocket: async () => socket_1.createSocket(auth, false),
289
+ createSocket: async () => (0, socket_1.createSocket)(auth, false),
290
290
  });
291
291
  }
292
292
  async addIntegration(name) {
@@ -300,7 +300,7 @@ class HomeAssistant {
300
300
  }
301
301
  async addResource(filename, resourceType) {
302
302
  if (resourceType === 'module') {
303
- await fs.copyFile(filename, path_1.join(this.path_wwwDir(), path_1.basename(filename)));
303
+ await fs.copyFile(filename, (0, path_1.join)(this.path_wwwDir(), (0, path_1.basename)(filename)));
304
304
  }
305
305
  else {
306
306
  throw new Error('Only the module type is supported for now');
@@ -308,7 +308,7 @@ class HomeAssistant {
308
308
  await this.ws.sendMessagePromise({
309
309
  type: 'lovelace/resources/create',
310
310
  res_type: resourceType,
311
- url: '/local/' + path_1.basename(filename),
311
+ url: '/local/' + (0, path_1.basename)(filename),
312
312
  });
313
313
  }
314
314
  async createDashboard(options) {
@@ -6,6 +6,7 @@
6
6
  const DEFAULT_IGNORE_TAGS = ['script', 'style'];
7
7
  const DEFAULT_IGNORE_SHADOW_CHILDREN = [
8
8
  'ha-icon',
9
+ 'ha-state-icon',
9
10
  'ha-slider',
10
11
  'mwc-button',
11
12
  'paper-input', // Polymer elements
@@ -94,7 +95,8 @@ function getDiffableHTML(container, options) {
94
95
  children = [...node.childNodes];
95
96
  if (!ignoreShadowChildren.includes(tag) && node instanceof Element && node.shadowRoot)
96
97
  children = [...node.shadowRoot.childNodes, ...children];
97
- return children.filter((node) => node.nodeType == Node.ELEMENT_NODE || node.nodeType == Node.TEXT_NODE);
98
+ return children.filter((node) => node.nodeType == Node.ELEMENT_NODE ||
99
+ (node.nodeType == Node.TEXT_NODE && node.textContent?.trim()));
98
100
  }
99
101
  /** An element's classList, sorted, as string */
100
102
  function getClassListValueString(el) {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PlaywrightPage = exports.PlaywrightBrowser = void 0;
4
4
  const playwright_1 = require("playwright");
5
5
  const fs_1 = require("fs");
6
- const htmlScript = fs_1.readFileSync(__dirname + '/../../lib/integrations/get-diffable-html.js', 'utf-8');
6
+ const htmlScript = (0, fs_1.readFileSync)(__dirname + '/../../lib/integrations/get-diffable-html.js', 'utf-8');
7
7
  class PlaywrightBrowser {
8
8
  static browsers = { chromium: playwright_1.chromium, webkit: playwright_1.webkit, firefox: playwright_1.firefox };
9
9
  browserName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hass-taste-test",
3
- "version": "0.0.10",
3
+ "version": "0.0.14",
4
4
  "description": "Integration testing for Home Assistant cards",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -14,26 +14,26 @@
14
14
  "homepage": "https://github.com/rianadon/hass-taste-test#readme",
15
15
  "license": "AGPL-3.0-or-later",
16
16
  "dependencies": {
17
- "home-assistant-js-websocket": "^5.10.0",
17
+ "home-assistant-js-websocket": "^5.11.1",
18
18
  "node-fetch": "^2.6.1",
19
19
  "proper-lockfile": "^4.1.2"
20
20
  },
21
21
  "devDependencies": {
22
- "@types/jest": "^26.0.23",
23
- "@types/jest-image-snapshot": "^4.3.0",
22
+ "@types/jest": "^27.0.2",
23
+ "@types/jest-image-snapshot": "^4.3.1",
24
24
  "@types/node-fetch": "^2.5.10",
25
- "@types/proper-lockfile": "^4.1.1",
26
- "@types/ws": "^7.4.6",
25
+ "@types/proper-lockfile": "^4.1.2",
26
+ "@types/ws": "^8.2.0",
27
27
  "ava": "^3.15.0",
28
- "husky": "^7.0.0",
29
- "jest": "^27.0.6",
28
+ "husky": "^7.0.2",
29
+ "jest": "^27.2.5",
30
30
  "jest-image-snapshot": "^4.5.1",
31
- "lint-staged": "^11.0.0",
32
- "playwright": "^1.12.3",
33
- "prettier": "^2.3.2",
34
- "ts-jest": "^27.0.3",
35
- "ts-node": "^10.0.0",
36
- "typescript": "^4.3.5"
31
+ "lint-staged": "^11.2.3",
32
+ "playwright": "^1.15.2",
33
+ "prettier": "^2.4.1",
34
+ "ts-jest": "^27.0.5",
35
+ "ts-node": "^10.2.1",
36
+ "typescript": "^4.4.3"
37
37
  },
38
38
  "prettier": {
39
39
  "printWidth": 100,