Skip to content

Commit 09b6cf1

Browse files
authored
chore(cleanup): remove import token feature flag (#6912)
# Motivation The nns-dapp uses feature flags to introduce new features into the `main` branch without disrupting existing flows. Some of these feature flags have been in the code for a long time, so we want to remove them. This PR removes the feature flags introduced in #6209. # Changes - Removes `ENABLE_IMPORT_TOKEN_BY_URL` feature flag. - Eliminates tests that check the UI behavior when the feature flag is off. - Updates tests to reflect the UI behavior when the feature flag is on, as this is the default behavior. # Tests - The pipeline should pass as before. - Tested in [devenv](https://qsgjb-riaaa-aaaaa-aaaga-cai.yhabib-ingress.devenv.dfinity.network) # Todos - [ ] Add entry to changelog (if necessary). Not necessary.
1 parent fcf4e2c commit 09b6cf1

File tree

15 files changed

+26
-109
lines changed

15 files changed

+26
-109
lines changed

config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
"ENABLE_USD_VALUES": true,
9595
"ENABLE_USD_VALUES_FOR_NEURONS": true,
9696
"ENABLE_PORTFOLIO_PAGE": true,
97-
"ENABLE_IMPORT_TOKEN_BY_URL": true,
9897
"ENABLE_SNS_TOPICS": true
9998
}
10099
}

frontend/src/lib/constants/environment.constants.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export interface FeatureFlags<T> {
2323
// Used only in tests and set up in jest-setup.ts
2424
TEST_FLAG_EDITABLE: T;
2525
TEST_FLAG_NOT_EDITABLE: T;
26-
ENABLE_IMPORT_TOKEN_BY_URL: T;
2726
ENABLE_SNS_TOPICS: T;
2827
}
2928
export const defaultFeatureFlagValues: FeatureFlags<boolean> = {
@@ -35,7 +34,6 @@ export const defaultFeatureFlagValues: FeatureFlags<boolean> = {
3534
ENABLE_PORTFOLIO_PAGE: false,
3635
TEST_FLAG_EDITABLE: false,
3736
TEST_FLAG_NOT_EDITABLE: false,
38-
ENABLE_IMPORT_TOKEN_BY_URL: false,
3937
ENABLE_SNS_TOPICS: false,
4038
};
4139

frontend/src/lib/modals/accounts/ImportTokenModal.svelte

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
import ImportTokenForm from "$lib/components/accounts/ImportTokenForm.svelte";
44
import ImportTokenReview from "$lib/components/accounts/ImportTokenReview.svelte";
55
import { LEDGER_CANISTER_ID } from "$lib/constants/canister-ids.constants";
6+
import { AppPath } from "$lib/constants/routes.constants";
7+
import { pageStore } from "$lib/derived/page.derived";
68
import { snsProjectsCommittedStore } from "$lib/derived/sns/sns-projects.derived";
79
import { getIcrcTokenMetaData } from "$lib/services/icrc-accounts.services";
810
import { matchLedgerIndexPair } from "$lib/services/icrc-index.services";
911
import { addImportedToken } from "$lib/services/imported-tokens.services";
1012
import { startBusy, stopBusy } from "$lib/stores/busy.store";
11-
import {
12-
DISABLE_IMPORT_TOKEN_VALIDATION_FOR_TESTING,
13-
ENABLE_IMPORT_TOKEN_BY_URL,
14-
} from "$lib/stores/feature-flags.store";
13+
import { DISABLE_IMPORT_TOKEN_VALIDATION_FOR_TESTING } from "$lib/stores/feature-flags.store";
1514
import { i18n } from "$lib/stores/i18n";
1615
import { importedTokensStore } from "$lib/stores/imported-tokens.store";
1716
import { toastsError, toastsShow } from "$lib/stores/toasts.store";
@@ -29,8 +28,6 @@
2928
import { isNullish, nonNullish } from "@dfinity/utils";
3029
import { createEventDispatcher } from "svelte";
3130
import { get } from "svelte/store";
32-
import { AppPath } from "$lib/constants/routes.constants";
33-
import { pageStore } from "$lib/derived/page.derived";
3431
3532
let currentStep: WizardStep | undefined = undefined;
3633
@@ -73,7 +70,6 @@
7370
let isLedgerCanisterIdProcessed = false;
7471
$: {
7572
if (
76-
$ENABLE_IMPORT_TOKEN_BY_URL &&
7773
!isLedgerCanisterIdProcessed &&
7874
isNullish(ledgerCanisterId) &&
7975
nonNullish($pageStore.importTokenLedgerId)
@@ -85,7 +81,6 @@
8581
let isIndexCanisterIdProcessed = false;
8682
$: {
8783
if (
88-
$ENABLE_IMPORT_TOKEN_BY_URL &&
8984
!isIndexCanisterIdProcessed &&
9085
isNullish(indexCanisterId) &&
9186
nonNullish($pageStore.importTokenIndexId)
@@ -97,7 +92,6 @@
9792
9893
let isAutoSubmitDone = false;
9994
$: if (
100-
$ENABLE_IMPORT_TOKEN_BY_URL &&
10195
!isAutoSubmitDone &&
10296
// Wait for the imported tokens to be loaded (for successful validation).
10397
nonNullish($importedTokensStore?.importedTokens)

frontend/src/lib/pages/SignInTokens.svelte

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import { authSignedInStore } from "$lib/derived/auth.derived";
66
import { pageStore } from "$lib/derived/page.derived";
77
import ImportTokenModal from "$lib/modals/accounts/ImportTokenModal.svelte";
8-
import { ENABLE_IMPORT_TOKEN_BY_URL } from "$lib/stores/feature-flags.store";
98
import { i18n } from "$lib/stores/i18n";
109
import type { UserToken } from "$lib/types/tokens-page";
1110
import { IconAccountsPage, PageBanner } from "@dfinity/gix-components";
@@ -14,12 +13,10 @@
1413
export let userTokensData: UserToken[];
1514
let showImportTokenModal = false;
1615
$: showImportTokenModal =
17-
$ENABLE_IMPORT_TOKEN_BY_URL &&
1816
// Since there are two ImportTokenModals on both Tokens and SignInTokens pages,
1917
// we need to hide this modal after a successful sign-in to
2018
// prevent it from blocking this component’s destruction.
21-
!$authSignedInStore &&
22-
nonNullish($pageStore.importTokenLedgerId);
19+
!$authSignedInStore && nonNullish($pageStore.importTokenLedgerId);
2320
</script>
2421

2522
<TestIdWrapper testId="sign-in-tokens-page-component">

frontend/src/lib/pages/Tokens.svelte

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<script lang="ts">
22
import HideZeroBalancesToggle from "$lib/components/tokens/TokensTable/HideZeroBalancesToggle.svelte";
33
import TokensTable from "$lib/components/tokens/TokensTable/TokensTable.svelte";
4+
import Separator from "$lib/components/ui/Separator.svelte";
45
import UsdValueBanner from "$lib/components/ui/UsdValueBanner.svelte";
56
import { OWN_CANISTER_ID_TEXT } from "$lib/constants/canister-ids.constants";
67
import { MAX_IMPORTED_TOKENS } from "$lib/constants/imported-tokens.constants";
78
import { pageStore } from "$lib/derived/page.derived";
89
import ImportTokenModal from "$lib/modals/accounts/ImportTokenModal.svelte";
9-
import {
10-
ENABLE_IMPORT_TOKEN_BY_URL,
11-
ENABLE_USD_VALUES,
12-
} from "$lib/stores/feature-flags.store";
10+
import { ENABLE_USD_VALUES } from "$lib/stores/feature-flags.store";
1311
import { hideZeroBalancesStore } from "$lib/stores/hide-zero-balances.store";
1412
import { i18n } from "$lib/stores/i18n";
1513
import { importedTokensStore } from "$lib/stores/imported-tokens.store";
@@ -21,7 +19,6 @@
2119
import { getTotalBalanceInUsd } from "$lib/utils/token.utils";
2220
import { IconHeldTokens, IconPlus, Tooltip } from "@dfinity/gix-components";
2321
import { TokenAmountV2, isNullish, nonNullish } from "@dfinity/utils";
24-
import Separator from "$lib/components/ui/Separator.svelte";
2522
2623
export let userTokensData: UserToken[];
2724
@@ -134,7 +131,7 @@
134131
</div>
135132
</TokensTable>
136133

137-
{#if showImportTokenModal || ($ENABLE_IMPORT_TOKEN_BY_URL && nonNullish($pageStore.importTokenLedgerId))}
134+
{#if showImportTokenModal || nonNullish($pageStore.importTokenLedgerId)}
138135
<ImportTokenModal on:nnsClose={() => (showImportTokenModal = false)} />
139136
{/if}
140137
</div>

frontend/src/lib/stores/feature-flags.store.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export const EDITABLE_FEATURE_FLAGS: Array<FeatureKey> = [
3737
"ENABLE_USD_VALUES",
3838
"ENABLE_USD_VALUES_FOR_NEURONS",
3939
"ENABLE_PORTFOLIO_PAGE",
40-
"ENABLE_IMPORT_TOKEN_BY_URL",
4140
"ENABLE_SNS_TOPICS",
4241
];
4342

@@ -159,6 +158,5 @@ export const {
159158
// Used only in tests only
160159
TEST_FLAG_EDITABLE,
161160
TEST_FLAG_NOT_EDITABLE,
162-
ENABLE_IMPORT_TOKEN_BY_URL,
163161
ENABLE_SNS_TOPICS,
164162
} = featureFlagsStore;

frontend/src/tests/lib/components/accounts/ImportTokenForm.svelte.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import ImportTokenForm from "$lib/components/accounts/ImportTokenForm.svelte";
2-
import { overrideFeatureFlagsStore } from "$lib/stores/feature-flags.store";
32
import { resetIdentity, setNoIdentity } from "$tests/mocks/auth.store.mock";
43
import { principal } from "$tests/mocks/sns-projects.mock";
54
import { ImportTokenFormPo } from "$tests/page-objects/ImportTokenForm.page-object";
@@ -40,7 +39,6 @@ describe("ImportTokenForm", () => {
4039

4140
beforeEach(() => {
4241
resetIdentity();
43-
overrideFeatureFlagsStore.setFlag("ENABLE_IMPORT_TOKEN_BY_URL", true);
4442
});
4543

4644
it("should render ledger canister id", async () => {

frontend/src/tests/lib/components/accounts/ImportTokenModal.spec.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { CKBTC_LEDGER_CANISTER_ID } from "$lib/constants/ckbtc-canister-ids.cons
99
import { AppPath } from "$lib/constants/routes.constants";
1010
import { pageStore } from "$lib/derived/page.derived";
1111
import ImportTokenModal from "$lib/modals/accounts/ImportTokenModal.svelte";
12-
import { overrideFeatureFlagsStore } from "$lib/stores/feature-flags.store";
1312
import { importedTokensStore } from "$lib/stores/imported-tokens.store";
1413
import type { IcrcTokenMetadata } from "$lib/types/icrc";
1514
import { page } from "$mocks/$app/stores";
@@ -484,7 +483,6 @@ describe("ImportTokenModal", () => {
484483
importTokenIndexId: indexCanisterId.toText(),
485484
},
486485
});
487-
overrideFeatureFlagsStore.setFlag("ENABLE_IMPORT_TOKEN_BY_URL", true);
488486
});
489487

490488
it("imports from URL", async () => {
@@ -591,29 +589,6 @@ describe("ImportTokenModal", () => {
591589
});
592590
});
593591

594-
it("does not auto validate when feature flag disabled", async () => {
595-
overrideFeatureFlagsStore.setFlag("ENABLE_IMPORT_TOKEN_BY_URL", false);
596-
vi.spyOn(importedTokensApi, "getImportedTokens").mockResolvedValue({
597-
imported_tokens: [],
598-
});
599-
vi.spyOn(importedTokensApi, "setImportedTokens").mockResolvedValue();
600-
601-
importedTokensStore.set({
602-
importedTokens: [],
603-
certified: true,
604-
});
605-
606-
const po = renderComponent();
607-
const formPo = po.getImportTokenFormPo();
608-
const reviewPo = po.getImportTokenReviewPo();
609-
610-
await runResolvedPromises();
611-
612-
// Should stay as form step
613-
expect(await formPo.isPresent()).toEqual(true);
614-
expect(await reviewPo.isPresent()).toEqual(false);
615-
});
616-
617592
it("should navigate to the imported token page when importing a duplicate", async () => {
618593
importedTokensStore.set({
619594
importedTokens: [

frontend/src/tests/lib/pages/Tokens.spec.ts

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -296,48 +296,23 @@ describe("Tokens page", () => {
296296
expect(await po.getImportTokenModalPo().isPresent()).toBe(true);
297297
});
298298

299-
describe("when ENABLE_IMPORT_TOKEN_BY_URL disabled", () => {
300-
beforeEach(() => {
301-
overrideFeatureFlagsStore.setFlag("ENABLE_IMPORT_TOKEN_BY_URL", false);
302-
});
303-
304-
it("doesn't open import token modal when ledger canister id in URL", async () => {
305-
page.mock({
306-
routeId: AppPath.Tokens,
307-
data: {
308-
universe: OWN_CANISTER_ID_TEXT,
309-
importTokenLedgerId: principal(1).toText(),
310-
},
311-
});
312-
const po = renderPage([positiveBalance, zeroBalance]);
313-
314-
expect(await po.getImportTokenModalPo().isPresent()).toBe(false);
315-
});
316-
});
317-
318-
describe("when ENABLE_IMPORT_TOKEN_BY_URL enabled", () => {
319-
beforeEach(() => {
320-
overrideFeatureFlagsStore.setFlag("ENABLE_IMPORT_TOKEN_BY_URL", true);
299+
it("opens import token modal when ledger canister id in URL", async () => {
300+
vi.spyOn(ledgerApi, "queryIcrcToken").mockResolvedValue({
301+
name: "Tetris",
302+
symbol: "TET",
303+
logo: "https://tetris.tet/logo.png",
304+
} as IcrcTokenMetadata);
305+
306+
page.mock({
307+
routeId: AppPath.Tokens,
308+
data: {
309+
universe: OWN_CANISTER_ID_TEXT,
310+
importTokenLedgerId: principal(1).toText(),
311+
},
321312
});
313+
const po = renderPage([positiveBalance, zeroBalance]);
322314

323-
it("opens import token modal when ledger canister id in URL", async () => {
324-
vi.spyOn(ledgerApi, "queryIcrcToken").mockResolvedValue({
325-
name: "Tetris",
326-
symbol: "TET",
327-
logo: "https://tetris.tet/logo.png",
328-
} as IcrcTokenMetadata);
329-
330-
page.mock({
331-
routeId: AppPath.Tokens,
332-
data: {
333-
universe: OWN_CANISTER_ID_TEXT,
334-
importTokenLedgerId: principal(1).toText(),
335-
},
336-
});
337-
const po = renderPage([positiveBalance, zeroBalance]);
338-
339-
expect(await po.getImportTokenModalPo().isPresent()).toBe(true);
340-
});
315+
expect(await po.getImportTokenModalPo().isPresent()).toBe(true);
341316
});
342317
});
343318

frontend/src/tests/routes/app/tokens/page.spec.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,25 +1136,12 @@ describe("Tokens route", () => {
11361136
});
11371137

11381138
it("opens import token modal when ledger canister id in URL", async () => {
1139-
overrideFeatureFlagsStore.setFlag("ENABLE_IMPORT_TOKEN_BY_URL", true);
1140-
11411139
const po = await renderPage();
11421140
await runResolvedPromises();
11431141

11441142
expect(
11451143
await po.getSignInTokensPagePo().getImportTokenModalPo().isPresent()
11461144
).toBe(true);
11471145
});
1148-
1149-
it("does not open import token modal when flag disabled", async () => {
1150-
overrideFeatureFlagsStore.setFlag("ENABLE_IMPORT_TOKEN_BY_URL", false);
1151-
1152-
const po = await renderPage();
1153-
await runResolvedPromises();
1154-
1155-
expect(
1156-
await po.getSignInTokensPagePo().getImportTokenModalPo().isPresent()
1157-
).toBe(false);
1158-
});
11591146
});
11601147
});

0 commit comments

Comments
 (0)