From 02e434e6827fa8536056af4ce72cbe444e332267 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Mon, 21 Oct 2024 08:43:23 -0700 Subject: [PATCH] test(engine-server): more slot tests (#4666) --- .../src/__tests__/fixtures.spec.ts | 2 + .../light/error.txt | 0 .../light/expected.html | 23 +++++++++++ .../light/index.js | 3 ++ .../light/modules/x/inner/inner.html | 9 +++++ .../light/modules/x/inner/inner.js | 5 +++ .../light/modules/x/outer/outer.html | 5 +++ .../light/modules/x/outer/outer.js | 5 +++ .../shadow/error.txt | 0 .../shadow/expected.html | 21 ++++++++++ .../shadow/index.js | 3 ++ .../shadow/modules/x/inner/inner.html | 9 +++++ .../shadow/modules/x/inner/inner.js | 4 ++ .../shadow/modules/x/outer/outer.html | 5 +++ .../shadow/modules/x/outer/outer.js | 3 ++ .../light/error.txt | 0 .../light/expected.html | 27 +++++++++++++ .../light/index.js | 3 ++ .../light/modules/x/inner/inner.html | 9 +++++ .../light/modules/x/inner/inner.js | 5 +++ .../light/modules/x/outer/outer.html | 15 +++++++ .../light/modules/x/outer/outer.js | 5 +++ .../shadow/error.txt | 0 .../shadow/expected.html | 39 +++++++++++++++++++ .../shadow/index.js | 3 ++ .../shadow/modules/x/inner/inner.html | 9 +++++ .../shadow/modules/x/inner/inner.js | 3 ++ .../shadow/modules/x/outer/outer.html | 15 +++++++ .../shadow/modules/x/outer/outer.js | 3 ++ 29 files changed, 233 insertions(+) create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/error.txt create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/expected.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/index.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/inner/inner.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/inner/inner.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/outer/outer.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/outer/outer.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/error.txt create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/expected.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/index.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/inner/inner.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/inner/inner.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/outer/outer.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/outer/outer.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/error.txt create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/expected.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/index.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/inner/inner.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/inner/inner.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/outer/outer.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/outer/outer.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/error.txt create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/expected.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/index.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/inner/inner.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/inner/inner.js create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/outer/outer.html create mode 100644 packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/outer/outer.js diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures.spec.ts b/packages/@lwc/engine-server/src/__tests__/fixtures.spec.ts index a2e8e53ecb..482cd44a0e 100755 --- a/packages/@lwc/engine-server/src/__tests__/fixtures.spec.ts +++ b/packages/@lwc/engine-server/src/__tests__/fixtures.spec.ts @@ -53,6 +53,8 @@ async function compileFixture({ input, dirname }: { input: string; dirname: stri // TODO [#3331]: The existing lwc:dynamic fixture test will generate warnings that can be safely suppressed. const shouldIgnoreWarning = message.includes('LWC1187') || + // TODO [#4497]: stop warning on duplicate slots or disallow them entirely (LWC1137 is duplicate slots) + message.includes('LWC1137') || message.includes('-h-t-m-l') || code === 'CIRCULAR_DEPENDENCY'; if (!shouldIgnoreWarning) { diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/expected.html new file mode 100644 index 0000000000..120c3cbe3c --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/expected.html @@ -0,0 +1,23 @@ + + + a + +
+ yolo +
+ + b + +
+ yolo +
+ + c + +
+ yolo +
+ + d +
+
\ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/index.js new file mode 100644 index 0000000000..17a015b5ea --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-outer'; +export { default } from 'x/outer'; +export * from 'x/outer'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/inner/inner.html b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/inner/inner.html new file mode 100644 index 0000000000..f1edc5794c --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/inner/inner.html @@ -0,0 +1,9 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/inner/inner.js b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/inner/inner.js new file mode 100644 index 0000000000..2104845f74 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/inner/inner.js @@ -0,0 +1,5 @@ +import { LightningElement} from 'lwc'; + +export default class extends LightningElement { + static renderMode = 'light' +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/outer/outer.html b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/outer/outer.html new file mode 100644 index 0000000000..1ae6aeda57 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/outer/outer.html @@ -0,0 +1,5 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/outer/outer.js b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/outer/outer.js new file mode 100644 index 0000000000..2104845f74 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/light/modules/x/outer/outer.js @@ -0,0 +1,5 @@ +import { LightningElement} from 'lwc'; + +export default class extends LightningElement { + static renderMode = 'light' +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/expected.html new file mode 100644 index 0000000000..7296bb8ba4 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/expected.html @@ -0,0 +1,21 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/index.js new file mode 100644 index 0000000000..17a015b5ea --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-outer'; +export { default } from 'x/outer'; +export * from 'x/outer'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/inner/inner.html b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/inner/inner.html new file mode 100644 index 0000000000..81aec27aa4 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/inner/inner.html @@ -0,0 +1,9 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/inner/inner.js b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/inner/inner.js new file mode 100644 index 0000000000..a12e9aa6b0 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/inner/inner.js @@ -0,0 +1,4 @@ +import { LightningElement} from 'lwc'; + +export default class extends LightningElement { +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/outer/outer.html b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/outer/outer.html new file mode 100644 index 0000000000..87ba71234a --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/outer/outer.html @@ -0,0 +1,5 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/outer/outer.js b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/outer/outer.js new file mode 100644 index 0000000000..0ac1a1ba09 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/duplicate-slots-in-template/shadow/modules/x/outer/outer.js @@ -0,0 +1,3 @@ +import { LightningElement} from 'lwc'; + +export default class extends LightningElement {} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/expected.html new file mode 100644 index 0000000000..1130c9b17d --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/expected.html @@ -0,0 +1,27 @@ + + + a + +
+ x +
+ + b + +
+ y +
+
+ y2 +
+
+ y3 +
+ + c + + default1default2default3default4default5default6 + + d +
+
\ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/index.js new file mode 100644 index 0000000000..17a015b5ea --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-outer'; +export { default } from 'x/outer'; +export * from 'x/outer'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/inner/inner.html b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/inner/inner.html new file mode 100644 index 0000000000..cb2a076ac1 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/inner/inner.html @@ -0,0 +1,9 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/inner/inner.js b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/inner/inner.js new file mode 100644 index 0000000000..2104845f74 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/inner/inner.js @@ -0,0 +1,5 @@ +import { LightningElement} from 'lwc'; + +export default class extends LightningElement { + static renderMode = 'light' +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/outer/outer.html b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/outer/outer.html new file mode 100644 index 0000000000..1736ecae2f --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/outer/outer.html @@ -0,0 +1,15 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/outer/outer.js b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/outer/outer.js new file mode 100644 index 0000000000..2104845f74 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/light/modules/x/outer/outer.js @@ -0,0 +1,5 @@ +import { LightningElement} from 'lwc'; + +export default class extends LightningElement { + static renderMode = 'light' +} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/error.txt b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/error.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/expected.html b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/expected.html new file mode 100644 index 0000000000..9b3f40fb6d --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/expected.html @@ -0,0 +1,39 @@ + + + \ No newline at end of file diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/index.js b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/index.js new file mode 100644 index 0000000000..17a015b5ea --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/index.js @@ -0,0 +1,3 @@ +export const tagName = 'x-outer'; +export { default } from 'x/outer'; +export * from 'x/outer'; diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/inner/inner.html b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/inner/inner.html new file mode 100644 index 0000000000..fe27ea87d8 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/inner/inner.html @@ -0,0 +1,9 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/inner/inner.js b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/inner/inner.js new file mode 100644 index 0000000000..0ac1a1ba09 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/inner/inner.js @@ -0,0 +1,3 @@ +import { LightningElement} from 'lwc'; + +export default class extends LightningElement {} diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/outer/outer.html b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/outer/outer.html new file mode 100644 index 0000000000..0c2e25c0e9 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/outer/outer.html @@ -0,0 +1,15 @@ + diff --git a/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/outer/outer.js b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/outer/outer.js new file mode 100644 index 0000000000..0ac1a1ba09 --- /dev/null +++ b/packages/@lwc/engine-server/src/__tests__/fixtures/reordered-duplicate-nonexistent-slots/shadow/modules/x/outer/outer.js @@ -0,0 +1,3 @@ +import { LightningElement} from 'lwc'; + +export default class extends LightningElement {}