Simplify test

This commit is contained in:
Sander Declerck 2025-10-14 16:11:34 +02:00
parent d35a4ca357
commit b567016ddd
No known key found for this signature in database

View file

@ -60,58 +60,55 @@ describe("E2E: Safe chain proxy", () => {
it(`safe-chain proxy allows to request through a local http registry`, async () => { it(`safe-chain proxy allows to request through a local http registry`, async () => {
const configShell = await container.openShell("bash"); const configShell = await container.openShell("bash");
await configShell.runCommand("touch /.verdaccio-config.yaml"); // await configShell.runCommand("touch /.verdaccio-config.yaml");
// verdaccio.yaml // // verdaccio.yaml
/* // /*
storage: ./storage // storage: ./storage
uplinks: // uplinks:
npmjs: // npmjs:
url: https://registry.npmjs.org/ // url: https://registry.npmjs.org/
packages: // packages:
"**": // "**":
access: $all // access: $all
proxy: npmjs // proxy: npmjs
log: { type: file, path: ./verdaccio.log, level: trace, colors: false } // log: { type: file, path: ./verdaccio.log, level: trace, colors: false }
*/ // */
await configShell.runCommand( // await configShell.runCommand(
`echo 'storage: ./storage' >> /.verdaccio-config.yaml` // `echo 'storage: ./storage' >> /.verdaccio-config.yaml`
); // );
await configShell.runCommand(`echo 'auth:' >> /.verdaccio-config.yaml`); // await configShell.runCommand(`echo 'auth:' >> /.verdaccio-config.yaml`);
await configShell.runCommand( // await configShell.runCommand(
`echo ' htpasswd:' >> /.verdaccio-config.yaml` // `echo ' htpasswd:' >> /.verdaccio-config.yaml`
); // );
await configShell.runCommand( // await configShell.runCommand(
`echo ' file: ./htpasswd' >> /.verdaccio-config.yaml` // `echo ' file: ./htpasswd' >> /.verdaccio-config.yaml`
); // );
await configShell.runCommand( // await configShell.runCommand(
`echo ' max_users: 100' >> /.verdaccio-config.yaml` // `echo ' max_users: 100' >> /.verdaccio-config.yaml`
); // );
await configShell.runCommand(`echo 'uplinks:' >> /.verdaccio-config.yaml`); // await configShell.runCommand(`echo 'uplinks:' >> /.verdaccio-config.yaml`);
await configShell.runCommand(`echo ' npmjs:' >> /.verdaccio-config.yaml`); // await configShell.runCommand(`echo ' npmjs:' >> /.verdaccio-config.yaml`);
await configShell.runCommand( // await configShell.runCommand(
`echo ' url: https://registry.npmjs.org/' >> /.verdaccio-config.yaml` // `echo ' url: https://registry.npmjs.org/' >> /.verdaccio-config.yaml`
); // );
await configShell.runCommand(`echo 'packages:' >> /.verdaccio-config.yaml`); // await configShell.runCommand(`echo 'packages:' >> /.verdaccio-config.yaml`);
await configShell.runCommand(`echo ' "**":' >> /.verdaccio-config.yaml`); // await configShell.runCommand(`echo ' "**":' >> /.verdaccio-config.yaml`);
await configShell.runCommand( // await configShell.runCommand(
`echo ' access: $all' >> /.verdaccio-config.yaml` // `echo ' access: $all' >> /.verdaccio-config.yaml`
); // );
await configShell.runCommand( // await configShell.runCommand(
`echo ' proxy: npmjs' >> /.verdaccio-config.yaml` // `echo ' proxy: npmjs' >> /.verdaccio-config.yaml`
); // );
await configShell.runCommand( // await configShell.runCommand(
`echo 'log: { type: file, path: ./verdaccio.log, level: trace, colors: false }' >> /.verdaccio-config.yaml` // `echo 'log: { type: file, path: ./verdaccio.log, level: trace, colors: false }' >> /.verdaccio-config.yaml`
); // );
// Start a local npm registry (verdaccio) inside the container // Start a local npm registry (verdaccio) inside the container
container.dockerExec( container.dockerExec("npx -y verdaccio --listen 4873", true);
"npx -y verdaccio --listen 4873 -c /verdaccio-config.yaml",
true
);
// Polling until verdaccio is ready (max 60 seconds) // Polling until verdaccio is ready (max 30 seconds)
let verdaccioStarted = false; let verdaccioStarted = false;
for (let i = 0; i < 120; i++) { for (let i = 0; i < 30; i++) {
await new Promise((resolve) => setTimeout(resolve, 500)); await new Promise((resolve) => setTimeout(resolve, 500));
try { try {
const curlOutput = container.dockerExec( const curlOutput = container.dockerExec(
@ -137,12 +134,12 @@ log: { type: file, path: ./verdaccio.log, level: trace, colors: false }
console.log("NPM install output:", result.output); console.log("NPM install output:", result.output);
const verdaccioLog = await container.openShell("bash"); // const verdaccioLog = await container.openShell("bash");
const { output: logOutput } = await verdaccioLog.runCommand( // const { output: logOutput } = await verdaccioLog.runCommand(
"cat /verdaccio.log" // "cat /verdaccio.log"
); // );
console.log("Verdaccio log output:", logOutput); // console.log("Verdaccio log output:", logOutput);
// Check if the installation was successful // Check if the installation was successful
assert( assert(