Files
nym/nym-wallet/webpack.common.js
T
Yana Matrosova 0e386b3b92 NYM-1199: Node Families E2E with mock app shell & native webview tests
Implements the new Node Families E2E testing strategy, shifting the primary Playwright suite from Storybook iframes to a dedicated mock-wired app shell (`main.mock.html`). This provides higher-fidelity testing against the actual wallet UI and router without a Tauri runtime or login.

Also introduces an optional WebdriverIO + `tauri-driver` suite for native WebKitGTK webview validation, configured as a non-blocking CI job for Linux. A critical fix for `NymCard`'s `data-testid` prop is included to enable robust UI selectors across all E2E tiers.

Updates CI workflows, adds new scripts for mock builds and native tests, and provides comprehensive documentation in `e2e/README.md` for the tiered testing approach.
2026-06-10 16:49:39 +03:00

94 lines
4.0 KiB
JavaScript

const path = require('path');
const webpack = require('webpack');
const { mergeWithRules } = require('webpack-merge');
const { webpackCommon } = require('@nymproject/webpack');
const resolveFromWallet = (request) => require.resolve(request, { paths: [__dirname] });
/** Package root (folder), not main entry - required so `@mui/material/Button` style subpath imports resolve. */
const resolveMuiPackageRoot = (pkg) =>
path.dirname(require.resolve(`${pkg}/package.json`, { paths: [__dirname, path.resolve(__dirname, '..')] }));
const muiSystemDir = path.dirname(
require.resolve('@mui/system/package.json', { paths: [__dirname, path.resolve(__dirname, '..')] }),
);
const muiStyledEngineV5 = path.dirname(require.resolve('@mui/styled-engine/package.json', { paths: [muiSystemDir] }));
// Mock-wired build for e2e (design D2): gated by `WALLET_MOCK_FAMILIES=on`. When off (the
// default, and always in production) the mock entry + its HTML are never registered.
const MOCK_FAMILIES = process.env.WALLET_MOCK_FAMILIES === 'on';
const entry = {
auth: path.resolve(__dirname, 'src/auth.tsx'), // JS bundle for sign up/sign in
main: path.resolve(__dirname, 'src/main.tsx'), // JS bundle for main app
log: path.resolve(__dirname, 'src/log.tsx'), // JS bundle for logging window
...(MOCK_FAMILIES ? { mainMock: path.resolve(__dirname, 'src/main.mock.tsx') } : {}), // mock-wired app (e2e only)
};
const htmlPages = [
{ filename: 'index.html', chunks: ['auth'], template: path.resolve(__dirname, 'public/index.html') }, // the starting point is index.html (sign up/sign in)
{ filename: 'main.html', chunks: ['main'], template: path.resolve(__dirname, 'public/index.html') }, // main app (loaded after sign in in a new window)
{ filename: 'log.html', chunks: ['log'], template: path.resolve(__dirname, 'public/log.html') }, // the user can open a separate logging window
];
if (MOCK_FAMILIES) {
// Served at /main.mock.html on the dev server; the e2e suite navigates here.
htmlPages.push({
filename: 'main.mock.html',
chunks: ['mainMock'],
template: path.resolve(__dirname, 'public/index.html'),
});
}
module.exports = mergeWithRules({
module: {
rules: {
test: 'match',
use: 'replace',
},
},
})(
webpackCommon(__dirname, htmlPages),
{
entry,
resolve: {
// Yarn workspaces hoist deps to ../node_modules; resolve Tauri packages from there too.
modules: [path.resolve(__dirname, 'node_modules'), path.resolve(__dirname, '../node_modules')],
alias: {
// Single Emotion instance so CacheProvider matches MUI's styled engine (workspaces can duplicate).
'@emotion/react': resolveFromWallet('@emotion/react'),
'@emotion/styled': resolveFromWallet('@emotion/styled'),
'@emotion/cache': resolveFromWallet('@emotion/cache'),
'@mui/styled-engine': muiStyledEngineV5,
'@mui/material': resolveMuiPackageRoot('@mui/material'),
'@mui/system': resolveMuiPackageRoot('@mui/system'),
'@mui/private-theming': resolveMuiPackageRoot('@mui/private-theming'),
'@mui/utils': resolveMuiPackageRoot('@mui/utils'),
'@mui/base': resolveMuiPackageRoot('@mui/base'),
'@mui/styles': resolveMuiPackageRoot('@mui/styles'),
'@mui/icons-material': resolveMuiPackageRoot('@mui/icons-material'),
'@mui/lab': resolveMuiPackageRoot('@mui/lab'),
react$: resolveFromWallet('react'),
'react-dom$': resolveFromWallet('react-dom'),
'react-dom/client': resolveFromWallet('react-dom/client'),
'react/jsx-runtime': resolveFromWallet('react/jsx-runtime'),
'react/jsx-dev-runtime': resolveFromWallet('react/jsx-dev-runtime'),
},
},
output: {
clean: true,
path: path.resolve(__dirname, 'dist'),
filename: '[name].bundle.js',
publicPath: '/',
},
experiments: {
asyncWebAssembly: true,
},
plugins: [
new webpack.EnvironmentPlugin({
NYM_WALLET_INTERNAL_DOCS: '',
WALLET_MOCK_FAMILIES: 'off',
}),
],
},
);