|
@@ -132,3 +132,113 @@ return { getRowDetails };
|
|
|
assert.equal(details.subject, 'Your ChatGPT code is 866785');
|
|
assert.equal(details.subject, 'Your ChatGPT code is 866785');
|
|
|
assert.equal(details.codes[0], '866785');
|
|
assert.equal(details.codes[0], '866785');
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+test('phplife refreshMessageList clicks inbox before refresh button', async () => {
|
|
|
|
|
+ const bundle = [
|
|
|
|
|
+ extractFunction('ensureInboxActive'),
|
|
|
|
|
+ extractFunction('refreshMessageList'),
|
|
|
|
|
+ ].join('\n');
|
|
|
|
|
+
|
|
|
|
|
+ const api = new Function(`${bundle}
|
|
|
|
|
+const clickOrder = [];
|
|
|
|
|
+const inboxLink = {
|
|
|
|
|
+ closest() {
|
|
|
|
|
+ return { classList: { contains() { return true; } } };
|
|
|
|
|
+ },
|
|
|
|
|
+ click() {
|
|
|
|
|
+ clickOrder.push('inbox');
|
|
|
|
|
+ },
|
|
|
|
|
+};
|
|
|
|
|
+const refreshButton = {
|
|
|
|
|
+ click() {
|
|
|
|
|
+ clickOrder.push('refresh');
|
|
|
|
|
+ },
|
|
|
|
|
+};
|
|
|
|
|
+function findInboxLink() {
|
|
|
|
|
+ return inboxLink;
|
|
|
|
|
+}
|
|
|
|
|
+function findRefreshButton() {
|
|
|
|
|
+ return refreshButton;
|
|
|
|
|
+}
|
|
|
|
|
+async function sleep() {}
|
|
|
|
|
+return {
|
|
|
|
|
+ refreshMessageList,
|
|
|
|
|
+ getClickOrder() {
|
|
|
|
|
+ return clickOrder.slice();
|
|
|
|
|
+ },
|
|
|
|
|
+};
|
|
|
|
|
+`)();
|
|
|
|
|
+
|
|
|
|
|
+ await api.refreshMessageList();
|
|
|
|
|
+ assert.deepEqual(api.getClickOrder(), ['inbox', 'refresh']);
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+test('phplife temporary login title opens detail to extract verification code', async () => {
|
|
|
|
|
+ const bundle = [
|
|
|
|
|
+ extractFunction('normalizeText'),
|
|
|
|
|
+ extractFunction('normalizeMinuteTimestamp'),
|
|
|
|
|
+ extractFunction('shouldOpenRowForCodeDetection'),
|
|
|
|
|
+ extractFunction('selectCandidateCode'),
|
|
|
|
|
+ extractFunction('matchesCurrentMessage'),
|
|
|
|
|
+ extractFunction('scoreRowCandidate'),
|
|
|
|
|
+ extractFunction('tryOpenRowsAndRead'),
|
|
|
|
|
+ ].join('\n');
|
|
|
|
|
+
|
|
|
|
|
+ const api = new Function(`${bundle}
|
|
|
|
|
+let opened = 0;
|
|
|
|
|
+const seenCodes = new Set();
|
|
|
|
|
+function throwIfStopped() {}
|
|
|
|
|
+function getMessageListRows() {
|
|
|
|
|
+ return [{ id: 'row-1' }];
|
|
|
|
|
+}
|
|
|
|
|
+function getRowDetails() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ row: { id: 'row-1' },
|
|
|
|
|
+ subject: 'Your temporary ChatGPT login code',
|
|
|
|
|
+ from: 'noreply@tm.openai.com',
|
|
|
|
|
+ to: 'n2026041807@a4sky.com',
|
|
|
|
|
+ dateText: '今天 12:30',
|
|
|
|
|
+ emailTimestamp: Date.now(),
|
|
|
|
|
+ codes: [],
|
|
|
|
|
+ combinedText: 'Your temporary ChatGPT login code noreply@tm.openai.com n2026041807@a4sky.com',
|
|
|
|
|
+ };
|
|
|
|
|
+}
|
|
|
|
|
+function matchesMailFilters() {
|
|
|
|
|
+ return true;
|
|
|
|
|
+}
|
|
|
|
|
+function getTargetEmailMatchState() {
|
|
|
|
|
+ return { matches: true, hasExplicitEmail: true };
|
|
|
|
|
+}
|
|
|
|
|
+function log() {}
|
|
|
|
|
+function getCurrentMessageUid() {
|
|
|
|
|
+ return '';
|
|
|
|
|
+}
|
|
|
|
|
+function openMessageRow() {
|
|
|
|
|
+ opened += 1;
|
|
|
|
|
+}
|
|
|
|
|
+async function sleep() {}
|
|
|
|
|
+async function waitForPreviewLoaded() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ subject: 'Your temporary ChatGPT login code',
|
|
|
|
|
+ combinedText: 'Your temporary ChatGPT login code 998877 noreply@tm.openai.com n2026041807@a4sky.com',
|
|
|
|
|
+ emailTimestamp: Date.now(),
|
|
|
|
|
+ codes: ['998877'],
|
|
|
|
|
+ };
|
|
|
|
|
+}
|
|
|
|
|
+return {
|
|
|
|
|
+ tryOpenRowsAndRead,
|
|
|
|
|
+ getOpenedCount() {
|
|
|
|
|
+ return opened;
|
|
|
|
|
+ },
|
|
|
|
|
+};
|
|
|
|
|
+`)();
|
|
|
|
|
+
|
|
|
|
|
+ const result = await api.tryOpenRowsAndRead(4, {
|
|
|
|
|
+ senderFilters: ['openai'],
|
|
|
|
|
+ subjectFilters: ['login', 'code'],
|
|
|
|
|
+ targetEmail: 'n2026041807@a4sky.com',
|
|
|
|
|
+ }, new Set(), 0);
|
|
|
|
|
+
|
|
|
|
|
+ assert.equal(result.code, '998877');
|
|
|
|
|
+ assert.equal(api.getOpenedCount(), 1);
|
|
|
|
|
+});
|