@microsoft/fast-html 1.0.0-alpha.31 → 1.0.0-alpha.32
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/dist/dts/components/observer-map.d.ts +1 -1
- package/dist/dts/components/schema.d.ts +1 -1
- package/dist/dts/components/utilities.d.ts +20 -18
- package/dist/esm/components/element.js +0 -5
- package/dist/esm/components/utilities.js +116 -71
- package/package.json +17 -32
- package/dist/dts/fixtures/attribute/attribute.spec.d.ts +0 -1
- package/dist/dts/fixtures/attribute/main.d.ts +0 -1
- package/dist/dts/fixtures/binding/binding.spec.d.ts +0 -1
- package/dist/dts/fixtures/binding/main.d.ts +0 -1
- package/dist/dts/fixtures/children/children.spec.d.ts +0 -1
- package/dist/dts/fixtures/children/main.d.ts +0 -1
- package/dist/dts/fixtures/dot-syntax/dot-syntax.spec.d.ts +0 -1
- package/dist/dts/fixtures/dot-syntax/main.d.ts +0 -1
- package/dist/dts/fixtures/event/event.spec.d.ts +0 -1
- package/dist/dts/fixtures/event/main.d.ts +0 -1
- package/dist/dts/fixtures/lifecycle-callbacks/lifecycle-callbacks.spec.d.ts +0 -1
- package/dist/dts/fixtures/lifecycle-callbacks/main.d.ts +0 -5
- package/dist/dts/fixtures/observer-map/main.d.ts +0 -1
- package/dist/dts/fixtures/observer-map/observer-map.spec.d.ts +0 -1
- package/dist/dts/fixtures/ref/main.d.ts +0 -1
- package/dist/dts/fixtures/ref/ref.spec.d.ts +0 -1
- package/dist/dts/fixtures/repeat/main.d.ts +0 -1
- package/dist/dts/fixtures/repeat/repeat.spec.d.ts +0 -1
- package/dist/dts/fixtures/slotted/main.d.ts +0 -1
- package/dist/dts/fixtures/slotted/slotted.spec.d.ts +0 -1
- package/dist/dts/fixtures/when/main.d.ts +0 -1
- package/dist/dts/fixtures/when/when.spec.d.ts +0 -1
- package/dist/esm/fixtures/attribute/attribute.spec.js +0 -23
- package/dist/esm/fixtures/attribute/main.js +0 -20
- package/dist/esm/fixtures/binding/binding.spec.js +0 -23
- package/dist/esm/fixtures/binding/main.js +0 -30
- package/dist/esm/fixtures/children/children.spec.js +0 -37
- package/dist/esm/fixtures/children/main.js +0 -25
- package/dist/esm/fixtures/dot-syntax/dot-syntax.spec.js +0 -116
- package/dist/esm/fixtures/dot-syntax/main.js +0 -42
- package/dist/esm/fixtures/event/event.spec.js +0 -35
- package/dist/esm/fixtures/event/main.js +0 -32
- package/dist/esm/fixtures/lifecycle-callbacks/lifecycle-callbacks.spec.js +0 -166
- package/dist/esm/fixtures/lifecycle-callbacks/main.js +0 -126
- package/dist/esm/fixtures/observer-map/main.js +0 -375
- package/dist/esm/fixtures/observer-map/observer-map.spec.js +0 -251
- package/dist/esm/fixtures/ref/main.js +0 -15
- package/dist/esm/fixtures/ref/ref.spec.js +0 -9
- package/dist/esm/fixtures/repeat/main.js +0 -44
- package/dist/esm/fixtures/repeat/repeat.spec.js +0 -36
- package/dist/esm/fixtures/slotted/main.js +0 -33
- package/dist/esm/fixtures/slotted/slotted.spec.js +0 -24
- package/dist/esm/fixtures/when/main.js +0 -156
- package/dist/esm/fixtures/when/when.spec.js +0 -82
- package/dist/esm/tsconfig.tsbuildinfo +0 -1
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { FASTElement } from "@microsoft/fast-element";
|
|
3
|
-
import { TemplateElement } from "../../components/index.js";
|
|
4
|
-
class ObserverMapTestElement extends FASTElement {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(...arguments);
|
|
7
|
-
this.users = [
|
|
8
|
-
{
|
|
9
|
-
id: 1,
|
|
10
|
-
name: "Alice Johnson",
|
|
11
|
-
details: {
|
|
12
|
-
personal: {
|
|
13
|
-
age: 28,
|
|
14
|
-
location: {
|
|
15
|
-
city: "New York",
|
|
16
|
-
country: "USA",
|
|
17
|
-
coordinates: {
|
|
18
|
-
lat: 40.7128,
|
|
19
|
-
lng: -74.006,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
preferences: {
|
|
24
|
-
theme: "dark",
|
|
25
|
-
notifications: {
|
|
26
|
-
email: true,
|
|
27
|
-
push: false,
|
|
28
|
-
settings: {
|
|
29
|
-
frequency: "daily",
|
|
30
|
-
categories: ["tech", "news"],
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
posts: [
|
|
36
|
-
{
|
|
37
|
-
id: 101,
|
|
38
|
-
title: "First Post",
|
|
39
|
-
content: "Hello World!",
|
|
40
|
-
metadata: {
|
|
41
|
-
views: 150,
|
|
42
|
-
likes: 25,
|
|
43
|
-
tags: ["introduction", "hello"],
|
|
44
|
-
author: {
|
|
45
|
-
name: "Alice Johnson",
|
|
46
|
-
verified: true,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
id: 102,
|
|
52
|
-
title: "Tech Update",
|
|
53
|
-
content: "Latest in technology...",
|
|
54
|
-
metadata: {
|
|
55
|
-
views: 320,
|
|
56
|
-
likes: 45,
|
|
57
|
-
tags: ["tech", "update"],
|
|
58
|
-
author: {
|
|
59
|
-
name: "Alice Johnson",
|
|
60
|
-
verified: true,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
id: 2,
|
|
68
|
-
name: "Bob Smith",
|
|
69
|
-
details: {
|
|
70
|
-
personal: {
|
|
71
|
-
age: 35,
|
|
72
|
-
location: {
|
|
73
|
-
city: "London",
|
|
74
|
-
country: "UK",
|
|
75
|
-
coordinates: {
|
|
76
|
-
lat: 51.5074,
|
|
77
|
-
lng: -0.1278,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
preferences: {
|
|
82
|
-
theme: "light",
|
|
83
|
-
notifications: {
|
|
84
|
-
email: false,
|
|
85
|
-
push: true,
|
|
86
|
-
settings: {
|
|
87
|
-
frequency: "weekly",
|
|
88
|
-
categories: ["sports", "music"],
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
posts: [
|
|
94
|
-
{
|
|
95
|
-
id: 201,
|
|
96
|
-
title: "Music Review",
|
|
97
|
-
content: "Amazing concert last night...",
|
|
98
|
-
metadata: {
|
|
99
|
-
views: 89,
|
|
100
|
-
likes: 12,
|
|
101
|
-
tags: ["music", "review"],
|
|
102
|
-
author: {
|
|
103
|
-
name: "Bob Smith",
|
|
104
|
-
verified: false,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
},
|
|
110
|
-
];
|
|
111
|
-
this.selectedUserId = 1;
|
|
112
|
-
this.stats = {
|
|
113
|
-
totalUsers: 2,
|
|
114
|
-
activeUsers: 1,
|
|
115
|
-
metrics: {
|
|
116
|
-
engagement: {
|
|
117
|
-
daily: 45,
|
|
118
|
-
weekly: 120,
|
|
119
|
-
monthly: 500,
|
|
120
|
-
},
|
|
121
|
-
performance: {
|
|
122
|
-
loadTime: 1.2,
|
|
123
|
-
renderTime: 0.8,
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
// Methods to test deeply nested property changes
|
|
128
|
-
this.updateUserAge = (userId) => {
|
|
129
|
-
const user = this.users.find(u => u.id === userId);
|
|
130
|
-
if (user) {
|
|
131
|
-
user.details.personal.age += 1;
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
this.toggleUserTheme = (userId) => {
|
|
135
|
-
const user = this.users.find(u => u.id === userId);
|
|
136
|
-
if (user) {
|
|
137
|
-
user.details.preferences.theme =
|
|
138
|
-
user.details.preferences.theme === "dark" ? "light" : "dark";
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
this.updateUserLocation = (userId) => {
|
|
142
|
-
const user = this.users.find(u => u.id === userId);
|
|
143
|
-
if (user) {
|
|
144
|
-
// Use hardcoded values since we can only pass single argument
|
|
145
|
-
user.details.personal.location.city = "Tokyo";
|
|
146
|
-
user.details.personal.location.country = "Japan";
|
|
147
|
-
// Update coordinates randomly for demo
|
|
148
|
-
user.details.personal.location.coordinates.lat = Math.random() * 180 - 90;
|
|
149
|
-
user.details.personal.location.coordinates.lng = Math.random() * 360 - 180;
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
this.addPostToUser = (userId) => {
|
|
153
|
-
const user = this.users.find(u => u.id === userId);
|
|
154
|
-
if (user) {
|
|
155
|
-
const newPostId = Math.max(...user.posts.map((p) => p.id)) + 1;
|
|
156
|
-
user.posts.push({
|
|
157
|
-
id: newPostId,
|
|
158
|
-
title: `New Post ${newPostId}`,
|
|
159
|
-
content: `This is a new post with ID ${newPostId}`,
|
|
160
|
-
metadata: {
|
|
161
|
-
views: 0,
|
|
162
|
-
likes: 0,
|
|
163
|
-
tags: ["new", "auto-generated"],
|
|
164
|
-
author: {
|
|
165
|
-
name: user.name,
|
|
166
|
-
verified: Math.random() > 0.5,
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
this.incrementPostLikes = (postId) => {
|
|
173
|
-
// Find the post across all users since we only have postId
|
|
174
|
-
for (const user of this.users) {
|
|
175
|
-
const post = user.posts.find((p) => p.id === postId);
|
|
176
|
-
if (post) {
|
|
177
|
-
post.metadata.likes += 1;
|
|
178
|
-
post.metadata.views += Math.floor(Math.random() * 5) + 1;
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
this.updateNotificationSettings = (userId) => {
|
|
184
|
-
const user = this.users.find(u => u.id === userId);
|
|
185
|
-
if (user) {
|
|
186
|
-
user.details.preferences.notifications.email =
|
|
187
|
-
!user.details.preferences.notifications.email;
|
|
188
|
-
user.details.preferences.notifications.push =
|
|
189
|
-
!user.details.preferences.notifications.push;
|
|
190
|
-
// Cycle through frequency options
|
|
191
|
-
const frequencies = ["daily", "weekly", "monthly"];
|
|
192
|
-
const currentIndex = frequencies.indexOf(user.details.preferences.notifications.settings.frequency);
|
|
193
|
-
const nextIndex = (currentIndex + 1) % frequencies.length;
|
|
194
|
-
user.details.preferences.notifications.settings.frequency =
|
|
195
|
-
frequencies[nextIndex];
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
this.addNotificationCategory = (userId) => {
|
|
199
|
-
const user = this.users.find(u => u.id === userId);
|
|
200
|
-
if (user) {
|
|
201
|
-
// Use hardcoded category since we can only pass single argument
|
|
202
|
-
const category = "sports";
|
|
203
|
-
if (!user.details.preferences.notifications.settings.categories.includes(category)) {
|
|
204
|
-
user.details.preferences.notifications.settings.categories.push(category);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
this.removeNotificationCategory = (userId) => {
|
|
209
|
-
const user = this.users.find(u => u.id === userId);
|
|
210
|
-
if (user) {
|
|
211
|
-
// Use hardcoded category since we can only pass single argument
|
|
212
|
-
const category = "tech";
|
|
213
|
-
const index = user.details.preferences.notifications.settings.categories.indexOf(category);
|
|
214
|
-
if (index > -1) {
|
|
215
|
-
user.details.preferences.notifications.settings.categories.splice(index, 1);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
this.addNewUser = () => {
|
|
220
|
-
const newId = Math.max(...this.users.map(u => u.id)) + 1;
|
|
221
|
-
this.users.push({
|
|
222
|
-
id: newId,
|
|
223
|
-
name: `User ${newId}`,
|
|
224
|
-
details: {
|
|
225
|
-
personal: {
|
|
226
|
-
age: Math.floor(Math.random() * 50) + 18,
|
|
227
|
-
location: {
|
|
228
|
-
city: "Random City",
|
|
229
|
-
country: "Random Country",
|
|
230
|
-
coordinates: {
|
|
231
|
-
lat: Math.random() * 180 - 90,
|
|
232
|
-
lng: Math.random() * 360 - 180,
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
},
|
|
236
|
-
preferences: {
|
|
237
|
-
theme: "dark",
|
|
238
|
-
notifications: {
|
|
239
|
-
email: Math.random() > 0.5,
|
|
240
|
-
push: Math.random() > 0.5,
|
|
241
|
-
settings: {
|
|
242
|
-
frequency: ["daily", "weekly", "monthly"][Math.floor(Math.random() * 3)],
|
|
243
|
-
categories: ["general"],
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
posts: [],
|
|
249
|
-
});
|
|
250
|
-
this.stats.totalUsers = this.users.length;
|
|
251
|
-
};
|
|
252
|
-
this.removeUser = (userId) => {
|
|
253
|
-
const index = this.users.findIndex(u => u.id === userId);
|
|
254
|
-
if (index > -1) {
|
|
255
|
-
this.users.splice(index, 1);
|
|
256
|
-
this.stats.totalUsers = this.users.length;
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
this.updateStats = () => {
|
|
260
|
-
this.stats.metrics.engagement.daily += Math.floor(Math.random() * 10);
|
|
261
|
-
this.stats.metrics.engagement.weekly += Math.floor(Math.random() * 20);
|
|
262
|
-
this.stats.metrics.engagement.monthly += Math.floor(Math.random() * 50);
|
|
263
|
-
this.stats.metrics.performance.loadTime = Math.random() * 2 + 0.5;
|
|
264
|
-
this.stats.metrics.performance.renderTime = Math.random() * 1 + 0.3;
|
|
265
|
-
};
|
|
266
|
-
this.selectUser = (userId) => {
|
|
267
|
-
this.selectedUserId = userId;
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
class ObserverMapInternalTestElement extends FASTElement {
|
|
272
|
-
constructor() {
|
|
273
|
-
super(...arguments);
|
|
274
|
-
this.a = {};
|
|
275
|
-
this.x = undefined;
|
|
276
|
-
this.groups = [
|
|
277
|
-
{
|
|
278
|
-
items: [
|
|
279
|
-
{
|
|
280
|
-
text: "item A",
|
|
281
|
-
actions: {
|
|
282
|
-
trailing: [
|
|
283
|
-
{
|
|
284
|
-
label: "action label A",
|
|
285
|
-
},
|
|
286
|
-
],
|
|
287
|
-
},
|
|
288
|
-
},
|
|
289
|
-
],
|
|
290
|
-
},
|
|
291
|
-
];
|
|
292
|
-
}
|
|
293
|
-
removeAllItems() {
|
|
294
|
-
this.groups[0].items.shift();
|
|
295
|
-
}
|
|
296
|
-
addAnItem() {
|
|
297
|
-
this.groups[0].items.push({
|
|
298
|
-
text: "item B",
|
|
299
|
-
actions: {
|
|
300
|
-
trailing: [
|
|
301
|
-
{
|
|
302
|
-
label: "action label A",
|
|
303
|
-
},
|
|
304
|
-
],
|
|
305
|
-
},
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
updateAnItem() {
|
|
309
|
-
this.groups[0].items[0].text = "item C";
|
|
310
|
-
}
|
|
311
|
-
removeGroup() {
|
|
312
|
-
this.groups = [];
|
|
313
|
-
}
|
|
314
|
-
addGroup() {
|
|
315
|
-
this.groups = [
|
|
316
|
-
{
|
|
317
|
-
items: [
|
|
318
|
-
{
|
|
319
|
-
text: "item A",
|
|
320
|
-
actions: {
|
|
321
|
-
trailing: [
|
|
322
|
-
{
|
|
323
|
-
label: "action label A",
|
|
324
|
-
},
|
|
325
|
-
],
|
|
326
|
-
},
|
|
327
|
-
},
|
|
328
|
-
],
|
|
329
|
-
},
|
|
330
|
-
];
|
|
331
|
-
}
|
|
332
|
-
updateActionLabel() {
|
|
333
|
-
this.groups[0].items[0].actions.trailing[0].label = "action label B";
|
|
334
|
-
}
|
|
335
|
-
defineB() {
|
|
336
|
-
this.a = {
|
|
337
|
-
b: {
|
|
338
|
-
c: "Hello world",
|
|
339
|
-
},
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
updateC() {
|
|
343
|
-
this.a.b.c = "Hello pluto";
|
|
344
|
-
}
|
|
345
|
-
defineY() {
|
|
346
|
-
this.x = {
|
|
347
|
-
y: {
|
|
348
|
-
z: "Z1",
|
|
349
|
-
},
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
updateZ() {
|
|
353
|
-
this.x.y.z = "Z2";
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
// Nested child components must be defined first
|
|
357
|
-
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
358
|
-
yield ObserverMapInternalTestElement.defineAsync({
|
|
359
|
-
name: "observer-map-internal-test-element",
|
|
360
|
-
});
|
|
361
|
-
yield ObserverMapTestElement.defineAsync({
|
|
362
|
-
name: "observer-map-test-element",
|
|
363
|
-
});
|
|
364
|
-
}))();
|
|
365
|
-
// Configure TemplateElement with observerMap enabled for this test
|
|
366
|
-
TemplateElement.options({
|
|
367
|
-
"observer-map-test-element": {
|
|
368
|
-
observerMap: "all", // Enable ObserverMap to track all the nested property changes
|
|
369
|
-
},
|
|
370
|
-
"observer-map-internal-test-element": {
|
|
371
|
-
observerMap: "all", // Enable ObserverMap to track all the nested property changes
|
|
372
|
-
},
|
|
373
|
-
}).define({
|
|
374
|
-
name: "f-template",
|
|
375
|
-
});
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { test, expect } from "@playwright/test";
|
|
3
|
-
test.describe("ObserverMap", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
4
|
-
test.beforeEach(({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5
|
-
yield page.goto("/observer-map");
|
|
6
|
-
yield page.waitForSelector("observer-map-test-element");
|
|
7
|
-
}));
|
|
8
|
-
test("should render initial users with deeply nested properties", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
-
// Check that initial users are rendered
|
|
10
|
-
yield expect(page.locator(".user-card")).toHaveCount(2);
|
|
11
|
-
// Check deeply nested properties are displayed
|
|
12
|
-
yield expect(page.locator("text=Alice Johnson")).toHaveCount(3);
|
|
13
|
-
yield expect(page.locator("text=Bob Smith")).toHaveCount(2);
|
|
14
|
-
// Check nested location data
|
|
15
|
-
yield expect(page.locator("text=New York, USA")).toBeVisible();
|
|
16
|
-
yield expect(page.locator("text=London, UK")).toBeVisible();
|
|
17
|
-
// Check deeply nested preferences
|
|
18
|
-
yield expect(page.locator("text=Theme: dark")).toBeVisible();
|
|
19
|
-
yield expect(page.locator("text=Theme: light")).toBeVisible();
|
|
20
|
-
}));
|
|
21
|
-
test("should update deeply nested age property", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
// Initial age should be 28 for Alice
|
|
23
|
-
yield expect(page.locator("text=Age: 28 years old")).toBeVisible();
|
|
24
|
-
// Click the age increment button for Alice (user ID 1)
|
|
25
|
-
yield page.locator("button:has-text('Age +1')").first().click();
|
|
26
|
-
// Age should now be 29
|
|
27
|
-
yield expect(page.locator("text=Age: 29 years old")).toBeVisible();
|
|
28
|
-
yield expect(page.locator("text=Age: 28 years old")).not.toBeVisible();
|
|
29
|
-
}));
|
|
30
|
-
test("should toggle theme in deeply nested preferences", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
// Initial theme should be dark for Alice
|
|
32
|
-
yield expect(page.locator("text=Theme: dark").first()).toBeVisible();
|
|
33
|
-
// Click the toggle theme button for Alice
|
|
34
|
-
yield page.locator("button:has-text('Toggle Theme')").first().click();
|
|
35
|
-
// Theme should now be light
|
|
36
|
-
yield expect(page.locator("text=Theme: light").first()).toBeVisible();
|
|
37
|
-
}));
|
|
38
|
-
test("should update location", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
// Initial location should be New York, USA
|
|
40
|
-
yield expect(page.locator("text=New York, USA")).toBeVisible();
|
|
41
|
-
// Click the change location button for Alice
|
|
42
|
-
yield page.locator("button:has-text('Change Location')").first().click();
|
|
43
|
-
// Location should now be Tokyo, Japan
|
|
44
|
-
yield expect(page.locator("text=Tokyo, Japan")).toBeVisible();
|
|
45
|
-
yield expect(page.locator("text=New York, USA")).not.toBeVisible();
|
|
46
|
-
}));
|
|
47
|
-
test("should update notification settings", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
// Check initial notification settings for Alice
|
|
49
|
-
yield expect(page.locator("text=Email Notifications: true").first()).toBeVisible();
|
|
50
|
-
yield expect(page.locator("text=Push Notifications: false").first()).toBeVisible();
|
|
51
|
-
yield expect(page.locator("text=Notification Frequency: daily").first()).toBeVisible();
|
|
52
|
-
// Click update notifications button
|
|
53
|
-
yield page.locator("button:has-text('Update Notifications')").first().click();
|
|
54
|
-
// Settings should be toggled
|
|
55
|
-
yield expect(page.locator("text=Email Notifications: false").first()).toBeVisible();
|
|
56
|
-
yield expect(page.locator("text=Push Notifications: true").first()).toBeVisible();
|
|
57
|
-
yield expect(page.locator("text=Notification Frequency: weekly").first()).toBeVisible();
|
|
58
|
-
}));
|
|
59
|
-
test("should add and remove categories in deeply nested arrays", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
-
// Check initial categories for Alice (should include "tech")
|
|
61
|
-
yield expect(page.locator(".tag:has-text('tech')")).toHaveCount(2);
|
|
62
|
-
// Add sports category
|
|
63
|
-
yield page.locator("button:has-text('Add Category')").first().click();
|
|
64
|
-
yield expect(page.locator(".tag:has-text('sports')").first()).toBeVisible();
|
|
65
|
-
// Remove tech category
|
|
66
|
-
yield page.locator("button:has-text('Remove Tech Category')").first().click();
|
|
67
|
-
yield expect(page.locator(".tag:has-text('tech')")).toHaveCount(1);
|
|
68
|
-
}));
|
|
69
|
-
test("should increment post likes and update nested metadata", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
-
const aliceCard = page.locator(".user-card").first();
|
|
71
|
-
const firstPost = aliceCard.locator(".post-card").first();
|
|
72
|
-
// Check initial likes (should be 25)
|
|
73
|
-
yield expect(firstPost.locator("text=25 likes")).toBeVisible();
|
|
74
|
-
// Click like button
|
|
75
|
-
yield firstPost.locator("button:has-text('Like Post')").click();
|
|
76
|
-
// Likes should increment to 26
|
|
77
|
-
yield expect(firstPost.locator("text=26 likes")).toBeVisible();
|
|
78
|
-
// Views should also increment (random amount)
|
|
79
|
-
yield expect(firstPost.locator("text=views")).toBeVisible();
|
|
80
|
-
}));
|
|
81
|
-
test("should add new posts to users", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
-
const aliceCard = page.locator(".user-card").first();
|
|
83
|
-
// Initial post count should be 2
|
|
84
|
-
yield expect(aliceCard.locator(".post-card")).toHaveCount(2);
|
|
85
|
-
// Add new post
|
|
86
|
-
yield aliceCard.locator("button:has-text('Add New Post')").click();
|
|
87
|
-
// Should now have 3 posts
|
|
88
|
-
yield expect(aliceCard.locator(".post-card")).toHaveCount(3);
|
|
89
|
-
}));
|
|
90
|
-
test("should update the likes on a new post", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
|
-
const aliceCard = page.locator(".user-card").first();
|
|
92
|
-
// Add new post first
|
|
93
|
-
yield aliceCard.locator("button:has-text('Add New Post')").click();
|
|
94
|
-
// Should now have 3 posts
|
|
95
|
-
yield expect(aliceCard.locator(".post-card")).toHaveCount(3);
|
|
96
|
-
// Get the newly added post (should be the last one)
|
|
97
|
-
const newPost = aliceCard.locator(".post-card").nth(2);
|
|
98
|
-
// Check initial likes on the new post (should be 0)
|
|
99
|
-
yield expect(newPost.locator("text=0 likes")).toBeVisible();
|
|
100
|
-
// Click like button on the new post
|
|
101
|
-
yield newPost.locator("button:has-text('Like Post')").click();
|
|
102
|
-
// Likes should increment to 1
|
|
103
|
-
yield expect(newPost.locator("text=1 likes")).toBeVisible();
|
|
104
|
-
yield expect(newPost.locator("text=0 likes")).not.toBeVisible();
|
|
105
|
-
}));
|
|
106
|
-
test("should add and remove users from the array", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
107
|
-
// Initial user count should be 2
|
|
108
|
-
yield expect(page.locator(".user-card")).toHaveCount(2);
|
|
109
|
-
yield expect(page.locator("text=Total Users: 2")).toBeVisible();
|
|
110
|
-
// Add new user
|
|
111
|
-
yield page.locator("button:has-text('Add New User')").click();
|
|
112
|
-
// Should now have 3 users
|
|
113
|
-
yield expect(page.locator(".user-card")).toHaveCount(3);
|
|
114
|
-
yield expect(page.locator("text=Total Users: 3")).toBeVisible();
|
|
115
|
-
yield expect(page.locator("text=User 3")).toBeVisible();
|
|
116
|
-
// Remove a user (Alice - first remove button)
|
|
117
|
-
yield page.locator("button:has-text('Remove User')").first().click();
|
|
118
|
-
// Should be back to 2 users
|
|
119
|
-
yield expect(page.locator(".user-card")).toHaveCount(2);
|
|
120
|
-
yield expect(page.locator("text=Total Users: 2")).toBeVisible();
|
|
121
|
-
}));
|
|
122
|
-
test("should be able to update nested properties on added users", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
123
|
-
// Initial user count should be 2
|
|
124
|
-
yield expect(page.locator(".user-card")).toHaveCount(2);
|
|
125
|
-
// Add new user
|
|
126
|
-
yield page.locator("button:has-text('Add New User')").click();
|
|
127
|
-
// Should now have 3 users
|
|
128
|
-
yield expect(page.locator(".user-card")).toHaveCount(3);
|
|
129
|
-
const userCard3 = yield page.locator(".user-card").nth(2);
|
|
130
|
-
// Initial theme should be dark for User 3
|
|
131
|
-
yield expect(userCard3.locator("text=Theme: dark")).toBeVisible();
|
|
132
|
-
// Click the toggle theme button for User 3
|
|
133
|
-
yield userCard3.locator("button:has-text('Toggle Theme')").click();
|
|
134
|
-
// Theme should now be light
|
|
135
|
-
yield expect(userCard3.locator("text=Theme: light")).toBeVisible();
|
|
136
|
-
}));
|
|
137
|
-
test("should be able to update nested properties on added users after the items array has been emptied", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
-
// Initial item count should be 1
|
|
139
|
-
yield expect(page.locator(".item")).toHaveCount(1);
|
|
140
|
-
// Remove item
|
|
141
|
-
yield page.locator("button:has-text('Remove all items')").click();
|
|
142
|
-
// Should now have 0 items
|
|
143
|
-
yield expect(page.locator(".item")).toHaveCount(0);
|
|
144
|
-
// Click the add item button
|
|
145
|
-
yield page.locator("button:has-text('Add an item')").click();
|
|
146
|
-
// There should now be 1 item
|
|
147
|
-
yield expect(page.locator(".item")).toHaveCount(1);
|
|
148
|
-
// Click the update item button
|
|
149
|
-
yield page.locator("button:has-text('Update an item')").click();
|
|
150
|
-
// The item should have updated text
|
|
151
|
-
yield expect(page.locator(".item")).toHaveText('item C');
|
|
152
|
-
}));
|
|
153
|
-
test("should be able to update nested properties on added users after the group array has been emptied", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
154
|
-
// Initial item count should be 1
|
|
155
|
-
yield expect(page.locator(".item")).toHaveCount(1);
|
|
156
|
-
// Remove groups
|
|
157
|
-
yield page.locator("button:has-text('Remove groups')").click();
|
|
158
|
-
// Should now have 0 items
|
|
159
|
-
yield expect(page.locator(".item")).toHaveCount(0);
|
|
160
|
-
// Click the add group button
|
|
161
|
-
yield page.locator("button:has-text('Add group')").click();
|
|
162
|
-
// There should now be 1 item
|
|
163
|
-
yield expect(page.locator(".item")).toHaveCount(1);
|
|
164
|
-
// Click the update item button
|
|
165
|
-
yield page.locator("button:has-text('Update an item')").click();
|
|
166
|
-
// The item should have updated text
|
|
167
|
-
yield expect(page.locator(".item")).toHaveText('item C');
|
|
168
|
-
// Click the update action label
|
|
169
|
-
yield page.locator("button:has-text('Update an action label')").click();
|
|
170
|
-
// The action label should have updated text
|
|
171
|
-
yield expect(page.locator(".action-label")).toHaveText('action label B');
|
|
172
|
-
}));
|
|
173
|
-
test("should update global stats with nested metrics", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
174
|
-
// Check initial engagement stats
|
|
175
|
-
const initialDaily = yield page.locator(".stats .nested-info").nth(1).textContent();
|
|
176
|
-
// Update stats
|
|
177
|
-
yield page.locator(".stats .controls button").nth(0).click();
|
|
178
|
-
yield page.evaluate(() => {
|
|
179
|
-
return new Promise((resolve) => {
|
|
180
|
-
requestAnimationFrame(() => resolve(true));
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
// Stats should be updated (values should change)
|
|
184
|
-
const updatedDaily = yield page.locator(".stats .nested-info").nth(1).textContent();
|
|
185
|
-
expect(updatedDaily).not.toBe(initialDaily);
|
|
186
|
-
}));
|
|
187
|
-
test("should handle user selection with conditional rendering", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
188
|
-
// Initially, Alice (ID 1) should be selected
|
|
189
|
-
yield expect(page.locator("text=⭐ SELECTED").first()).toBeVisible();
|
|
190
|
-
// Select Bob (user ID 2)
|
|
191
|
-
yield page.locator(".user-card").nth(1).locator("button:has-text('Select User')").click();
|
|
192
|
-
// Bob should now show as selected
|
|
193
|
-
const bobCard = page.locator(".user-card").nth(1);
|
|
194
|
-
yield expect(bobCard.locator("text=⭐ SELECTED")).toBeVisible();
|
|
195
|
-
// Alice should no longer show as selected
|
|
196
|
-
const aliceCard = page.locator(".user-card").first();
|
|
197
|
-
yield expect(aliceCard.locator("text=⭐ SELECTED")).not.toBeVisible();
|
|
198
|
-
}));
|
|
199
|
-
test("should update a defined object when a nested property has been defined", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
200
|
-
const undefinedText = yield page.locator(".nested-define").textContent();
|
|
201
|
-
yield expect(undefinedText).toEqual("");
|
|
202
|
-
// Define the object
|
|
203
|
-
yield page.locator("button:has-text('Define B')").nth(0).click();
|
|
204
|
-
yield page.evaluate(() => {
|
|
205
|
-
return new Promise((resolve) => {
|
|
206
|
-
requestAnimationFrame(() => resolve(true));
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
const definedText = yield page.locator(".nested-define").textContent();
|
|
210
|
-
yield expect(definedText).toEqual("Hello world");
|
|
211
|
-
}));
|
|
212
|
-
test("should update a defined object when a nested property has been updated", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
213
|
-
// Define the object
|
|
214
|
-
yield page.locator("button:has-text('Define B')").nth(0).click();
|
|
215
|
-
// Update the object
|
|
216
|
-
yield page.locator("button:has-text('Update C')").nth(0).click();
|
|
217
|
-
yield page.evaluate(() => {
|
|
218
|
-
return new Promise((resolve) => {
|
|
219
|
-
requestAnimationFrame(() => resolve(true));
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
const updatedText = yield page.locator(".nested-define").textContent();
|
|
223
|
-
yield expect(updatedText).toEqual("Hello pluto");
|
|
224
|
-
}));
|
|
225
|
-
test("should update an undefined object when a nested property has been defined", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
226
|
-
const undefinedText = yield page.locator(".nested-define-2");
|
|
227
|
-
yield expect(undefinedText).toHaveCount(0);
|
|
228
|
-
// Define the object
|
|
229
|
-
yield page.locator("button:has-text('Define Y')").nth(0).click();
|
|
230
|
-
yield page.evaluate(() => {
|
|
231
|
-
return new Promise((resolve) => {
|
|
232
|
-
requestAnimationFrame(() => resolve(true));
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
const definedText = yield page.locator(".nested-define-2").textContent();
|
|
236
|
-
yield expect(definedText).toEqual("Z1");
|
|
237
|
-
}));
|
|
238
|
-
test("should update an undefined object when a nested property has been updated", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
239
|
-
// Define the object
|
|
240
|
-
yield page.locator("button:has-text('Define Y')").nth(0).click();
|
|
241
|
-
// Update the object
|
|
242
|
-
yield page.locator("button:has-text('Update Z')").nth(0).click();
|
|
243
|
-
yield page.evaluate(() => {
|
|
244
|
-
return new Promise((resolve) => {
|
|
245
|
-
requestAnimationFrame(() => resolve(true));
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
const updatedText = yield page.locator(".nested-define-2").textContent();
|
|
249
|
-
yield expect(updatedText).toEqual("Z2");
|
|
250
|
-
}));
|
|
251
|
-
}));
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FASTElement } from "@microsoft/fast-element";
|
|
2
|
-
import { RenderableFASTElement, TemplateElement } from "@microsoft/fast-html";
|
|
3
|
-
class TestElement extends FASTElement {
|
|
4
|
-
constructor() {
|
|
5
|
-
super(...arguments);
|
|
6
|
-
this.video = null;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
RenderableFASTElement(TestElement).defineAsync({
|
|
10
|
-
name: "test-element",
|
|
11
|
-
templateOptions: "defer-and-hydrate",
|
|
12
|
-
});
|
|
13
|
-
TemplateElement.define({
|
|
14
|
-
name: "f-template",
|
|
15
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { expect, test } from "@playwright/test";
|
|
3
|
-
test.describe("f-template", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
4
|
-
test("create a ref directive", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5
|
-
yield page.goto("/ref");
|
|
6
|
-
const element = page.locator("test-element");
|
|
7
|
-
yield expect(element).toHaveJSProperty("video.nodeName", "VIDEO");
|
|
8
|
-
}));
|
|
9
|
-
}));
|