@oslokommune/punkt-elements 13.5.2 → 13.5.3
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/CHANGELOG.md +17 -0
- package/dist/{alert-DQNBDKjT.cjs → alert-7rUOhlNi.cjs} +2 -1
- package/dist/{alert-B07oUpkq.js → alert-cUBtwi2k.js} +12 -11
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +1 -1
- package/package.json +6 -2
- package/src/components/alert/alert.test.ts +64 -79
- package/src/components/alert/alert.ts +1 -0
- package/src/components/backlink/backlink.test.ts +50 -96
- package/src/components/button/button.test.ts +211 -249
- package/src/components/calendar/calendar.accessibility.test.ts +30 -43
- package/src/components/card/card.test.ts +71 -121
- package/src/components/checkbox/checkbox.test.ts +231 -156
- package/src/components/consent/consent.test.ts +87 -91
- package/src/components/icon/icon.test.ts +368 -0
- package/src/components/input-wrapper/input-wrapper.test.ts +505 -0
- package/src/components/link/link.test.ts +224 -0
- package/src/components/linkcard/linkcard.test.ts +14 -12
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [13.5.3](https://github.com/oslokommune/punkt/compare/13.5.2...13.5.3) (2025-09-08)
|
|
9
|
+
|
|
10
|
+
### ⚠ BREAKING CHANGES
|
|
11
|
+
Ingen
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
Ingen
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
Ingen
|
|
18
|
+
|
|
19
|
+
### Chores
|
|
20
|
+
Ingen
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
|
|
8
25
|
## [13.5.2](https://github.com/oslokommune/punkt/compare/13.5.1...13.5.2) (2025-09-08)
|
|
9
26
|
|
|
10
27
|
### ⚠ BREAKING CHANGES
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const c=require("./class-map-BBG2gMX4.cjs"),t=require("./element-6DBpyGQm.cjs"),d=require("./state-DPobt-Yz.cjs"),h=require("./pkt-slot-controller-BzddBp7z.cjs"),u=require("./ref-iJtiv3o2.cjs"),k=require("./classutils-BwNK82ZQ.cjs");require("./icon-B_ryAy4Q.cjs");require("./button-B8rdtaHB.cjs");const v={skin:{default:"info"},ariaLive:{default:"polite"},compact:{default:!1},closeAlert:{default:!1}},a={props:v};var f=Object.defineProperty,_=Object.getOwnPropertyDescriptor,i=(o,e,s,
|
|
1
|
+
"use strict";const c=require("./class-map-BBG2gMX4.cjs"),t=require("./element-6DBpyGQm.cjs"),d=require("./state-DPobt-Yz.cjs"),h=require("./pkt-slot-controller-BzddBp7z.cjs"),u=require("./ref-iJtiv3o2.cjs"),k=require("./classutils-BwNK82ZQ.cjs");require("./icon-B_ryAy4Q.cjs");require("./button-B8rdtaHB.cjs");const v={skin:{default:"info"},ariaLive:{default:"polite"},compact:{default:!1},closeAlert:{default:!1}},a={props:v};var f=Object.defineProperty,_=Object.getOwnPropertyDescriptor,i=(o,e,s,l)=>{for(var r=l>1?void 0:l?_(e,s):e,p=o.length-1,n;p>=0;p--)(n=o[p])&&(r=(l?n(e,s,r):n(r))||r);return l&&r&&f(e,s,r),r};exports.PktAlert=class extends t.PktElement{constructor(){super(),this.defaultSlot=u.e(),this.compact=a.props.compact.default,this.title="",this.skin=a.props.skin.default,this.ariaLive=a.props.ariaLive.default,this["aria-live"]=null,this.closeAlert=a.props.closeAlert.default,this.date=null,this.role="status",this._isClosed=!1,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent("close",{detail:{origin:e},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("on-close",{detail:{origin:e},bubbles:!0,composed:!0}))},this.slotController=new h.PktSlotController(this,this.defaultSlot),this._isClosed=!1}connectedCallback(){super.connectedCallback(),this["aria-live"]=this.getAttribute("aria-live")||this.ariaLive}attributeChangedCallback(e,s,l){e==="ariaLive"&&(this["aria-live"]=l),super.attributeChangedCallback(e,s,l)}updated(e){super.updated(e),e.has("ariaLive")&&(this["aria-live"]=this.ariaLive),e.has("_isClosed")&&k.updateClassAttribute(this,"pkt-hide",this._isClosed)}render(){const e={"pkt-alert":!0,"pkt-alert--compact":this.compact,[`pkt-alert--${this.skin}`]:this.skin,"pkt-hide":this._isClosed},s={"pkt-alert__grid":!0,"pkt-alert__noTitle":!this.title,"pkt-alert__noDate":!this.date};return t.x`
|
|
2
2
|
<div class=${c.e(e)} aria-live=${this["aria-live"]}>
|
|
3
3
|
<div class=${c.e(s)}>
|
|
4
4
|
<pkt-icon
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
variant="icon-only"
|
|
20
20
|
@click=${this.close}
|
|
21
21
|
>
|
|
22
|
+
<span class="sr-only">Lukk</span>
|
|
22
23
|
</pkt-button>
|
|
23
24
|
</div>
|
|
24
25
|
`:t.E}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { e as
|
|
2
|
-
import { P as f, E as
|
|
3
|
-
import { r as
|
|
4
|
-
import { P as
|
|
1
|
+
import { e as h } from "./class-map-BpTj9gtz.js";
|
|
2
|
+
import { P as f, E as u, x as p, n as a, a as v } from "./element-CgEWt74-.js";
|
|
3
|
+
import { r as k } from "./state-Bo2bck5_.js";
|
|
4
|
+
import { P as m } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
5
5
|
import { e as _, n as b } from "./ref-BBYSqgeW.js";
|
|
6
6
|
import { u as y } from "./classutils-RQs1k6D9.js";
|
|
7
7
|
import "./icon-CC1js8eR.js";
|
|
@@ -35,7 +35,7 @@ let e = class extends f {
|
|
|
35
35
|
), this.dispatchEvent(
|
|
36
36
|
new CustomEvent("on-close", { detail: { origin: t }, bubbles: !0, composed: !0 })
|
|
37
37
|
);
|
|
38
|
-
}, this.slotController = new
|
|
38
|
+
}, this.slotController = new m(this, this.defaultSlot), this._isClosed = !1;
|
|
39
39
|
}
|
|
40
40
|
// Lifecycle
|
|
41
41
|
connectedCallback() {
|
|
@@ -60,8 +60,8 @@ let e = class extends f {
|
|
|
60
60
|
"pkt-alert__noDate": !this.date
|
|
61
61
|
};
|
|
62
62
|
return p`
|
|
63
|
-
<div class=${
|
|
64
|
-
<div class=${
|
|
63
|
+
<div class=${h(t)} aria-live=${this["aria-live"]}>
|
|
64
|
+
<div class=${h(s)}>
|
|
65
65
|
<pkt-icon
|
|
66
66
|
class="pkt-alert__icon"
|
|
67
67
|
aria-hidden="true"
|
|
@@ -80,14 +80,15 @@ let e = class extends f {
|
|
|
80
80
|
variant="icon-only"
|
|
81
81
|
@click=${this.close}
|
|
82
82
|
>
|
|
83
|
+
<span class="sr-only">Lukk</span>
|
|
83
84
|
</pkt-button>
|
|
84
85
|
</div>
|
|
85
|
-
` :
|
|
86
|
-
${this.title ? p`<div class="pkt-alert__title">${this.title}</div>` :
|
|
86
|
+
` : u}
|
|
87
|
+
${this.title ? p`<div class="pkt-alert__title">${this.title}</div>` : u}
|
|
87
88
|
|
|
88
89
|
<div class="pkt-alert__text" ${b(this.defaultSlot)}></div>
|
|
89
90
|
|
|
90
|
-
${this.date ? p`<div class="pkt-alert__date">Sist oppdatert: ${this.date}</div>` :
|
|
91
|
+
${this.date ? p`<div class="pkt-alert__date">Sist oppdatert: ${this.date}</div>` : u}
|
|
91
92
|
</div>
|
|
92
93
|
</div>
|
|
93
94
|
`;
|
|
@@ -118,7 +119,7 @@ i([
|
|
|
118
119
|
a({ type: String, reflect: !0 })
|
|
119
120
|
], e.prototype, "role", 2);
|
|
120
121
|
i([
|
|
121
|
-
|
|
122
|
+
k()
|
|
122
123
|
], e.prototype, "_isClosed", 2);
|
|
123
124
|
e = i([
|
|
124
125
|
v("pkt-alert")
|
package/dist/pkt-alert.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./alert-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./alert-7rUOhlNi.cjs"),t=e.PktAlert;Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>e.PktAlert});exports.default=t;
|
package/dist/pkt-alert.js
CHANGED
package/dist/pkt-index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./alert-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./alert-7rUOhlNi.cjs"),l=require("./accordionitem-Csh7iSVG.cjs"),d=require("./backlink-JbBNi3qg.cjs"),b=require("./button-B8rdtaHB.cjs"),k=require("./calendar-32W9p9uc.cjs"),m=require("./card-DBlFf1ry.cjs"),g=require("./combobox-DjO0RMUB.cjs"),h=require("./consent-hYeFWNFr.cjs"),f=require("./checkbox-Gn7Wtk9h.cjs"),t=require("./element-6DBpyGQm.cjs"),y=require("./pkt-slot-controller-BzddBp7z.cjs"),s=require("./ref-iJtiv3o2.cjs"),O=require("./class-map-BBG2gMX4.cjs"),j=require("./datepicker-CmTrG5GE.cjs"),q=require("./helptext-CzQX6YVE.cjs"),x=require("./heading-CNycsyMj.cjs"),C=require("./icon-B_ryAy4Q.cjs"),v=require("./input-wrapper-CZ-a00V7.cjs"),S=require("./link-Cjl0xwSq.cjs"),$=require("./linkcard-DqIvb54H.cjs"),L=require("./loader-CHPxY9c6.cjs"),_=require("./messagebox-CqUBJs_D.cjs"),A=require("./modal-CRtxhCaP.cjs"),B=require("./progressbar-DhMBXkww.cjs"),p=require("./radiobutton-CdT6v1oq.cjs"),T=require("./tag-Bbs0U_Au.cjs"),I=require("./textarea-CPXsMFUq.cjs"),M=require("./textinput-aNI5kibM.cjs"),R=require("./select-Dkl0KhGW.cjs");var H=Object.defineProperty,w=Object.getOwnPropertyDescriptor,o=(a,e,r,i)=>{for(var n=i>1?void 0:i?w(e,r):e,u=a.length-1,c;u>=0;u--)(c=a[u])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&H(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=s.e(),this.namedSlot=s.e(),this.slotController=new y.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
|
|
2
2
|
<div class="${O.e(e)}">
|
|
3
3
|
<h1 class="pkt-txt-28">${this.string}</h1>
|
|
4
4
|
|
package/dist/pkt-index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "13.5.
|
|
3
|
+
"version": "13.5.3",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -35,7 +35,11 @@
|
|
|
35
35
|
"whatwg-fetch": "^3.6.19"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
+
"@babel/plugin-transform-class-properties": "^7.25.9",
|
|
39
|
+
"@babel/plugin-transform-private-methods": "^7.25.9",
|
|
40
|
+
"@babel/plugin-transform-private-property-in-object": "^7.25.9",
|
|
38
41
|
"@babel/preset-env": "^7.28.3",
|
|
42
|
+
"@babel/preset-typescript": "^7.25.9",
|
|
39
43
|
"@oslokommune/punkt-assets": "^13.3.1",
|
|
40
44
|
"@oslokommune/punkt-css": "^13.5.0",
|
|
41
45
|
"@testing-library/jest-dom": "^6.6.3",
|
|
@@ -69,5 +73,5 @@
|
|
|
69
73
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
70
74
|
},
|
|
71
75
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "6b43945924c71b96b609f1abc7875e139e297233"
|
|
73
77
|
}
|
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
import '@testing-library/jest-dom'
|
|
2
2
|
import { axe, toHaveNoViolations } from 'jest-axe'
|
|
3
3
|
import { fireEvent } from '@testing-library/dom'
|
|
4
|
+
import { createElementTest, BaseTestConfig } from '../../tests/test-framework'
|
|
5
|
+
import { CustomElementFor } from '../../tests/component-registry'
|
|
6
|
+
import './alert'
|
|
4
7
|
|
|
5
8
|
expect.extend(toHaveNoViolations)
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export interface AlertTestConfig extends BaseTestConfig {
|
|
11
|
+
skin?: string
|
|
12
|
+
compact?: boolean
|
|
13
|
+
title?: string
|
|
14
|
+
date?: string
|
|
15
|
+
closeAlert?: boolean
|
|
16
|
+
ariaLive?: string
|
|
12
17
|
}
|
|
13
18
|
|
|
14
|
-
//
|
|
15
|
-
const
|
|
16
|
-
const container =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
// Use shared framework
|
|
20
|
+
export const createAlertTest = async (config: AlertTestConfig = {}) => {
|
|
21
|
+
const { container, element } = await createElementTest<
|
|
22
|
+
CustomElementFor<'pkt-alert'>,
|
|
23
|
+
AlertTestConfig
|
|
24
|
+
>('pkt-alert', config)
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
container,
|
|
28
|
+
alert: element,
|
|
29
|
+
}
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
// Cleanup after each test
|
|
@@ -32,11 +37,11 @@ afterEach(() => {
|
|
|
32
37
|
describe('PktAlert', () => {
|
|
33
38
|
describe('Rendering and basic functionality', () => {
|
|
34
39
|
test('renders without errors', async () => {
|
|
35
|
-
const
|
|
40
|
+
const { alert } = await createAlertTest({
|
|
41
|
+
content: 'Test alert content',
|
|
42
|
+
})
|
|
36
43
|
|
|
37
|
-
const alert = container.querySelector('pkt-alert') as PktAlert
|
|
38
44
|
expect(alert).toBeInTheDocument()
|
|
39
|
-
|
|
40
45
|
await alert.updateComplete
|
|
41
46
|
expect(alert).toBeTruthy()
|
|
42
47
|
|
|
@@ -45,9 +50,11 @@ describe('PktAlert', () => {
|
|
|
45
50
|
})
|
|
46
51
|
|
|
47
52
|
test('renders with correct structure', async () => {
|
|
48
|
-
const
|
|
53
|
+
const { alert } = await createAlertTest({
|
|
54
|
+
title: 'Test Title',
|
|
55
|
+
content: 'Test alert message',
|
|
56
|
+
})
|
|
49
57
|
|
|
50
|
-
const alert = container.querySelector('pkt-alert') as PktAlert
|
|
51
58
|
await alert.updateComplete
|
|
52
59
|
|
|
53
60
|
const alertDiv = alert.querySelector('.pkt-alert')
|
|
@@ -68,8 +75,7 @@ describe('PktAlert', () => {
|
|
|
68
75
|
const skins = ['error', 'success', 'warning', 'info'] as const
|
|
69
76
|
|
|
70
77
|
for (const skin of skins) {
|
|
71
|
-
const
|
|
72
|
-
const alert = container.querySelector('pkt-alert') as PktAlert
|
|
78
|
+
const { alert } = await createAlertTest({ skin })
|
|
73
79
|
await alert.updateComplete
|
|
74
80
|
|
|
75
81
|
const icon = alert.querySelector('pkt-icon')
|
|
@@ -77,18 +83,14 @@ describe('PktAlert', () => {
|
|
|
77
83
|
|
|
78
84
|
expect(icon?.getAttribute('name')).toBe(expectedIconName)
|
|
79
85
|
expect(icon?.getAttribute('aria-hidden')).toBe('true')
|
|
80
|
-
|
|
81
|
-
// Cleanup for next iteration
|
|
82
|
-
container.remove()
|
|
83
86
|
}
|
|
84
87
|
})
|
|
85
88
|
})
|
|
86
89
|
|
|
87
90
|
describe('Properties and attributes', () => {
|
|
88
91
|
test('applies default properties correctly', async () => {
|
|
89
|
-
const
|
|
92
|
+
const { alert } = await createAlertTest()
|
|
90
93
|
|
|
91
|
-
const alert = container.querySelector('pkt-alert') as PktAlert
|
|
92
94
|
await alert.updateComplete
|
|
93
95
|
|
|
94
96
|
expect(alert.skin).toBe('info')
|
|
@@ -108,8 +110,7 @@ describe('PktAlert', () => {
|
|
|
108
110
|
const skins = ['error', 'success', 'warning', 'info'] as const
|
|
109
111
|
|
|
110
112
|
for (const skin of skins) {
|
|
111
|
-
const
|
|
112
|
-
const alert = container.querySelector('pkt-alert') as PktAlert
|
|
113
|
+
const { alert } = await createAlertTest({ skin })
|
|
113
114
|
await alert.updateComplete
|
|
114
115
|
|
|
115
116
|
expect(alert.skin).toBe(skin)
|
|
@@ -117,16 +118,12 @@ describe('PktAlert', () => {
|
|
|
117
118
|
|
|
118
119
|
const alertDiv = alert.querySelector('.pkt-alert')
|
|
119
120
|
expect(alertDiv).toHaveClass(`pkt-alert--${skin}`)
|
|
120
|
-
|
|
121
|
-
// Cleanup for next iteration
|
|
122
|
-
container.remove()
|
|
123
121
|
}
|
|
124
122
|
})
|
|
125
123
|
|
|
126
124
|
test('applies compact property correctly', async () => {
|
|
127
|
-
const
|
|
125
|
+
const { alert } = await createAlertTest({ compact: true })
|
|
128
126
|
|
|
129
|
-
const alert = container.querySelector('pkt-alert') as PktAlert
|
|
130
127
|
await alert.updateComplete
|
|
131
128
|
|
|
132
129
|
expect(alert.compact).toBe(true)
|
|
@@ -136,9 +133,8 @@ describe('PktAlert', () => {
|
|
|
136
133
|
})
|
|
137
134
|
|
|
138
135
|
test('handles title property', async () => {
|
|
139
|
-
const
|
|
136
|
+
const { alert } = await createAlertTest({ title: 'Alert Title' })
|
|
140
137
|
|
|
141
|
-
const alert = container.querySelector('pkt-alert') as PktAlert
|
|
142
138
|
await alert.updateComplete
|
|
143
139
|
|
|
144
140
|
expect(alert.title).toBe('Alert Title')
|
|
@@ -156,9 +152,8 @@ describe('PktAlert', () => {
|
|
|
156
152
|
})
|
|
157
153
|
|
|
158
154
|
test('handles date property', async () => {
|
|
159
|
-
const
|
|
155
|
+
const { alert } = await createAlertTest({ date: '2024-01-15' })
|
|
160
156
|
|
|
161
|
-
const alert = container.querySelector('pkt-alert') as PktAlert
|
|
162
157
|
await alert.updateComplete
|
|
163
158
|
|
|
164
159
|
expect(alert.date).toBe('2024-01-15')
|
|
@@ -170,25 +165,22 @@ describe('PktAlert', () => {
|
|
|
170
165
|
})
|
|
171
166
|
|
|
172
167
|
test('handles aria-live property', async () => {
|
|
173
|
-
const
|
|
168
|
+
const { alert } = await createAlertTest({ ariaLive: 'assertive' })
|
|
174
169
|
|
|
175
|
-
const alert = container.querySelector('pkt-alert') as PktAlert
|
|
176
170
|
await alert.updateComplete
|
|
177
171
|
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
expect(alert['aria-live']).toBe('polite')
|
|
172
|
+
// The component uses the ariaLive property value that was set
|
|
173
|
+
expect(alert['aria-live']).toBe('assertive')
|
|
181
174
|
|
|
182
175
|
const alertDiv = alert.querySelector('.pkt-alert')
|
|
183
|
-
expect(alertDiv?.getAttribute('aria-live')).toBe('
|
|
176
|
+
expect(alertDiv?.getAttribute('aria-live')).toBe('assertive')
|
|
184
177
|
})
|
|
185
178
|
})
|
|
186
179
|
|
|
187
180
|
describe('Close functionality', () => {
|
|
188
181
|
test('renders close button when closeAlert is true', async () => {
|
|
189
|
-
const
|
|
182
|
+
const { alert } = await createAlertTest({ closeAlert: true })
|
|
190
183
|
|
|
191
|
-
const alert = container.querySelector('pkt-alert') as PktAlert
|
|
192
184
|
await alert.updateComplete
|
|
193
185
|
|
|
194
186
|
expect(alert.closeAlert).toBe(true)
|
|
@@ -204,9 +196,8 @@ describe('PktAlert', () => {
|
|
|
204
196
|
})
|
|
205
197
|
|
|
206
198
|
test('does not render close button when closeAlert is false', async () => {
|
|
207
|
-
const
|
|
199
|
+
const { alert } = await createAlertTest({ closeAlert: false })
|
|
208
200
|
|
|
209
|
-
const alert = container.querySelector('pkt-alert') as PktAlert
|
|
210
201
|
await alert.updateComplete
|
|
211
202
|
|
|
212
203
|
expect(alert.closeAlert).toBe(false)
|
|
@@ -219,9 +210,8 @@ describe('PktAlert', () => {
|
|
|
219
210
|
})
|
|
220
211
|
|
|
221
212
|
test('closes alert when close button is clicked', async () => {
|
|
222
|
-
const
|
|
213
|
+
const { alert } = await createAlertTest({ closeAlert: true })
|
|
223
214
|
|
|
224
|
-
const alert = container.querySelector('pkt-alert') as PktAlert
|
|
225
215
|
await alert.updateComplete
|
|
226
216
|
|
|
227
217
|
// Listen for close events
|
|
@@ -265,30 +255,23 @@ describe('PktAlert', () => {
|
|
|
265
255
|
describe('Grid layout classes', () => {
|
|
266
256
|
test('applies correct grid classes based on content', async () => {
|
|
267
257
|
// Test with no title and no date
|
|
268
|
-
const
|
|
269
|
-
const alert1 = container1.querySelector('pkt-alert') as PktAlert
|
|
258
|
+
const { alert: alert1 } = await createAlertTest()
|
|
270
259
|
await alert1.updateComplete
|
|
271
260
|
|
|
272
261
|
const grid1 = alert1.querySelector('.pkt-alert__grid')
|
|
273
262
|
expect(grid1).toHaveClass('pkt-alert__noTitle')
|
|
274
263
|
expect(grid1).toHaveClass('pkt-alert__noDate')
|
|
275
264
|
|
|
276
|
-
container1.remove()
|
|
277
|
-
|
|
278
265
|
// Test with title but no date
|
|
279
|
-
const
|
|
280
|
-
const alert2 = container2.querySelector('pkt-alert') as PktAlert
|
|
266
|
+
const { alert: alert2 } = await createAlertTest({ title: 'Test Title' })
|
|
281
267
|
await alert2.updateComplete
|
|
282
268
|
|
|
283
269
|
const grid2 = alert2.querySelector('.pkt-alert__grid')
|
|
284
270
|
expect(grid2).not.toHaveClass('pkt-alert__noTitle')
|
|
285
271
|
expect(grid2).toHaveClass('pkt-alert__noDate')
|
|
286
272
|
|
|
287
|
-
container2.remove()
|
|
288
|
-
|
|
289
273
|
// Test with both title and date
|
|
290
|
-
const
|
|
291
|
-
const alert3 = container3.querySelector('pkt-alert') as PktAlert
|
|
274
|
+
const { alert: alert3 } = await createAlertTest({ title: 'Test Title', date: '2024-01-15' })
|
|
292
275
|
await alert3.updateComplete
|
|
293
276
|
|
|
294
277
|
const grid3 = alert3.querySelector('.pkt-alert__grid')
|
|
@@ -299,47 +282,49 @@ describe('PktAlert', () => {
|
|
|
299
282
|
|
|
300
283
|
describe('Accessibility', () => {
|
|
301
284
|
test('has correct ARIA attributes', async () => {
|
|
302
|
-
const
|
|
285
|
+
const { alert } = await createAlertTest({ ariaLive: 'polite' })
|
|
303
286
|
|
|
304
|
-
const alert = container.querySelector('pkt-alert') as PktAlert
|
|
305
287
|
await alert.updateComplete
|
|
306
288
|
|
|
307
289
|
const alertDiv = alert.querySelector('.pkt-alert')
|
|
308
290
|
const icon = alert.querySelector('pkt-icon')
|
|
309
291
|
|
|
310
292
|
expect(alertDiv?.getAttribute('aria-live')).toBe('polite')
|
|
311
|
-
expect(alert.role).toBe('
|
|
293
|
+
expect(alert.role).toBe('status')
|
|
312
294
|
expect(icon?.getAttribute('aria-hidden')).toBe('true')
|
|
313
295
|
})
|
|
314
296
|
|
|
315
297
|
test('renders with no WCAG errors with axe - simple alert', async () => {
|
|
316
|
-
const container = await
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
298
|
+
const { container } = await createAlertTest({
|
|
299
|
+
title: 'Test Alert',
|
|
300
|
+
content: 'This is a test alert message.',
|
|
301
|
+
})
|
|
320
302
|
|
|
321
303
|
const results = await axe(container)
|
|
322
304
|
expect(results).toHaveNoViolations()
|
|
323
305
|
})
|
|
324
306
|
|
|
325
307
|
test('renders with no WCAG errors with axe - complex alert', async () => {
|
|
326
|
-
const container = await
|
|
327
|
-
|
|
328
|
-
'
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
308
|
+
const { container } = await createAlertTest({
|
|
309
|
+
skin: 'error',
|
|
310
|
+
title: 'Error Alert',
|
|
311
|
+
date: '2024-01-15',
|
|
312
|
+
closeAlert: true,
|
|
313
|
+
ariaLive: 'assertive',
|
|
314
|
+
content: '<p>This is an error message with <a href="#">a link</a>.</p>',
|
|
315
|
+
})
|
|
333
316
|
|
|
334
317
|
const results = await axe(container)
|
|
335
318
|
expect(results).toHaveNoViolations()
|
|
336
319
|
})
|
|
337
320
|
|
|
338
321
|
test('renders with no WCAG errors with axe - compact alert', async () => {
|
|
339
|
-
const container = await
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
322
|
+
const { container } = await createAlertTest({
|
|
323
|
+
skin: 'success',
|
|
324
|
+
compact: true,
|
|
325
|
+
closeAlert: true,
|
|
326
|
+
content: 'Success message',
|
|
327
|
+
})
|
|
343
328
|
|
|
344
329
|
const results = await axe(container)
|
|
345
330
|
expect(results).toHaveNoViolations()
|