feat: replace cookie cleanup step with registration success wait
This commit is contained in:
@@ -140,7 +140,7 @@ assert.strictEqual(
|
||||
assert.strictEqual(
|
||||
api.getAutoRunPreExecutionDelayMs(6, {
|
||||
definitions: {
|
||||
6: { key: 'clear-login-cookies' },
|
||||
6: { key: 'wait-registration-success' },
|
||||
},
|
||||
}),
|
||||
0,
|
||||
|
||||
@@ -11,7 +11,7 @@ test('background imports step 1~10 modules', () => {
|
||||
'background/steps/fill-password.js',
|
||||
'background/steps/fetch-signup-code.js',
|
||||
'background/steps/fill-profile.js',
|
||||
'background/steps/clear-login-cookies.js',
|
||||
'background/steps/wait-registration-success.js',
|
||||
'background/steps/oauth-login.js',
|
||||
'background/steps/fetch-login-code.js',
|
||||
'background/steps/confirm-oauth.js',
|
||||
|
||||
@@ -2,29 +2,34 @@ const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
|
||||
test('step 6 runs cookie cleanup and completes from background', async () => {
|
||||
const source = fs.readFileSync('background/steps/clear-login-cookies.js', 'utf8');
|
||||
test('step 6 waits for registration success and completes from background', async () => {
|
||||
const source = fs.readFileSync('background/steps/wait-registration-success.js', 'utf8');
|
||||
const globalScope = {};
|
||||
const api = new Function('self', `${source}; return self.MultiPageBackgroundStep6;`)(globalScope);
|
||||
|
||||
const events = {
|
||||
cleanupCalls: 0,
|
||||
logs: [],
|
||||
waits: [],
|
||||
completedSteps: [],
|
||||
};
|
||||
|
||||
const executor = api.createStep6Executor({
|
||||
addLog: async (message, level = 'info') => {
|
||||
events.logs.push({ message, level });
|
||||
},
|
||||
completeStepFromBackground: async (step) => {
|
||||
events.completedSteps.push(step);
|
||||
},
|
||||
runPreStep6CookieCleanup: async () => {
|
||||
events.cleanupCalls += 1;
|
||||
sleepWithStop: async (ms) => {
|
||||
events.waits.push(ms);
|
||||
},
|
||||
});
|
||||
|
||||
await executor.executeStep6();
|
||||
|
||||
assert.equal(events.cleanupCalls, 1);
|
||||
assert.deepStrictEqual(events.waits, [20000]);
|
||||
assert.deepStrictEqual(events.completedSteps, [6]);
|
||||
assert.ok(events.logs.some(({ message }) => /等待 20 秒/.test(message)));
|
||||
});
|
||||
|
||||
test('step 7 retries up to configured limit and then fails', async () => {
|
||||
|
||||
@@ -28,7 +28,7 @@ test('step definitions module exposes ordered normal and Plus step metadata', ()
|
||||
'fill-password',
|
||||
'fetch-signup-code',
|
||||
'fill-profile',
|
||||
'clear-login-cookies',
|
||||
'wait-registration-success',
|
||||
'oauth-login',
|
||||
'fetch-login-code',
|
||||
'confirm-oauth',
|
||||
@@ -36,7 +36,7 @@ test('step definitions module exposes ordered normal and Plus step metadata', ()
|
||||
]
|
||||
);
|
||||
assert.equal(steps[0].title, '打开 ChatGPT 官网');
|
||||
assert.equal(steps[5].title, '清理登录 Cookies');
|
||||
assert.equal(steps[5].title, '等待注册成功');
|
||||
assert.equal(phoneSteps[1].title, '注册并输入手机号');
|
||||
assert.equal(phoneSteps[3].title, '获取手机验证码');
|
||||
|
||||
@@ -58,7 +58,7 @@ test('step definitions module exposes ordered normal and Plus step metadata', ()
|
||||
'platform-verify',
|
||||
]
|
||||
);
|
||||
assert.equal(plusSteps.some((step) => step.key === 'clear-login-cookies'), false);
|
||||
assert.equal(plusSteps.some((step) => step.key === 'wait-registration-success'), false);
|
||||
assert.equal(plusSteps.some((step) => step.key === 'fetch-login-code'), true);
|
||||
assert.equal(plusSteps.find((step) => step.key === 'paypal-approve')?.title, 'PayPal 登录与授权');
|
||||
assert.equal(plusPhoneSteps[1].title, '注册并输入手机号');
|
||||
|
||||
Reference in New Issue
Block a user