okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Trial2 merge f-0291-gh2-app (0dfa2d9b1)2e8fb221c

main
2.9 KiB46 linesraw
1import test from 'node:test';
2import assert from 'node:assert/strict';
3import { plainUpdateError, plainError } from '../server/update-messages.mjs';
4
5// #4853: an engine that was downloaded and checked, then could not be put in place, used to read "The update didn't finish and nothing was
6// changed" with no reason. The reason is now said in plain words and the technical text stays in details.
7
8const moved = new Error('the new engine could not be moved into place (Strata could not use C:\\Users\\x\\AppData\\Local\\Strata\\components\\.s\\ab12\\engine (PermissionError)); copying it did not work either (OSError)');
9Object.assign(moved, { exitCode: 6 });
10
11test('an engine that could not be put in place says so and does not blame the download', () => {
12  const plain = plainUpdateError(moved);
13  assert.match(plain.message, /downloaded and checked, but Windows or a security program would not let Strata put it in place/);
14  assert.match(plain.message, /Wait a minute, then press Update engine in Settings/);
15  assert.doesNotMatch(plain.message, /PermissionError|C:\\|exit|\.s\\/);
16  assert.equal(plain.details, moved.message);
17});
18
19test('the unpack and the switch failures are not the generic sentence either', () => {
20  for (const text of ['the package could not be unpacked: Strata could not use X (PermissionError)', 'the new engine was not accepted after the switch (a start would pick other); the previous engine is unchanged']) {
21    const plain = plainUpdateError(new Error(text));
22    assert.doesNotMatch(plain.message, /didn't finish and nothing was changed/);
23    assert.match(plain.message, /put it in place/);
24  }
25});
26
27test('a disk that is full while unpacking is a disk-space message, not a security-program one', () => {
28  const plain = plainUpdateError(new Error('the package could not be unpacked: Strata could not use X: No space left on device (OSError)'));
29  assert.match(plain.message, /not enough free disk space/);
30});
31
32test('a path that is too long says that', () => {
33  const plain = plainUpdateError(new Error('the package could not be unpacked: a file path is longer than Windows allows (300 characters, the limit is 260): X'));
34  assert.match(plain.message, /too deep for Windows/);
35  assert.match(plain.next, /Details/);
36});
37
38test('the first-run card has no Settings page: the next step names its own Continue button', () => {
39  const plain = plainUpdateError(moved, 'engine', 'Continue');
40  assert.match(plain.next, /^Wait a minute, then press Continue\./);
41  assert.doesNotMatch(plain.message, /Settings/);
42  const generic = plainUpdateError(new Error('something unexpected'), 'engine', 'Continue');
43  assert.equal(generic.next, 'Press Continue to try again.');
44  assert.equal(plainError(new Error('app-1 is serving.'), 'engine', 'Continue').message, 'A model is running, so nothing was changed. Unload the model in Models, then press Continue.');
45  assert.match(plainUpdateError(new Error('something unexpected')).next, /Update engine in Settings/);   // elsewhere unchanged
46});