Skip to content

Commit 61e9fbe

Browse files
feat: revert "use test safe transitions" (#6405)
# Motivation Revert #6396 because thanks to a different way of mocking the transitions for test purposes (without vite), those workaround are not needed anymore when migrating to Svelte v5. # Resources New solution to mock the animation for test purposes with Svelte v5 providing by Testing Library in testing-library/svelte-testing-library#284 (comment) # Changes Revert #6396 # Tests I tested the revert and new way of mocking with Svelte v5 in #6404. The tests did not throw the keyword `TypeError: Cannot set properties of undefined (setting 'onfinish')`. Signed-off-by: David Dal Busco <[email protected]>
1 parent 1e6c071 commit 61e9fbe

File tree

10 files changed

+34
-39
lines changed

10 files changed

+34
-39
lines changed

frontend/src/lib/components/accounts/TransactionCard.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
TransactionIconType,
1010
UiTransaction,
1111
} from "$lib/types/transaction";
12-
import { KeyValuePair, testSafeFade } from "@dfinity/gix-components";
12+
import { KeyValuePair } from "@dfinity/gix-components";
1313
import {
1414
nonNullish,
1515
type TokenAmount,
1616
type TokenAmountV2,
1717
} from "@dfinity/utils";
18+
import { fade } from "svelte/transition";
1819
1920
export let transaction: UiTransaction;
2021
@@ -55,7 +56,7 @@
5556
$: seconds = timestamp && timestamp.getTime() / 1000;
5657
</script>
5758

58-
<article data-tid="transaction-card" transition:testSafeFade>
59+
<article data-tid="transaction-card" transition:fade|global>
5960
<div class="icon">
6061
<TransactionIcon type={iconType} {isPending} />
6162
</div>

frontend/src/lib/components/common/JsonPreview.svelte

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44
import { jsonRepresentationModeStore } from "$lib/derived/json-representation.derived";
55
import { i18n } from "$lib/stores/i18n";
66
import { expandObject, getObjMaxDepth } from "$lib/utils/utils";
7-
import {
8-
IconCollapseAll,
9-
IconExpandAll,
10-
testSafeFade,
11-
} from "@dfinity/gix-components";
7+
import { IconCollapseAll, IconExpandAll } from "@dfinity/gix-components";
128
import { isNullish } from "@dfinity/utils";
9+
import { fade } from "svelte/transition";
1310
1411
const DEFAULT_EXPANDED_LEVEL = 1;
1512
@@ -41,12 +38,12 @@
4138
on:click={toggleExpanded}
4239
>
4340
{#if isAllExpanded}
44-
<div in:testSafeFade>
41+
<div in:fade>
4542
<IconCollapseAll />
4643
<span class="expand-all-label">{$i18n.core.collapse_all}</span>
4744
</div>
4845
{:else}
49-
<div in:testSafeFade>
46+
<div in:fade>
5047
<IconExpandAll />
5148
<span class="expand-all-label">{$i18n.core.expand_all}</span>
5249
</div>
@@ -55,15 +52,15 @@
5552
{/if}
5653
<div data-tid="json-wrapper" class="json-wrapper">
5754
{#if $jsonRepresentationModeStore === "tree"}
58-
<div in:testSafeFade>
55+
<div in:fade>
5956
<TreeJson
6057
testId="tree-json"
6158
json={expandedData}
6259
defaultExpandedLevel={isAllExpanded ? Number.MAX_SAFE_INTEGER : 1}
6360
/>
6461
</div>
6562
{:else}
66-
<div in:testSafeFade>
63+
<div in:fade>
6764
<RawJson testId="raw-json" {json} />
6865
</div>
6966
{/if}

frontend/src/lib/components/common/MenuItems.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
ThemeToggleButton,
2929
layoutMenuOpen,
3030
menuCollapsed,
31-
testSafeScale,
3231
} from "@dfinity/gix-components";
3332
import type { ComponentType } from "svelte";
3433
import { cubicIn, cubicOut } from "svelte/easing";
34+
import { scale } from "svelte/transition";
3535
3636
let routes: {
3737
context: string;
@@ -127,8 +127,8 @@
127127
<div
128128
data-tid="menu-footer"
129129
class="menu-footer"
130-
out:testSafeScale={{ duration: 200, easing: cubicOut }}
131-
in:testSafeScale={{ duration: 200, easing: cubicIn }}
130+
out:scale={{ duration: 200, easing: cubicOut }}
131+
in:scale={{ duration: 200, easing: cubicIn }}
132132
>
133133
<TotalValueLocked layout="stacked" />
134134
<div class="menu-footer-buttons">

frontend/src/lib/components/common/TreeJson.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
type TreeJsonValueType,
77
} from "$lib/utils/json.utils";
88
import { typeOfLikeANumber } from "$lib/utils/utils";
9-
import { IconExpandMore, testSafeFade } from "@dfinity/gix-components";
9+
import { IconExpandMore } from "@dfinity/gix-components";
10+
import { fade } from "svelte/transition";
1011
1112
export let json: unknown | undefined = undefined;
1213
export let defaultExpandedLevel = Infinity;
@@ -71,7 +72,7 @@
7172
{/if}
7273
{#if !collapsed}
7374
<!-- children of expandable-key -->
74-
<ul class:root class:is-array={isArray} in:testSafeFade data-tid={testId}>
75+
<ul class:root class:is-array={isArray} in:fade data-tid={testId}>
7576
{#each children as [key, value]}
7677
<li class:root class:key-is-index={keyIsIndex}>
7778
<svelte:self

frontend/src/lib/components/proposal-detail/VotingCard/ExpandableProposalNeurons.svelte

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
<script lang="ts">
2-
import {
3-
Collapsible,
4-
IconExpandCircleDown,
5-
testSafeFade,
6-
} from "@dfinity/gix-components";
2+
import { Collapsible, IconExpandCircleDown } from "@dfinity/gix-components";
3+
import { fade } from "svelte/transition";
74
85
export let testId: string;
96
107
let toggleContent: () => void;
118
let expanded: boolean;
129
</script>
1310

14-
<div class="container" in:testSafeFade>
11+
<div class="container" in:fade>
1512
<Collapsible
1613
{testId}
1714
expandButton={false}

frontend/src/lib/components/proposals/ActionableProposalCountBadge.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
import type { Universe } from "$lib/types/universe";
55
import { replacePlaceholders } from "$lib/utils/i18n.utils";
66
import { isUniverseNns } from "$lib/utils/universe.utils";
7-
import { Tooltip, testSafeScale } from "@dfinity/gix-components";
7+
import { Tooltip } from "@dfinity/gix-components";
88
import { Principal } from "@dfinity/principal";
99
import { cubicOut } from "svelte/easing";
10+
import { scale } from "svelte/transition";
1011
1112
export let count: number;
1213
export let universe: Universe | "all";
@@ -33,7 +34,7 @@
3334
<TestIdWrapper testId="actionable-proposal-count-badge-component">
3435
<Tooltip idPrefix="actionable-count-tooltip" text={tooltipText} top={true}
3536
><span
36-
transition:testSafeScale={{
37+
transition:scale={{
3738
duration: 250,
3839
easing: cubicOut,
3940
}}

frontend/src/lib/components/proposals/FiltersWrapper.svelte

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
<script lang="ts">
2-
import { testSafeFade } from "@dfinity/gix-components";
2+
import { fade } from "svelte/transition";
33
</script>
44

5-
<div
6-
class="filters"
7-
data-tid="proposals-filters"
8-
in:testSafeFade={{ duration: 150 }}
9-
>
5+
<div class="filters" data-tid="proposals-filters" in:fade={{ duration: 150 }}>
106
<slot />
117
</div>
128

frontend/src/lib/components/proposals/NnsProposalsList.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
import { authSignedInStore } from "$lib/derived/auth.derived";
1313
import { filteredActionableProposals } from "$lib/derived/proposals.derived";
1414
import { actionableNnsProposalsStore } from "$lib/stores/actionable-nns-proposals.store";
15-
import { InfiniteScroll, testSafeFade } from "@dfinity/gix-components";
15+
import { InfiniteScroll } from "@dfinity/gix-components";
1616
import type { ProposalInfo } from "@dfinity/nns";
1717
import { isNullish } from "@dfinity/utils";
18-
18+
import { fade } from "svelte/transition";
1919
export let hidden: boolean;
2020
export let disableInfiniteScroll: boolean;
2121
export let loading: boolean;
@@ -35,7 +35,7 @@
3535

3636
{#if display}
3737
{#if !$actionableProposalsActiveStore}
38-
<div in:testSafeFade data-tid="all-proposal-list">
38+
<div in:fade data-tid="all-proposal-list">
3939
{#if loadingAnimation === "skeleton"}
4040
<LoadingProposals />
4141
{:else if $filteredActionableProposals.proposals.length === 0}
@@ -59,7 +59,7 @@
5959
{/if}
6060
</div>
6161
{:else}
62-
<div in:testSafeFade data-tid="actionable-proposal-list">
62+
<div in:fade data-tid="actionable-proposal-list">
6363
{#if !$authSignedInStore}
6464
<ActionableProposalsSignIn />
6565
{:else if isNullish(actionableProposals)}

frontend/src/lib/components/sns-proposals/SnsProposalsList.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
import { authSignedInStore } from "$lib/derived/auth.derived";
1111
import { pageStore } from "$lib/derived/page.derived";
1212
import type { SnsProposalActionableData } from "$lib/derived/sns/sns-filtered-actionable-proposals.derived";
13-
import { InfiniteScroll, testSafeFade } from "@dfinity/gix-components";
13+
import { InfiniteScroll } from "@dfinity/gix-components";
1414
import type { SnsNervousSystemFunction } from "@dfinity/sns";
1515
import { fromNullable, isNullish } from "@dfinity/utils";
16+
import { fade } from "svelte/transition";
1617
1718
export let proposals: SnsProposalActionableData[] | undefined;
1819
export let actionableSelected: boolean;
@@ -25,7 +26,7 @@
2526
<SnsProposalsFilters />
2627

2728
{#if !actionableSelected}
28-
<div in:testSafeFade data-tid="all-proposal-list">
29+
<div in:fade data-tid="all-proposal-list">
2930
{#if proposals === undefined}
3031
<LoadingProposals />
3132
{:else if proposals.length === 0}
@@ -50,7 +51,7 @@
5051
{/if}
5152
</div>
5253
{:else}
53-
<div in:testSafeFade data-tid="actionable-proposal-list">
54+
<div in:fade data-tid="actionable-proposal-list">
5455
{#if !$authSignedInStore}
5556
<ActionableProposalsSignIn />
5657
{:else if isNullish(proposals)}

frontend/src/lib/components/universe/SelectUniverseCard.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
import { i18n } from "$lib/stores/i18n";
1616
import type { Universe } from "$lib/types/universe";
1717
import { isSelectedPath } from "$lib/utils/navigation.utils";
18-
import { Card, testSafeScale } from "@dfinity/gix-components";
18+
import { Card } from "@dfinity/gix-components";
1919
import { nonNullish } from "@dfinity/utils";
2020
import { onMount } from "svelte";
2121
import { cubicOut } from "svelte/easing";
22+
import { scale } from "svelte/transition";
2223
2324
export let selected: boolean;
2425
// "link" for desktop, "button" for mobile, "dropdown" to open the modal
@@ -73,7 +74,7 @@
7374
{#if $actionableProposalIndicationVisibleStore}
7475
{#if $actionableProposalTotalCountStore > 0 && mounted}
7576
<div
76-
in:testSafeScale={{
77+
in:scale={{
7778
duration: 250,
7879
easing: cubicOut,
7980
}}

0 commit comments

Comments
 (0)