diff --git a/frontend/.gitignore b/frontend/.gitignore index 3f6fed2db14..0f01eac67ea 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -3,7 +3,7 @@ node_modules /build /.svelte-kit /package -public +/public .env .env.* !.env.example diff --git a/frontend/.prettierignore b/frontend/.prettierignore index ae41e0b1b90..18736d02648 100644 --- a/frontend/.prettierignore +++ b/frontend/.prettierignore @@ -13,5 +13,5 @@ pnpm-lock.yaml package-lock.json yarn.lock -public -static/assets/libs +/public +/static/assets/libs diff --git a/frontend/src/lib/services/public/app.services.ts b/frontend/src/lib/services/public/app.services.ts index e1f6cce575c..d8a41dbdd4b 100644 --- a/frontend/src/lib/services/public/app.services.ts +++ b/frontend/src/lib/services/public/app.services.ts @@ -1,6 +1,6 @@ import { browser } from "$app/environment"; -import { loadSnsProjects } from "$lib/services/public/sns.services"; import { displayAndCleanLogoutMsg } from "$lib/services/auth.services"; +import { loadSnsProjects } from "$lib/services/public/sns.services"; import { authStore } from "$lib/stores/auth.store"; import { layoutAuthReady } from "$lib/stores/layout.store"; import { toastsError } from "$lib/stores/toasts.store"; diff --git a/frontend/src/lib/services/public/sns.services.ts b/frontend/src/lib/services/public/sns.services.ts index e9ae3ce2269..e961eb95a5e 100644 --- a/frontend/src/lib/services/public/sns.services.ts +++ b/frontend/src/lib/services/public/sns.services.ts @@ -82,9 +82,7 @@ export const loadProposalsSnsCF = async (): Promise => { onError: ({ error: err, certified, strategy }) => { console.error(err); - if ( - isLastCall({ strategy, certified }) - ) { + if (isLastCall({ strategy, certified })) { snsProposalsStore.reset(); toastsError( diff --git a/frontend/src/tests/lib/services/public/proposals.services.spec.ts b/frontend/src/tests/lib/services/public/proposals.services.spec.ts index bb58b485a59..d9800260941 100644 --- a/frontend/src/tests/lib/services/public/proposals.services.spec.ts +++ b/frontend/src/tests/lib/services/public/proposals.services.spec.ts @@ -3,22 +3,19 @@ import { ProposalPayloadNotFoundError, ProposalPayloadTooLargeError, } from "$lib/canisters/nns-dapp/nns-dapp.errors"; +import { getCurrentIdentity } from "$lib/services/auth.services"; import { listNextProposals, listProposals, loadProposal, loadProposalPayload, } from "$lib/services/public/proposals.services"; -import { getCurrentIdentity } from "$lib/services/auth.services"; import { proposalPayloadsStore, proposalsFiltersStore, proposalsStore, } from "$lib/stores/proposals.store"; -import { - resetIdentity, - setNoIdentity, -} from "$tests/mocks/auth.store.mock"; +import { resetIdentity, setNoIdentity } from "$tests/mocks/auth.store.mock"; import { mockProposals } from "$tests/mocks/proposals.store.mock"; import { toastsStore } from "@dfinity/gix-components"; import type { ProposalInfo } from "@dfinity/nns"; @@ -171,12 +168,14 @@ describe("proposals-services", () => { it("show no error message from api on uncertified error", async () => { const errorMessage = "Error message from api."; - vi.spyOn(api, "queryProposals").mockImplementation(async ({certified}) => { - if (!certified) { - throw new Error(errorMessage); + vi.spyOn(api, "queryProposals").mockImplementation( + async ({ certified }) => { + if (!certified) { + throw new Error(errorMessage); + } + return mockProposals; } - return mockProposals; - }); + ); await listProposals({ loadFinished: () => { // do nothing here @@ -191,8 +190,7 @@ describe("proposals-services", () => { const spyQueryProposal = vi.spyOn(api, "queryProposal"); beforeEach(() => { - spyQueryProposal.mockResolvedValue( - { ...mockProposals[0], id: 666n }); + spyQueryProposal.mockResolvedValue({ ...mockProposals[0], id: 666n }); proposalsStore.setProposalsForTesting({ proposals: mockProposals, certified: true, @@ -215,9 +213,9 @@ describe("proposals-services", () => { let spyQueryProposal; beforeEach(() => { - spyQueryProposal = vi.spyOn(api, "queryProposal").mockRejectedValue( - new Error("test-message") - ); + spyQueryProposal = vi + .spyOn(api, "queryProposal") + .mockRejectedValue(new Error("test-message")); vi.spyOn(console, "error").mockReturnValue(); }); @@ -228,10 +226,12 @@ describe("proposals-services", () => { proposalId: 0n, setProposal: vi.fn, }); - expect(get(toastsStore)).toMatchObject([{ - level: "error", - text: "An error occurred while loading the proposal. id: \"0\". test-message", - }]); + expect(get(toastsStore)).toMatchObject([ + { + level: "error", + text: 'An error occurred while loading the proposal. id: "0". test-message', + }, + ]); // `queryProposal` gave an error twice (query + update) but it should // result only in a single toast message. @@ -320,7 +320,7 @@ describe("proposals-services", () => { it("should load proposal if no identity", async () => { const spyQueryProposal = vi .spyOn(api, "queryProposal") - .mockResolvedValue({ ...mockProposals[0], id: 666n }) + .mockResolvedValue({ ...mockProposals[0], id: 666n }); expect(spyQueryProposal).not.toBeCalled(); let result; @@ -382,9 +382,9 @@ describe("proposals-services", () => { expect(get(proposalPayloadsStore)).toEqual(new Map()); await loadProposalPayload({ proposalId: 0n }); - expect(get(proposalPayloadsStore)).toEqual(new Map([ - [0n, mockProposalPayload], - ])); + expect(get(proposalPayloadsStore)).toEqual( + new Map([[0n, mockProposalPayload]]) + ); }); it("should update proposalPayloadsStore with null if the payload was not found", async () => { diff --git a/frontend/src/tests/lib/services/public/sns-proposals.services.spec.ts b/frontend/src/tests/lib/services/public/sns-proposals.services.spec.ts index 3d0e6d754c0..b789b939d06 100644 --- a/frontend/src/tests/lib/services/public/sns-proposals.services.spec.ts +++ b/frontend/src/tests/lib/services/public/sns-proposals.services.spec.ts @@ -12,10 +12,10 @@ import type { Filter, SnsProposalTypeFilterId } from "$lib/types/filters"; import { ALL_SNS_GENERIC_PROPOSAL_TYPES_ID } from "$lib/types/filters"; import { replacePlaceholders } from "$lib/utils/i18n.utils"; import { - setNoIdentity, - resetIdentity, mockIdentity, mockPrincipal, + resetIdentity, + setNoIdentity, } from "$tests/mocks/auth.store.mock"; import en from "$tests/mocks/i18n.mock"; import { diff --git a/frontend/src/tests/lib/services/public/sns.services.spec.ts b/frontend/src/tests/lib/services/public/sns.services.spec.ts index 4faec428ada..7dba4069b2a 100644 --- a/frontend/src/tests/lib/services/public/sns.services.spec.ts +++ b/frontend/src/tests/lib/services/public/sns.services.spec.ts @@ -2,15 +2,15 @@ import { clearSnsAggregatorCache } from "$lib/api-services/sns-aggregator.api-se import * as agent from "$lib/api/agent.api"; import * as aggregatorApi from "$lib/api/sns-aggregator.api"; import { clearWrapperCache, wrapper } from "$lib/api/sns-wrapper.api"; -import { loadSnsProjects } from "$lib/services/public/sns.services"; -import { snsAggregatorStore, snsAggregatorIncludingAbortedProjectsStore } from "$lib/stores/sns-aggregator.store"; import { snsFunctionsStore } from "$lib/derived/sns-functions.derived"; import { snsTotalTokenSupplyStore } from "$lib/derived/sns-total-token-supply.derived"; -import { tokensStore } from "$lib/stores/tokens.store"; +import { loadSnsProjects } from "$lib/services/public/sns.services"; import { - resetIdentity, - mockIdentity, -} from "$tests/mocks/auth.store.mock"; + snsAggregatorIncludingAbortedProjectsStore, + snsAggregatorStore, +} from "$lib/stores/sns-aggregator.store"; +import { tokensStore } from "$lib/stores/tokens.store"; +import { mockIdentity, resetIdentity } from "$tests/mocks/auth.store.mock"; import { aggregatorMockSnsesDataDto, aggregatorSnsMockDto, @@ -157,7 +157,9 @@ describe("SNS public services", () => { await loadSnsProjects(); - expect(get(snsAggregatorIncludingAbortedProjectsStore).data).toEqual(aggregatorMockSnsesDataDto); + expect(get(snsAggregatorIncludingAbortedProjectsStore).data).toEqual( + aggregatorMockSnsesDataDto + ); }); it("should load and map total token supply", async () => {