@ons/design-system 58.0.1 → 58.0.2

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.
@@ -33,6 +33,9 @@ export default class Modal {
33
33
  if (this.modalType !== 'Timeout') {
34
34
  window.addEventListener('keydown', this.escToClose.bind(this));
35
35
  }
36
+ this.component.setAttribute('data-ga-action', `Modal initialised`);
37
+ this.component.setAttribute('data-ga-label', `${this.modalType} modal initialised`);
38
+ this.component.setAttribute('data-ga-category', `${this.modalType} modal`);
36
39
  }
37
40
 
38
41
  dialogSupported() {
@@ -75,7 +78,6 @@ export default class Modal {
75
78
  this.component.setAttribute('data-ga-action', 'Modal opened by timed event');
76
79
  }
77
80
  this.component.setAttribute('data-ga-label', `${this.modalType} modal opened`);
78
- this.component.setAttribute('data-ga-category', `${this.modalType} modal`);
79
81
  }
80
82
  }
81
83
  }
@@ -121,7 +123,6 @@ export default class Modal {
121
123
  this.component.setAttribute('data-ga-action', 'Modal closed by timed event');
122
124
  }
123
125
  this.component.setAttribute('data-ga-label', `${this.modalType} modal closed`);
124
- this.component.setAttribute('data-ga-category', `${this.modalType} modal`);
125
126
  }
126
127
  }
127
128
  }
@@ -82,6 +82,17 @@ describe('script: modal', () => {
82
82
  await setTestPage('/test', template);
83
83
  });
84
84
 
85
+ describe('when the page has been loaded but the modal has not been opened yet', () => {
86
+ it('has the correct attributes set on the modal', async () => {
87
+ const gaLabel = await page.$eval('.ons-modal', node => node.getAttribute('data-ga-label'));
88
+ const gaAction = await page.$eval('.ons-modal', node => node.getAttribute('data-ga-action'));
89
+ const gaCategory = await page.$eval('.ons-modal', node => node.getAttribute('data-ga-category'));
90
+ expect(gaLabel).toBe('Generic modal initialised');
91
+ expect(gaAction).toBe('Modal initialised');
92
+ expect(gaCategory).toBe('Generic modal');
93
+ });
94
+ });
95
+
85
96
  describe('when the modal is launched by a click event', () => {
86
97
  beforeEach(async () => {
87
98
  await page.focus('#launcher');
@@ -241,6 +241,17 @@ describe('script: timeout modal', () => {
241
241
  await setTestPage('/test', template);
242
242
  });
243
243
 
244
+ describe('when the page has been loaded but the modal has not been opened yet', () => {
245
+ it('has the correct attributes set on the modal', async () => {
246
+ const gaLabel = await page.$eval('.ons-modal', node => node.getAttribute('data-ga-label'));
247
+ const gaAction = await page.$eval('.ons-modal', node => node.getAttribute('data-ga-action'));
248
+ const gaCategory = await page.$eval('.ons-modal', node => node.getAttribute('data-ga-category'));
249
+ expect(gaLabel).toBe('Timeout modal initialised');
250
+ expect(gaAction).toBe('Modal initialised');
251
+ expect(gaCategory).toBe('Timeout modal');
252
+ });
253
+ });
254
+
244
255
  describe('when the modal is open', () => {
245
256
  beforeEach(async () => {
246
257
  await page.waitForSelector('.ons-modal');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ons/design-system",
3
3
  "description": "ONS Design System built CSS, JS, and Nunjucks templates",
4
- "version": "58.0.1",
4
+ "version": "58.0.2",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
7
7
  "author": {