Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,27 @@ import { VoteRequest } from '@daml.js/splice-dso-governance/lib/Splice/DsoRules'
import { MemoryRouter } from 'react-router';
import dayjs from 'dayjs';
import { dateTimeFormatISO } from '@canton-network/splice-common-frontend-utils';
import { svPartyId, voteRequests } from '../mocks/constants';

const sampleContractId = voteRequests.dso_rules_vote_requests[0]
.contract_id as ContractId<VoteRequest>;

const requests: ActionRequiredData[] = [
{
actionName: 'Feature Application',
description: 'Test description for feature application',
contractId: '2abcde123456' as ContractId<VoteRequest>,
contractId: sampleContractId,
votingCloses: '2024-09-25 11:00',
createdAt: '2024-09-25 11:00',
requester: 'sv1',
requester: svPartyId,
},
{
actionName: 'Set DSO Rules Configuration',
description: 'Test description for DSO rules configuration',
contractId: '2bcde123456' as ContractId<VoteRequest>,
contractId: voteRequests.dso_rules_vote_requests[1].contract_id as ContractId<VoteRequest>,
votingCloses: '2024-09-25 11:00',
createdAt: '2024-09-25 11:00',
requester: 'sv2',
isYou: true,
requester: svPartyId,
},
];

Expand Down Expand Up @@ -76,10 +79,10 @@ describe('Action Required', () => {
const actionRequired = {
actionName: 'Feature Application',
description: 'Test description',
contractId: '2abcde123456' as ContractId<VoteRequest>,
contractId: sampleContractId,
votingCloses: closesDate,
createdAt: createdDate,
requester: 'sv1',
requester: svPartyId,
};

render(
Expand All @@ -104,23 +107,22 @@ describe('Action Required', () => {
expect(votingCloses).toBeInTheDocument();
expect(votingCloses.textContent).toBe('10 days');

const requester = screen.getByTestId('action-required-requester-identifier-value');
expect(requester).toBeInTheDocument();
expect(requester.textContent).toBe(actionRequired.requester);
const submittedBy = screen.getByTestId('action-required-submitted-by-identifier-value');
expect(submittedBy).toBeInTheDocument();
expect(submittedBy.textContent).toBe(svPartyId);

const viewDetails = screen.getByTestId('action-required-view-details');
expect(viewDetails).toBeInTheDocument();
});

test('should render isYou badge for requests created by viewing sv', () => {
test('should render submitted by with copy button and no You badge', () => {
const actionRequired = {
actionName: 'Feature Application',
description: 'Test description',
contractId: '2abcde123456' as ContractId<VoteRequest>,
contractId: sampleContractId,
votingCloses: '2029-09-25 11:00',
createdAt: '2029-09-25 11:00',
requester: 'sv1',
isYou: true,
requester: svPartyId,
};

render(
Expand All @@ -129,18 +131,22 @@ describe('Action Required', () => {
</MemoryRouter>
);

const isYou = screen.getByTestId('action-required-requester-identifier-badge');
expect(isYou).toBeInTheDocument();
expect(
screen.getByTestId('action-required-submitted-by-identifier-copy-button')
).toBeInTheDocument();
expect(
screen.queryByTestId('action-required-submitted-by-identifier-badge')
).not.toBeInTheDocument();
});

test('should not render isYou badge for requests created by other svs', () => {
test('should render vote proposal contract id with full value', () => {
const actionRequired = {
actionName: 'Feature Application',
description: 'Test description',
contractId: '2abcde123456' as ContractId<VoteRequest>,
contractId: sampleContractId,
votingCloses: '2029-09-25 11:00',
createdAt: '2029-09-25 11:00',
requester: 'sv1',
requester: svPartyId,
};

render(
Expand All @@ -149,8 +155,8 @@ describe('Action Required', () => {
</MemoryRouter>
);

const isYou = screen.queryByTestId('action-required-requester-identifier-badge');

expect(isYou).not.toBeInTheDocument();
expect(screen.getByTestId('action-required-contract-id-value').textContent).toBe(
sampleContractId
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '../../components/governance/ActionRequiredSection';
import { ProposalListingSection } from '../../components/governance/ProposalListingSection';
import { ProposalListingData } from '../../utils/types';
import { svPartyId } from '../mocks/constants';

describe('Governance Page Sorting', () => {
describe('Action Required Section', () => {
Expand All @@ -22,23 +23,23 @@ describe('Governance Page Sorting', () => {
contractId: 'c' as ContractId<VoteRequest>,
votingCloses: '2025-01-25 12:00',
createdAt: '2025-01-10 12:00',
requester: 'sv1',
requester: svPartyId,
},
{
actionName: 'Action A - Earliest',
description: 'Test description',
contractId: 'a' as ContractId<VoteRequest>,
votingCloses: '2025-01-15 10:00',
createdAt: '2025-01-10 12:00',
requester: 'sv1',
requester: svPartyId,
},
{
actionName: 'Action B - Middle',
description: 'Test description',
contractId: 'b' as ContractId<VoteRequest>,
votingCloses: '2025-01-15 18:00',
createdAt: '2025-01-10 12:00',
requester: 'sv1',
requester: svPartyId,
},
];

Expand Down Expand Up @@ -69,6 +70,7 @@ describe('Governance Page Sorting', () => {
yourVote: 'accepted',
status: 'In Progress',
acceptanceThreshold: BigInt(11),
requester: svPartyId,
};

test('should sort with Threshold items first (by votes desc, then deadline asc), then dated items by effective date asc', () => {
Expand Down Expand Up @@ -153,6 +155,7 @@ describe('Governance Page Sorting', () => {
status: 'Implemented',
voteStats: { accepted: 8, rejected: 2, 'no-vote': 1 },
acceptanceThreshold: BigInt(11),
requester: svPartyId,
};

test('renders in backend order without client re-sorting', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ import { VoteRequest } from '@daml.js/splice-dso-governance/lib/Splice/DsoRules'
import { ContractId } from '@daml/types';
import { ProposalListingData } from '../../utils/types';
import { MemoryRouter } from 'react-router';
import { svPartyId, voteRequests } from '../mocks/constants';

const sampleContractId = voteRequests.dso_rules_vote_requests[0]
.contract_id as ContractId<VoteRequest>;

const inflightVoteRequests: ProposalListingData[] = [
{
actionName: 'Feature Application',
contractId: '2abcde123456' as ContractId<VoteRequest>,
contractId: sampleContractId,
requester: svPartyId,
votingThresholdDeadline: '2025-09-25 11:00',
voteTakesEffect: '2025-09-26 11:00',
yourVote: 'no-vote',
Expand All @@ -21,7 +26,8 @@ const inflightVoteRequests: ProposalListingData[] = [
},
{
actionName: 'Set DSO Rules Configuration',
contractId: 'bcde123456' as ContractId<VoteRequest>,
contractId: voteRequests.dso_rules_vote_requests[1].contract_id as ContractId<VoteRequest>,
requester: svPartyId,
votingThresholdDeadline: '2025-09-25 11:00',
voteTakesEffect: '2025-09-26 11:00',
yourVote: 'accepted',
Expand All @@ -34,7 +40,8 @@ const inflightVoteRequests: ProposalListingData[] = [
const voteHistory: ProposalListingData[] = [
{
actionName: 'Feature Application',
contractId: '2abcde123456' as ContractId<VoteRequest>,
contractId: sampleContractId,
requester: svPartyId,
votingThresholdDeadline: '2025-09-25 11:00',
voteTakesEffect: '2025-09-26 11:00',
yourVote: 'no-vote',
Expand All @@ -44,7 +51,8 @@ const voteHistory: ProposalListingData[] = [
},
{
actionName: 'Set DSO Rules Configuration',
contractId: '2bcde123456' as ContractId<VoteRequest>,
contractId: voteRequests.dso_rules_vote_requests[1].contract_id as ContractId<VoteRequest>,
requester: svPartyId,
votingThresholdDeadline: '2025-09-25 11:00',
voteTakesEffect: '2025-09-26 11:00',
yourVote: 'accepted',
Expand Down Expand Up @@ -93,6 +101,8 @@ describe('Inflight Vote Requests', () => {
const uniqueId = 'proposals-request';
const data = {
actionName: 'Feature Application',
contractId: sampleContractId,
requester: svPartyId,
votingThresholdDeadline: '2025-09-25 11:00',
voteTakesEffect: '2025-09-26 11:00',
yourVote: 'no-vote',
Expand Down Expand Up @@ -136,10 +146,49 @@ describe('Inflight Vote Requests', () => {
expect(yourVote.textContent).toMatch(/No Vote/);
});

test('should render submitted by column with full party id and copy button', () => {
const uniqueId = 'proposals-request';
const data = {
actionName: 'Feature Application',
contractId: sampleContractId,
requester: svPartyId,
votingThresholdDeadline: '2025-09-25 11:00',
voteTakesEffect: '2025-09-26 11:00',
yourVote: 'accepted',
status: 'In Progress',
voteStats: { accepted: 0, rejected: 0, 'no-vote': 0 },
acceptanceThreshold: BigInt(11),
} as ProposalListingData;

render(
<MemoryRouter>
<ProposalListingSection
sectionTitle="Inflight Vote Requests"
data={[data]}
noDataMessage="No Inflight Vote Requests available"
uniqueId={uniqueId}
/>
</MemoryRouter>
);

expect(screen.getByText('SUBMITTED BY')).toBeInTheDocument();
expect(screen.getByTestId(`${uniqueId}-row-submitted-by-identifier-value`).textContent).toBe(
svPartyId
);
expect(
screen.getByTestId(`${uniqueId}-row-submitted-by-identifier-copy-button`)
).toBeInTheDocument();
expect(
screen.queryByTestId(`${uniqueId}-row-submitted-by-identifier-badge`)
).not.toBeInTheDocument();
});

test('should render Accepted inflight vote request', () => {
const uniqueId = 'proposals-request';
const data = {
actionName: 'Feature Application',
contractId: sampleContractId,
requester: svPartyId,
votingThresholdDeadline: '2025-09-25 11:00',
voteTakesEffect: '2025-09-26 11:00',
yourVote: 'accepted',
Expand Down Expand Up @@ -171,6 +220,8 @@ describe('Inflight Vote Requests', () => {
const uniqueId = 'proposals-request';
const data = {
actionName: 'Feature Application',
contractId: sampleContractId,
requester: svPartyId,
votingThresholdDeadline: '2025-09-25 11:00',
voteTakesEffect: '2025-09-26 11:00',
yourVote: 'rejected',
Expand Down Expand Up @@ -255,6 +306,8 @@ describe('Vote history', () => {
const uniqueId = 'vote-history';
const data = {
actionName: 'Feature Application',
contractId: sampleContractId,
requester: svPartyId,
votingThresholdDeadline: '2024-09-25 11:00',
voteTakesEffect: '2024-09-26 11:00',
yourVote: 'accepted',
Expand Down
Loading
Loading