1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-17 04:05:36 +08:00

Opt: AP preserve until reset

This commit is contained in:
sui-feng-cb
2025-09-03 13:59:51 +08:00
parent c3856ae101
commit 6b0383a169
137 changed files with 9982 additions and 13706 deletions

View File

@@ -18,10 +18,11 @@ const {strict: assert} = require('assert');
isCrashed: mainWindow.webContents.isCrashed(),
});
return new Promise(resolve => {
return new Promise((resolve) => {
if (mainWindow.isVisible()) {
resolve(getState());
} else mainWindow.once('ready-to-show', () => setTimeout(() => resolve(getState()), 0));
} else
mainWindow.once('ready-to-show', () => setTimeout(() => resolve(getState()), 0));
});
});
@@ -36,11 +37,13 @@ const {strict: assert} = require('assert');
*/
const page = await electronApp.firstWindow();
// Check web-page content
const element = await page.$('#app', {strict: true});
assert.notStrictEqual(element, null, "Can't find root element");
assert.notStrictEqual(element, null, 'Can\'t find root element');
assert.notStrictEqual((await element.innerHTML()).trim(), '', 'Window content is empty');
// Checking the framework.
// It is assumed that on the main screen there is a `<button>` that changes its contents after clicking.
const button = await page.$('button');
@@ -49,20 +52,13 @@ const {strict: assert} = require('assert');
await button.click();
const newBtnText = await button.textContent();
assert.ok(
originalBtnText !== newBtnText,
'The button did not change the contents after clicking',
);
assert.ok(originalBtnText !== newBtnText, 'The button did not change the contents after clicking');
// Check Preload script
const renderedExposedApi = await page.evaluate(() => globalThis.electron);
const realVersions = await electronApp.evaluate(() => process.versions);
assert.notStrictEqual(
renderedExposedApi,
undefined,
'In renderer `globalThis.electron` is undefined',
);
assert.notStrictEqual(renderedExposedApi, undefined, 'In renderer `globalThis.electron` is undefined');
assert.strictEqual(renderedExposedApi?.versions?.electron, realVersions.electron);
// Close app