edu-webcomponents 1.17.0 → 1.19.7
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/.github/workflows/deploy-storybook-build-to-github-pages.yaml +27 -27
- package/.github/workflows/{release-packages-to-github.yaml → release-and-publish.yaml} +50 -36
- package/CHANGELOG.md +102 -66
- package/README.md +62 -62
- package/demo/index.html +29 -29
- package/docs/deploy-storybook-build-to-github-pages-docs.md +4 -4
- package/docs/husky-docs.md +12 -12
- package/docs/npm-check-updates-docs.md +10 -10
- package/docs/publish-packages-to-npm-registry-docs.md +46 -46
- package/docs/release-packages-to-github-docs.md +3 -4
- package/index.js +3 -1
- package/package.json +72 -72
- package/src/EduButton.js +61 -57
- package/src/EduProgressBar.js +78 -0
- package/src/EduTooltip.js +126 -0
- package/src/stories/EduProgressBar.stories.js +102 -0
- package/src/stories/EduTooltip.stories.js +68 -0
- package/src/stylesConstants.js +15 -0
- package/test/EduProgressBar.test.js +173 -0
- package/test/EduTooltip.test.js +119 -0
- package/.github/workflows/publish-packages-to-npm-registry.yaml +0 -21
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// test/edu-progress-bar.test.js
|
|
2
|
+
import { html, fixture, expect } from '@open-wc/testing';
|
|
3
|
+
import '../src/EduProgressBar.js'; // ajusta la ruta si es necesario
|
|
4
|
+
|
|
5
|
+
describe('EduProgressBar', () => {
|
|
6
|
+
it('renders with default values', async () => {
|
|
7
|
+
const el = await fixture(html`<edu-progress-bar></edu-progress-bar>`);
|
|
8
|
+
|
|
9
|
+
const bar = el.shadowRoot.querySelector('.bar-fill');
|
|
10
|
+
const label = el.shadowRoot.querySelector('.label');
|
|
11
|
+
|
|
12
|
+
expect(el.value).to.equal(0);
|
|
13
|
+
expect(el.max).to.equal(100);
|
|
14
|
+
expect(bar.style.width).to.equal('0%');
|
|
15
|
+
expect(label).to.be.null;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('renders with default values (with label)', async () => {
|
|
19
|
+
const el = await fixture(
|
|
20
|
+
html`<edu-progress-bar .showLabel=${true}></edu-progress-bar>`,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const bar = el.shadowRoot.querySelector('.bar-fill');
|
|
24
|
+
const label = el.shadowRoot.querySelector('.label');
|
|
25
|
+
|
|
26
|
+
expect(el.value).to.equal(0);
|
|
27
|
+
expect(el.max).to.equal(100);
|
|
28
|
+
expect(bar.style.width).to.equal('0%');
|
|
29
|
+
expect(label.textContent).to.equal('0%');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('calculates percentage correctly', async () => {
|
|
33
|
+
const el = await fixture(
|
|
34
|
+
html`<edu-progress-bar .value=${25} .max=${50}></edu-progress-bar>`,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const bar = el.shadowRoot.querySelector('.bar-fill');
|
|
38
|
+
const label = el.shadowRoot.querySelector('.label');
|
|
39
|
+
|
|
40
|
+
expect(bar.style.width).to.equal('50%');
|
|
41
|
+
expect(label).to.be.null;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('calculates percentage correctly (with label)', async () => {
|
|
45
|
+
const el = await fixture(
|
|
46
|
+
html`<edu-progress-bar
|
|
47
|
+
.value=${25}
|
|
48
|
+
.max=${50}
|
|
49
|
+
.showLabel=${true}
|
|
50
|
+
></edu-progress-bar>`,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const bar = el.shadowRoot.querySelector('.bar-fill');
|
|
54
|
+
const label = el.shadowRoot.querySelector('.label');
|
|
55
|
+
|
|
56
|
+
expect(bar.style.width).to.equal('50%');
|
|
57
|
+
expect(label.textContent).to.equal('50%');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('caps percentage at 100%', async () => {
|
|
61
|
+
const el = await fixture(
|
|
62
|
+
html`<edu-progress-bar .value=${200} .max=${100}></edu-progress-bar>`,
|
|
63
|
+
);
|
|
64
|
+
const bar = el.shadowRoot.querySelector('.bar-fill');
|
|
65
|
+
const label = el.shadowRoot.querySelector('.label');
|
|
66
|
+
|
|
67
|
+
expect(bar.style.width).to.equal('100%');
|
|
68
|
+
expect(label).to.be.null;
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('caps percentage at 100% (with label)', async () => {
|
|
72
|
+
const el = await fixture(
|
|
73
|
+
html`<edu-progress-bar
|
|
74
|
+
.value=${200}
|
|
75
|
+
.max=${100}
|
|
76
|
+
.showLabel=${true}
|
|
77
|
+
></edu-progress-bar>`,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const bar = el.shadowRoot.querySelector('.bar-fill');
|
|
81
|
+
const label = el.shadowRoot.querySelector('.label');
|
|
82
|
+
|
|
83
|
+
expect(bar.style.width).to.equal('100%');
|
|
84
|
+
expect(label.textContent).to.equal('100%');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('handles invalid max', async () => {
|
|
88
|
+
const el = await fixture(
|
|
89
|
+
html`<edu-progress-bar .value=${50} .max=${0}></edu-progress-bar>`,
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const bar = el.shadowRoot.querySelector('.bar-fill');
|
|
93
|
+
const label = el.shadowRoot.querySelector('.label');
|
|
94
|
+
|
|
95
|
+
expect(bar.style.width).to.equal('50%');
|
|
96
|
+
expect(label).to.be.null;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('handles invalid max (with label)', async () => {
|
|
100
|
+
const el = await fixture(
|
|
101
|
+
html`<edu-progress-bar
|
|
102
|
+
.value=${50}
|
|
103
|
+
.max=${0}
|
|
104
|
+
.showLabel=${true}
|
|
105
|
+
></edu-progress-bar>`,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const bar = el.shadowRoot.querySelector('.bar-fill');
|
|
109
|
+
const label = el.shadowRoot.querySelector('.label');
|
|
110
|
+
|
|
111
|
+
expect(bar.style.width).to.equal('50%');
|
|
112
|
+
expect(label.textContent).to.equal('50%');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('hides label when showLabel is false', async () => {
|
|
116
|
+
const el = await fixture(
|
|
117
|
+
html`<edu-progress-bar
|
|
118
|
+
.value=${50}
|
|
119
|
+
.showLabel=${false}
|
|
120
|
+
></edu-progress-bar>`,
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const label = el.shadowRoot.querySelector('.label');
|
|
124
|
+
|
|
125
|
+
expect(label).to.equal(null);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('shows label when showLabel is true', async () => {
|
|
129
|
+
const el = await fixture(
|
|
130
|
+
html`<edu-progress-bar
|
|
131
|
+
.value=${50}
|
|
132
|
+
.showLabel=${true}
|
|
133
|
+
></edu-progress-bar>`,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const label = el.shadowRoot.querySelector('.label');
|
|
137
|
+
|
|
138
|
+
expect(label).to.exist;
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('is accessible by default', async () => {
|
|
142
|
+
const el = await fixture(html`<edu-progress-bar></edu-progress-bar>`);
|
|
143
|
+
|
|
144
|
+
await expect(el).to.be.accessible();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('is accessible by default (with value)', async () => {
|
|
148
|
+
const el = await fixture(
|
|
149
|
+
html`<edu-progress-bar .value=${50}></edu-progress-bar>`,
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
await expect(el).to.be.accessible();
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('is accessible (with label)', async () => {
|
|
156
|
+
const el = await fixture(
|
|
157
|
+
html`<edu-progress-bar .showLabel=${true}></edu-progress-bar>`,
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
await expect(el).to.be.accessible();
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('is accessible (with value and label)', async () => {
|
|
164
|
+
const el = await fixture(
|
|
165
|
+
html`<edu-progress-bar
|
|
166
|
+
.value=${50}
|
|
167
|
+
.showLabel=${true}
|
|
168
|
+
></edu-progress-bar>`,
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
await expect(el).to.be.accessible();
|
|
172
|
+
});
|
|
173
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { fixture, html, expect } from '@open-wc/testing';
|
|
2
|
+
import '../src/EduTooltip.js';
|
|
3
|
+
|
|
4
|
+
describe('EduTooltip', () => {
|
|
5
|
+
it('is not visible by default', async () => {
|
|
6
|
+
const el = await fixture(html`<edu-tooltip></edu-tooltip>`);
|
|
7
|
+
|
|
8
|
+
const tooltip = el.shadowRoot.querySelector('.tooltip');
|
|
9
|
+
const styles = getComputedStyle(tooltip);
|
|
10
|
+
expect(styles.opacity).to.equal('0');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('sets bottom styles for position when there is not value passed in', async () => {
|
|
14
|
+
const el = await fixture(html`<edu-tooltip></edu-tooltip>`);
|
|
15
|
+
|
|
16
|
+
const tooltip = el.shadowRoot.querySelector('.tooltip');
|
|
17
|
+
expect(tooltip.classList.contains('bottom')).to.be.true;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('sets bottom styles for position when the value passed is not valid', async () => {
|
|
21
|
+
const el = await fixture(
|
|
22
|
+
html`<edu-tooltip position="invalidString"></edu-tooltip>`,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const tooltip = el.shadowRoot.querySelector('.tooltip');
|
|
26
|
+
expect(tooltip.classList.contains('bottom')).to.be.true;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('applies class for position', async () => {
|
|
30
|
+
const el = await fixture(
|
|
31
|
+
html`<edu-tooltip position="right"></edu-tooltip>`,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const tooltip = el.shadowRoot.querySelector('.tooltip');
|
|
35
|
+
expect(tooltip.classList.contains('right')).to.be.true;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('applies class for position (case insensitive)', async () => {
|
|
39
|
+
const el = await fixture(
|
|
40
|
+
html`<edu-tooltip position="RIGHT"></edu-tooltip>`,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const tooltip = el.shadowRoot.querySelector('.tooltip');
|
|
44
|
+
expect(tooltip.classList.contains('right')).to.be.true;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('renders text of the tooltip', async () => {
|
|
48
|
+
const el = await fixture(html`<edu-tooltip text="Help"></edu-tooltip>`);
|
|
49
|
+
|
|
50
|
+
const tooltip = el.shadowRoot.querySelector('.tooltip');
|
|
51
|
+
expect(tooltip.textContent).to.equal('\n Help\n ');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('shows tooltip when mouseenter event', async () => {
|
|
55
|
+
const el = await fixture(
|
|
56
|
+
html`<edu-tooltip text="Text"><span>Hover me</span></edu-tooltip>`,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const trigger = el.shadowRoot.querySelector('span');
|
|
60
|
+
const tooltip = el.shadowRoot.querySelector('.tooltip');
|
|
61
|
+
trigger.dispatchEvent(new Event('mouseenter'));
|
|
62
|
+
await el.updateComplete;
|
|
63
|
+
|
|
64
|
+
const styles = getComputedStyle(tooltip);
|
|
65
|
+
expect(styles.opacity).to.equal('1');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('hides tooltip when mouseleave event', async () => {
|
|
69
|
+
const el = await fixture(
|
|
70
|
+
html`<edu-tooltip text="Text"><span>Hover me</span></edu-tooltip>`,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const trigger = el.shadowRoot.querySelector('span');
|
|
74
|
+
const tooltip = el.shadowRoot.querySelector('.tooltip');
|
|
75
|
+
el.visible = true;
|
|
76
|
+
trigger.dispatchEvent(new Event('mouseleave'));
|
|
77
|
+
await el.updateComplete;
|
|
78
|
+
|
|
79
|
+
const styles = getComputedStyle(tooltip);
|
|
80
|
+
expect(styles.opacity).to.equal('0');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('shows tooltip when focus event', async () => {
|
|
84
|
+
const el = await fixture(
|
|
85
|
+
html`<edu-tooltip text="Text"><span>Focus</span></edu-tooltip>`,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const trigger = el.shadowRoot.querySelector('span');
|
|
89
|
+
const tooltip = el.shadowRoot.querySelector('.tooltip');
|
|
90
|
+
trigger.dispatchEvent(new Event('focus'));
|
|
91
|
+
await el.updateComplete;
|
|
92
|
+
|
|
93
|
+
const styles = getComputedStyle(tooltip);
|
|
94
|
+
expect(styles.opacity).to.equal('1');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('hides tooltip when blur event', async () => {
|
|
98
|
+
const el = await fixture(
|
|
99
|
+
html`<edu-tooltip text="Text"><span>Focus</span></edu-tooltip>`,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const trigger = el.shadowRoot.querySelector('span');
|
|
103
|
+
const tooltip = el.shadowRoot.querySelector('.tooltip');
|
|
104
|
+
el.visible = true;
|
|
105
|
+
trigger.dispatchEvent(new Event('blur'));
|
|
106
|
+
await el.updateComplete;
|
|
107
|
+
|
|
108
|
+
const styles = getComputedStyle(tooltip);
|
|
109
|
+
expect(styles.opacity).to.equal('0');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('is accessible', async () => {
|
|
113
|
+
const el = await fixture(
|
|
114
|
+
html`<edu-tooltip text="Text"><span>Trigger</span></edu-tooltip>`,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
await expect(el).to.be.accessible();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
name: Publish Package to npmjs
|
|
2
|
-
on:
|
|
3
|
-
release:
|
|
4
|
-
types: [published]
|
|
5
|
-
jobs:
|
|
6
|
-
build:
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
permissions:
|
|
9
|
-
contents: read
|
|
10
|
-
id-token: write
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v4
|
|
13
|
-
- uses: actions/setup-node@v4
|
|
14
|
-
with:
|
|
15
|
-
node-version: '20.x'
|
|
16
|
-
registry-url: 'https://registry.npmjs.org'
|
|
17
|
-
- run: npm install -g npm
|
|
18
|
-
- run: npm ci
|
|
19
|
-
- run: npm publish --provenance --access public
|
|
20
|
-
env:
|
|
21
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|