mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-10-20 18:56:30 +00:00
Run the slow specs again
- Removes the skip from Bounties and CreateAccount. - test:slow runs only the .slow. specs. - Each step waits up to 20s instead of the 1s default, since it waits on a live chain. The previous setting is restored when the file ends. - assertDevNode fails a spec at once when no dev node answers. Without it the api keeps reconnecting and the spec waits until the job's timeout.
This commit is contained in:
1 parent
676780874a
commit
1978e00ad1
5 files changed
+63
-14
No files matched your search
+2
-1
@@ -45,7 +45,8 @@
|
|||||||
"test": "pezkuwi-dev-run-test --experimental-test-module-mocks --env browser ^typesBundle ^chainEndpoints ^chainTypes ^:.slow.",
|
"test": "pezkuwi-dev-run-test --experimental-test-module-mocks --env browser ^typesBundle ^chainEndpoints ^chainTypes ^:.slow.",
|
||||||
"test:all": "pezkuwi-dev-run-test --experimental-test-module-mocks --env browser ^chainEndpoints ^chainTypes",
|
"test:all": "pezkuwi-dev-run-test --experimental-test-module-mocks --env browser ^chainEndpoints ^chainTypes",
|
||||||
"test:one": "pezkuwi-dev-run-test --experimental-test-module-mocks --env browser",
|
"test:one": "pezkuwi-dev-run-test --experimental-test-module-mocks --env browser",
|
||||||
"test:skipped": "echo 'tests skipped'"
|
"test:skipped": "echo 'tests skipped'",
|
||||||
|
"test:slow": "pezkuwi-dev-run-test --experimental-test-module-mocks --env browser :.slow."
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@pezkuwi/dev": "^0.86.8",
|
"@pezkuwi/dev": "^0.86.8",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import '@pezkuwi/react-components/i18n';
|
import '@pezkuwi/react-components/i18n';
|
||||||
|
|
||||||
import { cleanup, fireEvent, render, waitForElementToBeRemoved } from '@testing-library/react';
|
import { cleanup, configure, fireEvent, getConfig, render, waitForElementToBeRemoved } from '@testing-library/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import { ThemeProvider } from 'styled-components';
|
import { ThemeProvider } from 'styled-components';
|
||||||
@@ -15,7 +15,7 @@ import { ApiCtxRoot } from '@pezkuwi/react-api';
|
|||||||
import { statics } from '@pezkuwi/react-api/statics';
|
import { statics } from '@pezkuwi/react-api/statics';
|
||||||
import { lightTheme } from '@pezkuwi/react-components';
|
import { lightTheme } from '@pezkuwi/react-components';
|
||||||
import { KeyringCtxRoot } from '@pezkuwi/react-hooks/ctx/Keyring';
|
import { KeyringCtxRoot } from '@pezkuwi/react-hooks/ctx/Keyring';
|
||||||
import { BIZINIKIWI_PORT } from '@pezkuwi/test-support/bizinikiwi';
|
import { assertDevNode, BIZINIKIWI_PORT } from '@pezkuwi/test-support/bizinikiwi';
|
||||||
import { MemoryStore } from '@pezkuwi/test-support/keyring';
|
import { MemoryStore } from '@pezkuwi/test-support/keyring';
|
||||||
import { WaitForApi } from '@pezkuwi/test-support/react';
|
import { WaitForApi } from '@pezkuwi/test-support/react';
|
||||||
import { settings } from '@pezkuwi/ui-settings';
|
import { settings } from '@pezkuwi/ui-settings';
|
||||||
@@ -53,19 +53,31 @@ const renderAccounts = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line jest/no-disabled-tests
|
describe('--SLOW--: Account Create', () => {
|
||||||
describe.skip('--SLOW--: Account Create', () => {
|
// every step waits on a live chain and a page that draws once the api and
|
||||||
|
// keyring are ready, which takes longer than the 1s default on a busy machine
|
||||||
|
let asyncUtilTimeout: number;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await assertDevNode();
|
||||||
|
asyncUtilTimeout = getConfig().asyncUtilTimeout;
|
||||||
|
configure({ asyncUtilTimeout: 20_000 });
|
||||||
|
});
|
||||||
|
|
||||||
// each render opens its own connection, and an open one keeps the process alive
|
// each render opens its own connection, and an open one keeps the process alive
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
cleanup();
|
cleanup();
|
||||||
await statics.api.disconnect();
|
await statics.api.disconnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
configure({ asyncUtilTimeout });
|
||||||
|
});
|
||||||
|
|
||||||
it('created account is added to list', async () => {
|
it('created account is added to list', async () => {
|
||||||
const { findByRole, findByTestId, findByText, queryByText } = renderAccounts();
|
const { findByRole, findByTestId, findByText, queryByText } = renderAccounts();
|
||||||
|
|
||||||
// the page draws once the api and keyring are ready, later than the 1s default on a busy machine
|
fireEvent.click(await findByRole('button', { name: 'Account' }));
|
||||||
fireEvent.click(await findByRole('button', { name: 'Account' }, { timeout: 20_000 }));
|
|
||||||
|
|
||||||
const isSeedSavedCheckbox = await findByText('I have saved my mnemonic seed safely');
|
const isSeedSavedCheckbox = await findByText('I have saved my mnemonic seed safely');
|
||||||
const hiddenCheckbox = isSeedSavedCheckbox as HTMLInputElement;
|
const hiddenCheckbox = isSeedSavedCheckbox as HTMLInputElement;
|
||||||
@@ -104,7 +116,7 @@ describe.skip('--SLOW--: Account Create', () => {
|
|||||||
it('gives an error message when entering invalid derivation path', async () => {
|
it('gives an error message when entering invalid derivation path', async () => {
|
||||||
const { findByRole, findByTestId, findByText } = renderAccounts();
|
const { findByRole, findByTestId, findByText } = renderAccounts();
|
||||||
|
|
||||||
fireEvent.click(await findByRole('button', { name: 'Account' }, { timeout: 20_000 }));
|
fireEvent.click(await findByRole('button', { name: 'Account' }));
|
||||||
|
|
||||||
const showAdvancedOptionsButton = await findByText('Advanced creation options', {});
|
const showAdvancedOptionsButton = await findByText('Advanced creation options', {});
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import '@pezkuwi/react-components/i18n';
|
|||||||
|
|
||||||
import type { ApiPromise } from '@pezkuwi/api';
|
import type { ApiPromise } from '@pezkuwi/api';
|
||||||
|
|
||||||
import { cleanup, render } from '@testing-library/react';
|
import { cleanup, configure, getConfig, render } from '@testing-library/react';
|
||||||
import React, { Suspense } from 'react';
|
import React, { Suspense } from 'react';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import { ThemeProvider } from 'styled-components';
|
import { ThemeProvider } from 'styled-components';
|
||||||
@@ -16,6 +16,7 @@ import { ApiCtxRoot } from '@pezkuwi/react-api';
|
|||||||
import { statics } from '@pezkuwi/react-api/statics';
|
import { statics } from '@pezkuwi/react-api/statics';
|
||||||
import { lightTheme } from '@pezkuwi/react-components';
|
import { lightTheme } from '@pezkuwi/react-components';
|
||||||
import { createApi } from '@pezkuwi/test-support/api';
|
import { createApi } from '@pezkuwi/test-support/api';
|
||||||
|
import { assertDevNode, BIZINIKIWI_PORT } from '@pezkuwi/test-support/bizinikiwi';
|
||||||
import { aliceSigner, MemoryStore } from '@pezkuwi/test-support/keyring';
|
import { aliceSigner, MemoryStore } from '@pezkuwi/test-support/keyring';
|
||||||
import { WaitForApi } from '@pezkuwi/test-support/react';
|
import { WaitForApi } from '@pezkuwi/test-support/react';
|
||||||
import { execute } from '@pezkuwi/test-support/transaction';
|
import { execute } from '@pezkuwi/test-support/transaction';
|
||||||
@@ -23,8 +24,6 @@ import { BN } from '@pezkuwi/util';
|
|||||||
|
|
||||||
import BountiesApp from './index.js';
|
import BountiesApp from './index.js';
|
||||||
|
|
||||||
const BIZINIKIWI_PORT = Number.parseInt(process.env.TEST_BIZINIKIWI_PORT || '30333');
|
|
||||||
|
|
||||||
const renderBounties = () => {
|
const renderBounties = () => {
|
||||||
const memoryStore = new MemoryStore();
|
const memoryStore = new MemoryStore();
|
||||||
|
|
||||||
@@ -48,12 +47,22 @@ const renderBounties = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line jest/no-disabled-tests
|
describe('--SLOW--: Bounties', () => {
|
||||||
describe.skip('--SLOW--: Bounties', () => {
|
// every step waits on a live chain and a page that draws once the api and
|
||||||
|
// keyring are ready, which takes longer than the 1s default on a busy machine
|
||||||
|
let asyncUtilTimeout: number;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await assertDevNode();
|
||||||
|
asyncUtilTimeout = getConfig().asyncUtilTimeout;
|
||||||
|
configure({ asyncUtilTimeout: 20_000 });
|
||||||
|
});
|
||||||
|
|
||||||
let api: ApiPromise | undefined;
|
let api: ApiPromise | undefined;
|
||||||
|
|
||||||
// both connections stay open otherwise, and keep the process alive
|
// both connections stay open otherwise, and keep the process alive
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
|
configure({ asyncUtilTimeout });
|
||||||
cleanup();
|
cleanup();
|
||||||
await api?.disconnect();
|
await api?.disconnect();
|
||||||
await statics.api.disconnect();
|
await statics.api.disconnect();
|
||||||
@@ -69,6 +78,6 @@ describe.skip('--SLOW--: Bounties', () => {
|
|||||||
|
|
||||||
const { findByText } = renderBounties();
|
const { findByText } = renderBounties();
|
||||||
|
|
||||||
expect(await findByText(title, {}, { timeout: 20_000 })).toBeTruthy();
|
expect(await findByText(title)).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
// Copyright 2017-2026 @pezkuwi/test-support authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import { BIZINIKIWI_PORT } from './constants.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fails at once when no dev node answers on BIZINIKIWI_PORT. Without it an
|
||||||
|
* api keeps reconnecting and a spec waits until the job's timeout.
|
||||||
|
*/
|
||||||
|
export async function assertDevNode (timeoutMs = 5_000): Promise<void> {
|
||||||
|
const url = `http://127.0.0.1:${BIZINIKIWI_PORT}`;
|
||||||
|
const res = await fetch(url, {
|
||||||
|
body: JSON.stringify({ id: 1, jsonrpc: '2.0', method: 'system_chain' }),
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
method: 'POST',
|
||||||
|
signal: AbortSignal.timeout(timeoutMs)
|
||||||
|
}).catch((error: Error) => error);
|
||||||
|
|
||||||
|
if (res instanceof Error || !res.ok) {
|
||||||
|
const reason = res instanceof Error
|
||||||
|
? res.message
|
||||||
|
: `HTTP ${res.status}`;
|
||||||
|
|
||||||
|
throw new Error(`No dev node answers on ${url} (${reason}); the .slow. specs need one`);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// Copyright 2017-2026 @pezkuwi/test-support authors & contributors
|
// Copyright 2017-2026 @pezkuwi/test-support authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
export * from './assertDevNode.js';
|
||||||
export * from './constants.js';
|
export * from './constants.js';
|
||||||
Reference in new issue
Block a user