hass-taste-test 0.2.0 → 0.2.1

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.d.ts CHANGED
@@ -77,6 +77,7 @@ export declare class HomeAssistant<E> {
77
77
  cards: HassCard<E>[];
78
78
  parent: HomeAssistant<E>;
79
79
  path: string;
80
+ page: BrowserPage<E>;
80
81
  link(): Promise<string>;
81
82
  openInBrowser(): Promise<void>;
82
83
  }>;
@@ -87,6 +88,7 @@ export declare class HomeAssistant<E> {
87
88
  cards: HassCard<E>[];
88
89
  parent: HomeAssistant<E>;
89
90
  path: string;
91
+ page: BrowserPage<E>;
90
92
  link(): Promise<string>;
91
93
  openInBrowser(): Promise<void>;
92
94
  };
package/lib/index.js CHANGED
@@ -352,8 +352,8 @@ class HomeAssistant {
352
352
  mode: 'storage',
353
353
  require_admin: false,
354
354
  show_in_sidebar: true,
355
- title: `Dashboard ${id}`,
356
355
  ...options,
356
+ title: options?.title || `Dashboard ${id}`,
357
357
  };
358
358
  await this.ws.sendMessagePromise(args);
359
359
  return args.url_path;
@@ -376,7 +376,7 @@ class HomeAssistant {
376
376
  async Dashboard(config, options) {
377
377
  if (!this.options.browser)
378
378
  throw new Error('Cannot launch a dashboard without a browser integration. Make sure to specify options.integration');
379
- const dashboard = await this.createDashboard();
379
+ const dashboard = await this.createDashboard({ title: options?.title });
380
380
  await this.setDashboardView(dashboard, config);
381
381
  const code = await this.fetchLoginCode();
382
382
  const page = await this.options.browser.open(this.customDashboard(dashboard, code), options || {});
@@ -398,10 +398,12 @@ class HomeAssistant {
398
398
  HassDashboard = class {
399
399
  parent;
400
400
  path;
401
+ page;
401
402
  cards = [];
402
403
  constructor(parent, path, config, page) {
403
404
  this.parent = parent;
404
405
  this.path = path;
406
+ this.page = page;
405
407
  for (let i = 0; i < config.length; i++) {
406
408
  this.cards.push(new HassCard(i, page));
407
409
  }
@@ -20,4 +20,5 @@ export declare class PlaywrightPage implements BrowserPage<PlaywrightElement> {
20
20
  screenshot(element: PlaywrightElement): Promise<Buffer>;
21
21
  find(element: PlaywrightElement, selector: string): Promise<ElementHandle<SVGElement | HTMLElement> | null>;
22
22
  textContent(element: PlaywrightElement): Promise<string>;
23
+ get playwright(): Page;
23
24
  }
@@ -68,5 +68,8 @@ class PlaywrightPage {
68
68
  throw new Error('Element has no textcontent');
69
69
  return content;
70
70
  }
71
+ get playwright() {
72
+ return this.page;
73
+ }
71
74
  }
72
75
  exports.PlaywrightPage = PlaywrightPage;
package/lib/types.d.ts CHANGED
@@ -23,6 +23,7 @@ export interface DiffOptions {
23
23
  }
24
24
  export type DashboardOptions = Partial<{
25
25
  colorScheme: 'light' | 'dark' | 'no-preference';
26
+ title: string;
26
27
  }>;
27
28
  export interface BrowserIntegration<E> {
28
29
  open(url: string, options: DashboardOptions): Promise<BrowserPage<E>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hass-taste-test",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Integration testing for Home Assistant cards",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {