Skip to content

Commit 67bbf0f

Browse files
test: additional tests for ssr (salesforce#1953)
* test: additional tests for ssr if:true and if:false * test: tests for if directive with slots * test: test for lwc:dynamic * test: test that lwc:dom directive is ignored for ssr * test(engine-server): update tests * test: breakdown tests into individual test cases Co-authored-by: Pierre-Marie Dartus <p.dartus@salesforce.com>
1 parent a35801f commit 67bbf0f

File tree

38 files changed

+347
-0
lines changed

38 files changed

+347
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<x-if-conditional-slot-content>
2+
<template shadow-root>
3+
<div class="active-if-blocks">
4+
<x-conditional-slot-content>
5+
<template shadow-root>
6+
<x-slotted>
7+
<template shadow-root><slot></slot></template>
8+
Testing if:true
9+
<x-child>
10+
<template shadow-root><slot></slot></template>
11+
Should be slotted when true === true
12+
</x-child>
13+
</x-slotted>
14+
<x-slotted>
15+
<template shadow-root><slot></slot></template>
16+
Testing if:false
17+
<x-child>
18+
<template shadow-root><slot></slot></template>
19+
Should be slotted when false === false
20+
</x-child>
21+
</x-slotted>
22+
</template>
23+
</x-conditional-slot-content>
24+
</div>
25+
<div class="inactive-if-blocks">
26+
<x-conditional-slot-content>
27+
<template shadow-root>
28+
<x-slotted>
29+
<template shadow-root><slot></slot></template>
30+
</x-slotted>
31+
<x-slotted>
32+
<template shadow-root><slot></slot></template>
33+
</x-slotted>
34+
</template>
35+
</x-conditional-slot-content>
36+
</div>
37+
</template>
38+
</x-if-conditional-slot-content>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<slot></slot>
3+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { LightningElement } from 'lwc';
2+
3+
export default class Child extends LightningElement {
4+
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- The slot content passed to x-slotted component is controlled by a if:* directive-->
2+
<template>
3+
<x-slotted>
4+
<template if:true={activatetruepath}>
5+
Testing if:true
6+
<x-child>Should be slotted when {activatetruepath} === true</x-child>
7+
</template>
8+
</x-slotted>
9+
<x-slotted>
10+
<template if:false={activatefalsepath}>
11+
Testing if:false
12+
<x-child>Should be slotted when {activatefalsepath} === false</x-child>
13+
</template>
14+
</x-slotted>
15+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { LightningElement, api } from 'lwc';
2+
3+
export default class ConditionalSlotContent extends LightningElement {
4+
@api
5+
activatefalsepath;
6+
7+
@api
8+
activatetruepath;
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template>
2+
<div class="active-if-blocks">
3+
<x-conditional-slot-content activatetruepath={trueFlag} activatefalsepath={falseFlag}>
4+
</x-conditional-slot-content>
5+
</div>
6+
7+
<div class="inactive-if-blocks">
8+
<x-conditional-slot-content activatetruepath={falseFlag} activatefalsepath={trueFlag}>
9+
</x-conditional-slot-content>
10+
</div>
11+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { LightningElement } from 'lwc';
2+
3+
export default class Test extends LightningElement {
4+
falseFlag = false;
5+
trueFlag = true;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<slot></slot>
3+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { LightningElement } from 'lwc';
2+
3+
export default class Slotted extends LightningElement {
4+
5+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<x-if-conditional-slot>
2+
<template shadow-root>
3+
<div class="active-if-blocks">
4+
<x-parent>
5+
<template shadow-root>
6+
<x-slotted>
7+
<template shadow-root>
8+
Should be active when true === true
9+
<slot name="trueslot"></slot>
10+
Should be active when false === false
11+
<slot name="falseslot"></slot>
12+
</template>
13+
<x-child slot="trueslot" class="slotted-child">
14+
<template shadow-root><slot></slot></template>
15+
Testing if:true
16+
</x-child>
17+
<x-child slot="falseslot" class="slotted-child">
18+
<template shadow-root><slot></slot></template>
19+
Testing if:false
20+
</x-child>
21+
</x-slotted>
22+
</template>
23+
</x-parent>
24+
</div>
25+
<div class="inactive-if-blocks">
26+
<x-parent>
27+
<template shadow-root>
28+
<x-slotted>
29+
<template shadow-root></template>
30+
<x-child slot="trueslot" class="slotted-child">
31+
<template shadow-root><slot></slot></template>
32+
Testing if:true
33+
</x-child>
34+
<x-child slot="falseslot" class="slotted-child">
35+
<template shadow-root><slot></slot></template>
36+
Testing if:false
37+
</x-child>
38+
</x-slotted>
39+
</template>
40+
</x-parent>
41+
</div>
42+
</template>
43+
</x-if-conditional-slot>

0 commit comments

Comments
 (0)