fix frontend tests broken with aiscript 1.0.0 (#16377)

* test: update test for aiscript 1.0: line info in error

* test: update test for aiscript 1.0: keyword in object literal
This commit is contained in:
anatawa12 2025-08-09 14:12:17 +09:00 committed by GitHub
parent 785b85ee46
commit 103d5a4b44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 8 deletions

View File

@ -37,6 +37,17 @@ let $iMock = vi.hoisted<Partial<typeof import('@/i.js').$i> | null >(
() => null
);
function errorWithPos<T extends errors.AiScriptError>(
error: T,
line: number,
column: number,
): T {
const pos = { line, column };
error.pos = pos;
error.message = error.message + `\n at <root> (Line ${pos.line}, Column ${pos.column})`;
return error;
}
vi.mock('@/i.js', () => {
return {
get $i() {
@ -316,7 +327,7 @@ describe('AiScript common API', () => {
await expect(() => exe(`
Mk:api('https://example.com/api/ping', {})
`)).rejects.toStrictEqual(
new errors.AiScriptRuntimeError('invalid endpoint'),
errorWithPos(new errors.AiScriptRuntimeError('invalid endpoint'), 2, 11),
);
expect(misskeyApiMock).not.toHaveBeenCalled();
});
@ -325,7 +336,7 @@ describe('AiScript common API', () => {
await expect(() => exe(`
Mk:api('ping')
`)).rejects.toStrictEqual(
new errors.AiScriptRuntimeError('expected param'),
errorWithPos(new errors.AiScriptRuntimeError('expected param'), 2, 11),
);
expect(misskeyApiMock).not.toHaveBeenCalled();
});
@ -353,7 +364,7 @@ describe('AiScript common API', () => {
await expect(() => exe(`
Mk:save('key')
`)).rejects.toStrictEqual(
new errors.AiScriptRuntimeError('Expect anything, but got nothing.'),
errorWithPos(new errors.AiScriptRuntimeError('Expect anything, but got nothing.'), 2, 12),
);
});

View File

@ -316,10 +316,11 @@ describe('AiScript UI API', () => {
describe('textInput', () => {
test.concurrent('all options', async () => {
// https://github.com/aiscript-dev/aiscript/pull/948
const { root, get, outputs } = await exe(`
let text_input = Ui:C:textInput({
onInput: print
default: 'a'
"default": 'a'
label: 'b'
caption: 'c'
}, 'id')
@ -356,10 +357,11 @@ describe('AiScript UI API', () => {
describe('textarea', () => {
test.concurrent('all options', async () => {
// https://github.com/aiscript-dev/aiscript/pull/948
const { root, get, outputs } = await exe(`
let textarea = Ui:C:textarea({
onInput: print
default: 'a'
"default": 'a'
label: 'b'
caption: 'c'
}, 'id')
@ -396,10 +398,11 @@ describe('AiScript UI API', () => {
describe('numberInput', () => {
test.concurrent('all options', async () => {
// https://github.com/aiscript-dev/aiscript/pull/948
const { root, get, outputs } = await exe(`
let number_input = Ui:C:numberInput({
onInput: print
default: 1
"default": 1
label: 'a'
caption: 'b'
}, 'id')
@ -557,10 +560,11 @@ describe('AiScript UI API', () => {
describe('switch', () => {
test.concurrent('all options', async () => {
// https://github.com/aiscript-dev/aiscript/pull/948
const { root, get, outputs } = await exe(`
let switch = Ui:C:switch({
onChange: print
default: false
"default": false
label: 'a'
caption: 'b'
}, 'id')
@ -597,6 +601,7 @@ describe('AiScript UI API', () => {
describe('select', () => {
test.concurrent('all options', async () => {
// https://github.com/aiscript-dev/aiscript/pull/948
const { root, get, outputs } = await exe(`
let select = Ui:C:select({
items: [
@ -604,7 +609,7 @@ describe('AiScript UI API', () => {
{ text: 'B', value: 'b' }
]
onChange: print
default: 'a'
"default": 'a'
label: 'c'
caption: 'd'
}, 'id')