Skip to content
Merged
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
7 changes: 4 additions & 3 deletions apps/common/frontend-test-vite-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
export default {
test: {
disableConsoleIntercept: true,
environment: 'happy-dom',
exclude: ['../lib/**'],
silent: false,
testTimeout: 15000,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main change is here. The rest is just formatting and removing individual timeouts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tried setting this to 1 and checking that all tests fail after a timeout? I once tried to change it and miserably failed, but might be due to commons needing rebuilding and such

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha yeah that i'll be because of the 2 config files we have here. Almost caught me off guard too. The config in index is what we seem to be using so I'll create a tech debt to remove the other config(hopefully it's straightforward).

typecheck: {
include: ['**/*.{test,spec}-d.?(c|m)[jt]s?(x)', '**/*.{test,spec}.?(c|m)[jt]s?(x)'],
},
exclude: ['../lib/**'],
silent: false,
disableConsoleIntercept: true,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('SV user can', () => {
});
});

describe('Set Amulet Config Rules Form', { timeout: 5000 }, () => {
describe('Set Amulet Config Rules Form', () => {
test('should render all Set Amulet Config Rules Form components', () => {
render(
<Wrapper>
Expand Down Expand Up @@ -81,45 +81,41 @@ describe('Set Amulet Config Rules Form', { timeout: 5000 }, () => {
);
});

test(
'should render errors when submit button is clicked on new form',
async () => {
const user = userEvent.setup();
test('should render errors when submit button is clicked on new form', async () => {
const user = userEvent.setup();

render(
<Wrapper>
<SetAmuletConfigRulesForm />
</Wrapper>
);
render(
<Wrapper>
<SetAmuletConfigRulesForm />
</Wrapper>
);

const actionInput = screen.getByTestId('set-amulet-config-rules-action');
const submitButton = screen.getByTestId('submit-button');
expect(submitButton).toBeDefined();
const actionInput = screen.getByTestId('set-amulet-config-rules-action');
const submitButton = screen.getByTestId('submit-button');
expect(submitButton).toBeDefined();

await user.click(submitButton);
expect(submitButton.getAttribute('disabled')).toBeDefined();
await expect(async () => await user.click(submitButton)).rejects.toThrowError(
/Unable to perform pointer interaction/
);
await user.click(submitButton);
expect(submitButton.getAttribute('disabled')).toBeDefined();
await expect(async () => await user.click(submitButton)).rejects.toThrowError(
/Unable to perform pointer interaction/
);

expect(screen.getByText('Summary is required')).toBeDefined();
expect(screen.getByText('Invalid URL')).toBeDefined();
expect(screen.getByText('Summary is required')).toBeDefined();
expect(screen.getByText('Invalid URL')).toBeDefined();

// completing the form should reenable the submit button
const summaryInput = screen.getByTestId('set-amulet-config-rules-summary');
expect(summaryInput).toBeDefined();
await user.type(summaryInput, 'Summary of the proposal');
// completing the form should reenable the submit button
const summaryInput = screen.getByTestId('set-amulet-config-rules-summary');
expect(summaryInput).toBeDefined();
await user.type(summaryInput, 'Summary of the proposal');

const urlInput = screen.getByTestId('set-amulet-config-rules-url');
expect(urlInput).toBeDefined();
await user.type(urlInput, 'https://example.com');
const urlInput = screen.getByTestId('set-amulet-config-rules-url');
expect(urlInput).toBeDefined();
await user.type(urlInput, 'https://example.com');

await user.click(actionInput); // using this to trigger the onBlur event which triggers the validation
await user.click(actionInput); // using this to trigger the onBlur event which triggers the validation

expect(submitButton.getAttribute('disabled')).toBeNull();
},
{ timeout: 10000 }
);
expect(submitButton.getAttribute('disabled')).toBeNull();
});

test('expiry date must be in the future', async () => {
const user = userEvent.setup();
Expand Down Expand Up @@ -240,7 +236,7 @@ describe('Set Amulet Config Rules Form', { timeout: 5000 }, () => {
expect(screen.getByText(PROPOSAL_SUMMARY_TITLE)).toBeDefined();
});

test('should show error on form if submission fails', { timeout: 10000 }, async () => {
test('should show error on form if submission fails', async () => {
server.use(
rest.post(`${svUrl}/v0/admin/sv/voterequest/create`, (_, res, ctx) => {
return res(ctx.status(503), ctx.json({ error: 'Service Unavailable' }));
Expand Down
186 changes: 87 additions & 99 deletions apps/sv/frontend/src/__tests__/sv.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Expiration
expect(await screen.findByText('Vote Requests')).toBeDefined();
});

test('see proper time format in popup', { timeout: 10000 }, async () => {
test('see proper time format in popup', async () => {
const user = userEvent.setup();
render(<AppWithConfig />);

Expand Down Expand Up @@ -190,131 +190,119 @@ describe('An SetConfig request', () => {
).toBe(true);
});

test(
'displays a warning when an SV tries to modify a DsoRules field already changed by another request',
{ timeout: 10000 },
async () => {
const user = userEvent.setup();
render(<AppWithConfig />);
test('displays a warning when an SV tries to modify a DsoRules field already changed by another request', async () => {
const user = userEvent.setup();
render(<AppWithConfig />);

expect(await screen.findByText('Governance')).toBeDefined();
await user.click(screen.getByText('Governance'));
expect(await screen.findByText('Governance')).toBeDefined();
await user.click(screen.getByText('Governance'));

expect(await screen.findByText('Vote Requests')).toBeDefined();
expect(await screen.findByText('Governance')).toBeDefined();
expect(await screen.findByText('Vote Requests')).toBeDefined();
expect(await screen.findByText('Governance')).toBeDefined();

changeAction('SRARC_SetConfig');
changeAction('SRARC_SetConfig');

const input = screen.getByTestId(
'decentralizedSynchronizer.synchronizers.0.1.acsCommitmentReconciliationInterval-value'
);
await user.clear(input);
await user.type(input, '481516');
expect(await screen.findByDisplayValue('481516')).toBeDefined();
const input = screen.getByTestId(
'decentralizedSynchronizer.synchronizers.0.1.acsCommitmentReconciliationInterval-value'
);
await user.clear(input);
await user.type(input, '481516');
expect(await screen.findByDisplayValue('481516')).toBeDefined();

const summaryInput = screen.getByTestId('create-reason-summary');
await user.type(summaryInput, 'summaryABC');
expect(await screen.findByDisplayValue('summaryABC')).toBeDefined();
const summaryInput = screen.getByTestId('create-reason-summary');
await user.type(summaryInput, 'summaryABC');
expect(await screen.findByDisplayValue('summaryABC')).toBeDefined();

const urlInput = screen.getByTestId('create-reason-url');
await user.type(urlInput, 'https://vote-request.url');
const urlInput = screen.getByTestId('create-reason-url');
await user.type(urlInput, 'https://vote-request.url');

const warning = screen.getByTestId('voterequest-creation-alert');
expect(warning).toBeDefined();
expect(warning.textContent).toContain(
'A Vote Request aiming to change similar fields already exists. ' +
'You are therefore not allowed to modify the fields: decentralizedSynchronizer.synchronizers.acsCommitmentReconciliationInterval'
);
const warning = screen.getByTestId('voterequest-creation-alert');
expect(warning).toBeDefined();
expect(warning.textContent).toContain(
'A Vote Request aiming to change similar fields already exists. ' +
'You are therefore not allowed to modify the fields: decentralizedSynchronizer.synchronizers.acsCommitmentReconciliationInterval'
);

const button = screen.getByRole('button', { name: 'Send Request to Super Validators' });
expect(button.getAttribute('disabled')).toBeDefined();
}
);
const button = screen.getByRole('button', { name: 'Send Request to Super Validators' });
expect(button.getAttribute('disabled')).toBeDefined();
});

test(
'displays a warning when an SV tries to modify an AmuletRules field already changed by another request',
{ timeout: 10000 },
async () => {
const user = userEvent.setup();
render(<AppWithConfig />);
test('displays a warning when an SV tries to modify an AmuletRules field already changed by another request', async () => {
const user = userEvent.setup();
render(<AppWithConfig />);

expect(await screen.findByText('Governance')).toBeDefined();
await user.click(screen.getByText('Governance'));
expect(await screen.findByText('Governance')).toBeDefined();
await user.click(screen.getByText('Governance'));

expect(await screen.findByText('Vote Requests')).toBeDefined();
expect(await screen.findByText('Vote Requests')).toBeDefined();

changeAction('CRARC_SetConfig');
changeAction('CRARC_SetConfig');

const input = screen.getByTestId('transferConfig.createFee.fee-value');
await user.clear(input);
await user.type(input, '481516');
expect(await screen.findByDisplayValue('481516')).toBeDefined();
const input = screen.getByTestId('transferConfig.createFee.fee-value');
await user.clear(input);
await user.type(input, '481516');
expect(await screen.findByDisplayValue('481516')).toBeDefined();

const input2 = screen.getByTestId('create-reason-summary');
await user.type(input2, 'summaryABC');
expect(await screen.findByDisplayValue('summaryABC')).toBeDefined();
const input2 = screen.getByTestId('create-reason-summary');
await user.type(input2, 'summaryABC');
expect(await screen.findByDisplayValue('summaryABC')).toBeDefined();

const urlInput = screen.getByTestId('create-reason-url');
await user.type(urlInput, 'https://vote-request.url');
const urlInput = screen.getByTestId('create-reason-url');
await user.type(urlInput, 'https://vote-request.url');

const warning = screen.getByTestId('voterequest-creation-alert');
expect(warning).toBeDefined();
expect(warning.textContent).toContain(
'A Vote Request aiming to change similar fields already exists. ' +
'You are therefore not allowed to modify the fields: transferConfig.createFee.fee'
);
const button = screen.getByTestId('create-voterequest-submit-button');
expect(button.getAttribute('disabled')).toBeDefined();
}
);
const warning = screen.getByTestId('voterequest-creation-alert');
expect(warning).toBeDefined();
expect(warning.textContent).toContain(
'A Vote Request aiming to change similar fields already exists. ' +
'You are therefore not allowed to modify the fields: transferConfig.createFee.fee'
);
const button = screen.getByTestId('create-voterequest-submit-button');
expect(button.getAttribute('disabled')).toBeDefined();
});

test(
'disables the Proceed button in the confirmation dialog if a conflict arises after request creation',
{ timeout: 10000 },
async () => {
server.use(
rest.get(`${svUrl}/v0/admin/sv/voterequests`, (_, res, ctx) => {
return res(ctx.json<ListDsoRulesVoteRequestsResponse>({ dso_rules_vote_requests: [] }));
})
);
test('disables the Proceed button in the confirmation dialog if a conflict arises after request creation', async () => {
server.use(
rest.get(`${svUrl}/v0/admin/sv/voterequests`, (_, res, ctx) => {
return res(ctx.json<ListDsoRulesVoteRequestsResponse>({ dso_rules_vote_requests: [] }));
})
);

const user = userEvent.setup();
render(<AppWithConfig />);
const user = userEvent.setup();
render(<AppWithConfig />);

expect(await screen.findByText('Governance')).toBeDefined();
await user.click(screen.getByText('Governance'));
expect(await screen.findByText('Governance')).toBeDefined();
await user.click(screen.getByText('Governance'));

expect(await screen.findByText('Vote Requests')).toBeDefined();
expect(await screen.findByText('Governance')).toBeDefined();
expect(await screen.findByText('Vote Requests')).toBeDefined();
expect(await screen.findByText('Governance')).toBeDefined();

changeAction('CRARC_SetConfig');
changeAction('CRARC_SetConfig');

const input = screen.getByTestId('transferConfig.createFee.fee-value');
await user.clear(input);
await user.type(input, '481516');
expect(await screen.findByDisplayValue('481516')).toBeDefined();
const input = screen.getByTestId('transferConfig.createFee.fee-value');
await user.clear(input);
await user.type(input, '481516');
expect(await screen.findByDisplayValue('481516')).toBeDefined();

const input2 = screen.getByTestId('create-reason-summary');
await user.type(input2, 'summaryABC');
expect(await screen.findByDisplayValue('summaryABC')).toBeDefined();
const input2 = screen.getByTestId('create-reason-summary');
await user.type(input2, 'summaryABC');
expect(await screen.findByDisplayValue('summaryABC')).toBeDefined();

const urlInput = screen.getByTestId('create-reason-url');
await user.type(urlInput, 'https://vote-request.url');
expect(await screen.findByDisplayValue('https://vote-request.url')).toBeDefined();
const urlInput = screen.getByTestId('create-reason-url');
await user.type(urlInput, 'https://vote-request.url');
expect(await screen.findByDisplayValue('https://vote-request.url')).toBeDefined();

expect(await screen.findByText('Send Request to Super Validators')).toBeDefined();
await user.click(screen.getByText('Send Request to Super Validators'));
expect(await screen.findByText('Send Request to Super Validators')).toBeDefined();
await user.click(screen.getByText('Send Request to Super Validators'));

server.use(
rest.get(`${svUrl}/v0/admin/sv/voterequests`, (_, res, ctx) => {
return res(ctx.json<ListDsoRulesVoteRequestsResponse>(voteRequests));
})
);
server.use(
rest.get(`${svUrl}/v0/admin/sv/voterequests`, (_, res, ctx) => {
return res(ctx.json<ListDsoRulesVoteRequestsResponse>(voteRequests));
})
);

const button = screen.getByRole('button', { name: 'Proceed' });
expect(button.getAttribute('disabled')).toBeDefined();
}
);
const button = screen.getByRole('button', { name: 'Proceed' });
expect(button.getAttribute('disabled')).toBeDefined();
});
});

describe('An AddFutureAmuletConfigSchedule request', () => {
Expand Down
Loading
Loading