Skip to content

Commit

Permalink
e2e: add mock api structure for e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
victorgcramos committed Oct 6, 2021
1 parent 9a7e7b7 commit 81d6411
Show file tree
Hide file tree
Showing 26 changed files with 1,354 additions and 367 deletions.
17 changes: 2 additions & 15 deletions src/components/RecordsView/RecordsView.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState, useMemo, useEffect } from "react";
import { Tabs, Tab } from "pi-ui";
import LazyList from "src/components/LazyList";
import orderBy from "lodash/fp/orderBy";
import { getRecordsByTabOption } from "./helpers";
import HelpMessage from "src/components/HelpMessage";
import { useConfig } from "src/containers/Config";
Expand All @@ -21,20 +20,8 @@ const LoadingPlaceholders = ({ numberOfItems, placeholder }) => {
return <>{placeholders}</>;
};

const defaultSort = {
fields: ["timestamp"],
order: ["desc"]
};

const getFilteredRecordsAndToken = (
records,
tokens,
tab,
filterCensored,
sort = defaultSort
) => {
const getFilteredRecordsAndToken = (records, tokens, tab, filterCensored) => {
const filteredTokens = tokens[tab].map((token) => shortRecordToken(token));
const sortByNewestFirst = orderBy(sort.fields, sort.order);
let filteredRecords =
(records &&
filteredTokens &&
Expand All @@ -45,7 +32,7 @@ const getFilteredRecordsAndToken = (
({ status }) => status !== PROPOSAL_STATUS_CENSORED
);
}
return [sortByNewestFirst(filteredRecords), filteredTokens];
return [filteredRecords, filteredTokens];
};

const getDefaultEmptyMessage = () => "No records available";
Expand Down
6 changes: 2 additions & 4 deletions src/containers/Proposal/Vetted/Vetted.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useMemo } from "react";
import isEmpty from "lodash/fp/isEmpty";
import styles from "./VettedProposals.module.css";
import { tabValues, statusByTab, sortByTab } from "./helpers";
import { tabValues, statusByTab } from "./helpers";
import { mapProposalsTokensByTab } from "src/containers/Proposal/helpers";
import useProposalsBatch from "src/hooks/api/useProposalsBatch";
import useLegacyVettedProposals from "src/hooks/api/useLegacyVettedProposals";
Expand All @@ -28,7 +28,6 @@ const tabLabels = [
const VettedProposals = ({ TopBanner, PageDetails, Sidebar, Main }) => {
const [index, onSetIndex] = useQueryStringWithIndexValue("tab", 0, tabLabels);
const statuses = statusByTab[tabLabels[index]];
const sort = sortByTab[tabLabels[index]];
const {
proposals: batchProposals,
proposalsTokens,
Expand Down Expand Up @@ -129,8 +128,7 @@ const VettedProposals = ({ TopBanner, PageDetails, Sidebar, Main }) => {
onFetchMoreProposals={onFetchMoreProposals}
dropdownTabsForMobile
hasMore={hasMoreProposals}
isLoading={loading || verifying || mdLoading}
sort={sort}>
isLoading={loading || verifying || mdLoading}>
{content}
</RecordsView>
);
Expand Down
9 changes: 0 additions & 9 deletions src/containers/Proposal/Vetted/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,3 @@ export const statusByTab = {
[tabValues.REJECTED]: [PROPOSAL_VOTING_REJECTED],
[tabValues.INELIGIBLE]: [PROPOSAL_VOTING_INELIGIBLE]
};

export const sortByTab = {
[tabValues.UNDER_REVIEW]: {
fields: ["voteStatus", "timestamp"],
order: ["desc", "desc"]
}
// For other tabs = undefined (get the default)
// { fields: ["timestamp"], order: ["desc"] }
};

0 comments on commit 81d6411

Please sign in to comment.