feat: refactor user registration steps into modular functions and implement step registry
- Replaced individual step imports with a centralized step registry in background.js - Created separate modules for each registration step: open-chatgpt, submit-signup-email, fill-password, fetch-signup-code, fill-profile, oauth-login, fetch-login-code, confirm-oauth, platform-verify - Updated tests to reflect changes in step imports and added new tests for step registry functionality
This commit is contained in:
@@ -6,15 +6,15 @@ test('background imports step 1~9 modules', () => {
|
||||
const source = fs.readFileSync('background.js', 'utf8');
|
||||
|
||||
[
|
||||
'background/steps/step1.js',
|
||||
'background/steps/step2.js',
|
||||
'background/steps/step3.js',
|
||||
'background/steps/step4.js',
|
||||
'background/steps/step5.js',
|
||||
'background/steps/step6.js',
|
||||
'background/steps/step7.js',
|
||||
'background/steps/step8.js',
|
||||
'background/steps/step9.js',
|
||||
'background/steps/open-chatgpt.js',
|
||||
'background/steps/submit-signup-email.js',
|
||||
'background/steps/fill-password.js',
|
||||
'background/steps/fetch-signup-code.js',
|
||||
'background/steps/fill-profile.js',
|
||||
'background/steps/oauth-login.js',
|
||||
'background/steps/fetch-login-code.js',
|
||||
'background/steps/confirm-oauth.js',
|
||||
'background/steps/platform-verify.js',
|
||||
].forEach((path) => {
|
||||
assert.match(source, new RegExp(path.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')));
|
||||
});
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
|
||||
test('background imports step registry module and uses sparse order values', () => {
|
||||
const source = fs.readFileSync('background.js', 'utf8');
|
||||
assert.match(source, /background\/steps\/registry\.js/);
|
||||
assert.match(source, /order:\s*10/);
|
||||
assert.match(source, /order:\s*90/);
|
||||
assert.match(source, /stepRegistry\.executeStep\(step,\s*state\)/);
|
||||
});
|
||||
@@ -2,7 +2,7 @@ const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
|
||||
const helperSource = fs.readFileSync('background.js', 'utf8');
|
||||
const step8ModuleSource = fs.readFileSync('background/steps/step8.js', 'utf8');
|
||||
const step8ModuleSource = fs.readFileSync('background/steps/confirm-oauth.js', 'utf8');
|
||||
|
||||
function extractFunction(source, name) {
|
||||
const markers = [`async function ${name}(`, `function ${name}(`];
|
||||
|
||||
Reference in New Issue
Block a user