feat: 添加 GPC Helper API URL 支持并更新相关逻辑

This commit is contained in:
QLHazyCoder
2026-05-05 05:32:01 +08:00
parent 6056a94d91
commit 3dfc112561
10 changed files with 49 additions and 28 deletions
+13 -8
View File
@@ -239,6 +239,7 @@ const SUB2API_STEP1_RESPONSE_TIMEOUT_MS = 90000;
const SUB2API_STEP9_RESPONSE_TIMEOUT_MS = 120000; const SUB2API_STEP9_RESPONSE_TIMEOUT_MS = 120000;
const DEFAULT_SUB2API_URL = 'https://sub2api.hisence.fun/admin/accounts'; const DEFAULT_SUB2API_URL = 'https://sub2api.hisence.fun/admin/accounts';
const DEFAULT_CODEX2API_URL = 'http://localhost:8080/admin/accounts'; const DEFAULT_CODEX2API_URL = 'http://localhost:8080/admin/accounts';
const DEFAULT_GPC_HELPER_API_URL = 'https://gopay.hwork.pro';
const DEFAULT_SUB2API_GROUP_NAME = 'codex'; const DEFAULT_SUB2API_GROUP_NAME = 'codex';
const DEFAULT_SUB2API_PROXY_NAME = ''; const DEFAULT_SUB2API_PROXY_NAME = '';
const CONTRIBUTION_SOURCE_CPA = 'cpa'; const CONTRIBUTION_SOURCE_CPA = 'cpa';
@@ -603,7 +604,7 @@ const PERSISTED_SETTING_DEFAULTS = {
gopayPhone: '', gopayPhone: '',
gopayOtp: '', gopayOtp: '',
gopayPin: '', gopayPin: '',
gopayHelperApiUrl: '', gopayHelperApiUrl: DEFAULT_GPC_HELPER_API_URL,
gopayHelperCardKey: '', gopayHelperCardKey: '',
gopayHelperPhoneNumber: '', gopayHelperPhoneNumber: '',
gopayHelperCountryCode: '+86', gopayHelperCountryCode: '+86',
@@ -2213,9 +2214,13 @@ function normalizePersistentSettingValue(key, value) {
? self.GoPayUtils.normalizeGoPayCountryCode(value) ? self.GoPayUtils.normalizeGoPayCountryCode(value)
: String(value || '+86').trim(); : String(value || '+86').trim();
case 'gopayHelperApiUrl': case 'gopayHelperApiUrl':
return self.GoPayUtils?.normalizeGpcHelperBaseUrl {
? self.GoPayUtils.normalizeGpcHelperBaseUrl(value) const defaultGpcHelperApiUrl = PERSISTED_SETTING_DEFAULTS.gopayHelperApiUrl
: String(value || '').trim().replace(/\/+$/g, ''); || (typeof DEFAULT_GPC_HELPER_API_URL !== 'undefined' ? DEFAULT_GPC_HELPER_API_URL : 'https://gopay.hwork.pro');
return self.GoPayUtils?.normalizeGpcHelperBaseUrl
? self.GoPayUtils.normalizeGpcHelperBaseUrl(value || defaultGpcHelperApiUrl)
: String(value || defaultGpcHelperApiUrl).trim().replace(/\/+$/g, '');
}
case 'gopayHelperCardKey': case 'gopayHelperCardKey':
case 'gopayHelperReferenceId': case 'gopayHelperReferenceId':
case 'gopayHelperGoPayGuid': case 'gopayHelperGoPayGuid':
@@ -9387,13 +9392,13 @@ async function maybeSwitchIpProxyAfterAutoRunRoundSuccess(payload = {}) {
function resolveGpcHelperBaseUrl(apiUrl = '') { function resolveGpcHelperBaseUrl(apiUrl = '') {
if (self.GoPayUtils?.normalizeGpcHelperBaseUrl) { if (self.GoPayUtils?.normalizeGpcHelperBaseUrl) {
return self.GoPayUtils.normalizeGpcHelperBaseUrl(apiUrl); return self.GoPayUtils.normalizeGpcHelperBaseUrl(apiUrl || DEFAULT_GPC_HELPER_API_URL);
} }
let normalized = String(apiUrl || '').trim().replace(/\/+$/g, ''); let normalized = String(apiUrl || DEFAULT_GPC_HELPER_API_URL).trim().replace(/\/+$/g, '');
normalized = normalized.replace(/\/api\/checkout\/start$/i, ''); normalized = normalized.replace(/\/api\/checkout\/start$/i, '');
normalized = normalized.replace(/\/api\/gopay\/(?:otp|pin)$/i, ''); normalized = normalized.replace(/\/api\/gopay\/(?:otp|pin)$/i, '');
normalized = normalized.replace(/\/api\/card\/balance(?:\?.*)?$/i, ''); normalized = normalized.replace(/\/api\/card\/balance(?:\?.*)?$/i, '');
return normalized; return normalized || DEFAULT_GPC_HELPER_API_URL;
} }
function buildGpcCardBalanceRequestUrl(apiUrl = '', cardKey = '') { function buildGpcCardBalanceRequestUrl(apiUrl = '', cardKey = '') {
@@ -9423,7 +9428,7 @@ function formatGpcCardBalancePayload(payload = {}) {
} }
async function refreshGpcCardBalance(state = {}, options = {}) { async function refreshGpcCardBalance(state = {}, options = {}) {
const apiUrl = String(state?.gopayHelperApiUrl || '').trim(); const apiUrl = resolveGpcHelperBaseUrl(state?.gopayHelperApiUrl || DEFAULT_GPC_HELPER_API_URL);
const cardKey = String(state?.gopayHelperCardKey || state?.gpcCardKey || state?.cardKey || '').trim(); const cardKey = String(state?.gopayHelperCardKey || state?.gpcCardKey || state?.cardKey || '').trim();
if (!apiUrl) { if (!apiUrl) {
throw new Error('缺少 GPC API 地址。'); throw new Error('缺少 GPC API 地址。');
+3 -2
View File
@@ -7,6 +7,7 @@
const PLUS_PAYMENT_METHOD_PAYPAL = 'paypal'; const PLUS_PAYMENT_METHOD_PAYPAL = 'paypal';
const PLUS_PAYMENT_METHOD_GOPAY = 'gopay'; const PLUS_PAYMENT_METHOD_GOPAY = 'gopay';
const PLUS_PAYMENT_METHOD_GPC_HELPER = 'gpc-helper'; const PLUS_PAYMENT_METHOD_GPC_HELPER = 'gpc-helper';
const DEFAULT_GPC_HELPER_API_URL = 'https://gopay.hwork.pro';
function createPlusCheckoutCreateExecutor(deps = {}) { function createPlusCheckoutCreateExecutor(deps = {}) {
const { const {
@@ -200,11 +201,11 @@
if (rootScope.GoPayUtils?.normalizeGpcHelperBaseUrl) { if (rootScope.GoPayUtils?.normalizeGpcHelperBaseUrl) {
return rootScope.GoPayUtils.normalizeGpcHelperBaseUrl(apiUrl); return rootScope.GoPayUtils.normalizeGpcHelperBaseUrl(apiUrl);
} }
let normalized = String(apiUrl || '').trim().replace(/\/+$/g, ''); let normalized = String(apiUrl || DEFAULT_GPC_HELPER_API_URL).trim().replace(/\/+$/g, '');
normalized = normalized.replace(/\/api\/checkout\/start$/i, ''); normalized = normalized.replace(/\/api\/checkout\/start$/i, '');
normalized = normalized.replace(/\/api\/gopay\/(?:otp|pin)$/i, ''); normalized = normalized.replace(/\/api\/gopay\/(?:otp|pin)$/i, '');
normalized = normalized.replace(/\/api\/card\/balance(?:\?.*)?$/i, ''); normalized = normalized.replace(/\/api\/card\/balance(?:\?.*)?$/i, '');
return normalized; return normalized || DEFAULT_GPC_HELPER_API_URL;
} }
function buildGpcHelperApiUrl(apiUrl = '', path = '') { function buildGpcHelperApiUrl(apiUrl = '', path = '') {
+3 -2
View File
@@ -10,6 +10,7 @@
const PLUS_PAYMENT_METHOD_PAYPAL = 'paypal'; const PLUS_PAYMENT_METHOD_PAYPAL = 'paypal';
const PLUS_PAYMENT_METHOD_GOPAY = 'gopay'; const PLUS_PAYMENT_METHOD_GOPAY = 'gopay';
const PLUS_PAYMENT_METHOD_GPC_HELPER = 'gpc-helper'; const PLUS_PAYMENT_METHOD_GPC_HELPER = 'gpc-helper';
const DEFAULT_GPC_HELPER_API_URL = 'https://gopay.hwork.pro';
const PAYMENT_METHOD_CONFIGS = { const PAYMENT_METHOD_CONFIGS = {
[PLUS_PAYMENT_METHOD_PAYPAL]: { [PLUS_PAYMENT_METHOD_PAYPAL]: {
id: PLUS_PAYMENT_METHOD_PAYPAL, id: PLUS_PAYMENT_METHOD_PAYPAL,
@@ -111,11 +112,11 @@
if (rootScope.GoPayUtils?.normalizeGpcHelperBaseUrl) { if (rootScope.GoPayUtils?.normalizeGpcHelperBaseUrl) {
return rootScope.GoPayUtils.normalizeGpcHelperBaseUrl(apiUrl); return rootScope.GoPayUtils.normalizeGpcHelperBaseUrl(apiUrl);
} }
let normalized = String(apiUrl || '').trim().replace(/\/+$/g, ''); let normalized = String(apiUrl || DEFAULT_GPC_HELPER_API_URL).trim().replace(/\/+$/g, '');
normalized = normalized.replace(/\/api\/checkout\/start$/i, ''); normalized = normalized.replace(/\/api\/checkout\/start$/i, '');
normalized = normalized.replace(/\/api\/gopay\/(?:otp|pin)$/i, ''); normalized = normalized.replace(/\/api\/gopay\/(?:otp|pin)$/i, '');
normalized = normalized.replace(/\/api\/card\/balance(?:\?.*)?$/i, ''); normalized = normalized.replace(/\/api\/card\/balance(?:\?.*)?$/i, '');
return normalized; return normalized || DEFAULT_GPC_HELPER_API_URL;
} }
async function fetchJsonWithTimeout(url, options = {}, timeoutMs = 30000) { async function fetchJsonWithTimeout(url, options = {}, timeoutMs = 30000) {
+5 -3
View File
@@ -4,6 +4,7 @@
const PLUS_PAYMENT_METHOD_PAYPAL = 'paypal'; const PLUS_PAYMENT_METHOD_PAYPAL = 'paypal';
const PLUS_PAYMENT_METHOD_GOPAY = 'gopay'; const PLUS_PAYMENT_METHOD_GOPAY = 'gopay';
const PLUS_PAYMENT_METHOD_GPC_HELPER = 'gpc-helper'; const PLUS_PAYMENT_METHOD_GPC_HELPER = 'gpc-helper';
const DEFAULT_GPC_HELPER_API_URL = 'https://gopay.hwork.pro';
function normalizePlusPaymentMethod(value = '') { function normalizePlusPaymentMethod(value = '') {
const normalized = String(value || '').trim().toLowerCase(); const normalized = String(value || '').trim().toLowerCase();
@@ -46,15 +47,15 @@
} }
function normalizeGpcHelperBaseUrl(apiUrl = '') { function normalizeGpcHelperBaseUrl(apiUrl = '') {
let normalized = String(apiUrl || '').trim(); let normalized = String(apiUrl || DEFAULT_GPC_HELPER_API_URL).trim();
if (!normalized) { if (!normalized) {
return ''; return DEFAULT_GPC_HELPER_API_URL;
} }
normalized = normalized.replace(/\/+$/g, ''); normalized = normalized.replace(/\/+$/g, '');
normalized = normalized.replace(/\/api\/checkout\/start$/i, ''); normalized = normalized.replace(/\/api\/checkout\/start$/i, '');
normalized = normalized.replace(/\/api\/gopay\/(?:otp|pin)$/i, ''); normalized = normalized.replace(/\/api\/gopay\/(?:otp|pin)$/i, '');
normalized = normalized.replace(/\/api\/card\/balance(?:\?.*)?$/i, ''); normalized = normalized.replace(/\/api\/card\/balance(?:\?.*)?$/i, '');
return normalized; return normalized || DEFAULT_GPC_HELPER_API_URL;
} }
function buildGpcHelperApiUrl(apiUrl = '', path = '') { function buildGpcHelperApiUrl(apiUrl = '', path = '') {
@@ -194,6 +195,7 @@
return { return {
DEFAULT_GOPAY_COUNTRY_CODE, DEFAULT_GOPAY_COUNTRY_CODE,
DEFAULT_GPC_HELPER_API_URL,
PLUS_PAYMENT_METHOD_GPC_HELPER, PLUS_PAYMENT_METHOD_GPC_HELPER,
PLUS_PAYMENT_METHOD_GOPAY, PLUS_PAYMENT_METHOD_GOPAY,
PLUS_PAYMENT_METHOD_PAYPAL, PLUS_PAYMENT_METHOD_PAYPAL,
-4
View File
@@ -279,10 +279,6 @@
<button id="btn-add-paypal-account" class="btn btn-outline btn-sm data-inline-btn" type="button">添加</button> <button id="btn-add-paypal-account" class="btn btn-outline btn-sm data-inline-btn" type="button">添加</button>
</div> </div>
</div> </div>
<div class="data-row" id="row-gpc-helper-api" style="display:none;">
<span class="data-label">GPC API</span>
<input type="text" id="input-gpc-helper-api" class="data-input" placeholder="https://gopay.hwork.pro" />
</div>
<div class="data-row" id="row-gpc-helper-card-key" style="display:none;"> <div class="data-row" id="row-gpc-helper-card-key" style="display:none;">
<span class="data-label">GPC 卡密</span> <span class="data-label">GPC 卡密</span>
<div class="data-inline"> <div class="data-inline">
+13 -7
View File
@@ -478,6 +478,7 @@ const stepsList = document.querySelector('.steps-list');
const PLUS_PAYMENT_METHOD_PAYPAL = 'paypal'; const PLUS_PAYMENT_METHOD_PAYPAL = 'paypal';
const PLUS_PAYMENT_METHOD_GOPAY = 'gopay'; const PLUS_PAYMENT_METHOD_GOPAY = 'gopay';
const PLUS_PAYMENT_METHOD_GPC_HELPER = 'gpc-helper'; const PLUS_PAYMENT_METHOD_GPC_HELPER = 'gpc-helper';
const DEFAULT_GPC_HELPER_API_URL = 'https://gopay.hwork.pro';
const DEFAULT_PLUS_PAYMENT_METHOD = PLUS_PAYMENT_METHOD_PAYPAL; const DEFAULT_PLUS_PAYMENT_METHOD = PLUS_PAYMENT_METHOD_PAYPAL;
const SIGNUP_METHOD_EMAIL = 'email'; const SIGNUP_METHOD_EMAIL = 'email';
const SIGNUP_METHOD_PHONE = 'phone'; const SIGNUP_METHOD_PHONE = 'phone';
@@ -2773,6 +2774,9 @@ function applyCloudflareTempEmailSettingsState(state = {}) {
} }
function collectSettingsPayload() { function collectSettingsPayload() {
const defaultGpcHelperApiUrl = typeof DEFAULT_GPC_HELPER_API_URL !== 'undefined'
? DEFAULT_GPC_HELPER_API_URL
: 'https://gopay.hwork.pro';
const { domains, activeDomain } = getCloudflareDomainsFromState(); const { domains, activeDomain } = getCloudflareDomainsFromState();
const selectedCloudflareDomain = normalizeCloudflareDomainValue( const selectedCloudflareDomain = normalizeCloudflareDomainValue(
!cloudflareDomainEditMode ? selectCfDomain.value : activeDomain !cloudflareDomainEditMode ? selectCfDomain.value : activeDomain
@@ -3303,10 +3307,10 @@ function collectSettingsPayload() {
? String(inputGoPayPin.value || '') ? String(inputGoPayPin.value || '')
: String(latestState?.gopayPin || '')), : String(latestState?.gopayPin || '')),
gopayHelperApiUrl: window.GoPayUtils?.normalizeGpcHelperBaseUrl gopayHelperApiUrl: window.GoPayUtils?.normalizeGpcHelperBaseUrl
? window.GoPayUtils.normalizeGpcHelperBaseUrl(typeof inputGpcHelperApi !== 'undefined' && inputGpcHelperApi ? inputGpcHelperApi.value : latestState?.gopayHelperApiUrl) ? window.GoPayUtils.normalizeGpcHelperBaseUrl(typeof inputGpcHelperApi !== 'undefined' && inputGpcHelperApi ? inputGpcHelperApi.value : (latestState?.gopayHelperApiUrl || defaultGpcHelperApiUrl))
: (typeof inputGpcHelperApi !== 'undefined' && inputGpcHelperApi : (typeof inputGpcHelperApi !== 'undefined' && inputGpcHelperApi
? String(inputGpcHelperApi.value || '').trim().replace(/\/+$/g, '') ? String(inputGpcHelperApi.value || defaultGpcHelperApiUrl).trim().replace(/\/+$/g, '')
: String(latestState?.gopayHelperApiUrl || '').trim()), : String(latestState?.gopayHelperApiUrl || defaultGpcHelperApiUrl).trim()),
gopayHelperCardKey: typeof inputGpcHelperCardKey !== 'undefined' && inputGpcHelperCardKey gopayHelperCardKey: typeof inputGpcHelperCardKey !== 'undefined' && inputGpcHelperCardKey
? String(inputGpcHelperCardKey.value || '').trim() ? String(inputGpcHelperCardKey.value || '').trim()
: String(latestState?.gopayHelperCardKey || '').trim(), : String(latestState?.gopayHelperCardKey || '').trim(),
@@ -7044,7 +7048,7 @@ function updatePlusModeUI() {
} }
if (typeof plusPaymentMethodCaption !== 'undefined' && plusPaymentMethodCaption) { if (typeof plusPaymentMethodCaption !== 'undefined' && plusPaymentMethodCaption) {
plusPaymentMethodCaption.textContent = method === gpcValue plusPaymentMethodCaption.textContent = method === gpcValue
? 'GPC API 订阅链路' ? 'GPC 订阅链路'
: method === gopayValue : method === gopayValue
? 'GoPay 印尼订阅链路' ? 'GoPay 印尼订阅链路'
: 'PayPal 订阅链路'; : 'PayPal 订阅链路';
@@ -7069,7 +7073,6 @@ function updatePlusModeUI() {
row.style.display = enabled && selectedMethod === paypalValue ? '' : 'none'; row.style.display = enabled && selectedMethod === paypalValue ? '' : 'none';
}); });
[ [
typeof rowGpcHelperApi !== 'undefined' ? rowGpcHelperApi : null,
typeof rowGpcHelperCardKey !== 'undefined' ? rowGpcHelperCardKey : null, typeof rowGpcHelperCardKey !== 'undefined' ? rowGpcHelperCardKey : null,
typeof rowGpcHelperCountryCode !== 'undefined' ? rowGpcHelperCountryCode : null, typeof rowGpcHelperCountryCode !== 'undefined' ? rowGpcHelperCountryCode : null,
typeof rowGpcHelperPhone !== 'undefined' ? rowGpcHelperPhone : null, typeof rowGpcHelperPhone !== 'undefined' ? rowGpcHelperPhone : null,
@@ -7788,7 +7791,10 @@ function applySettingsState(state) {
selectPlusPaymentMethod.value = normalizePlusPaymentMethod(state?.plusPaymentMethod); selectPlusPaymentMethod.value = normalizePlusPaymentMethod(state?.plusPaymentMethod);
} }
if (typeof inputGpcHelperApi !== 'undefined' && inputGpcHelperApi) { if (typeof inputGpcHelperApi !== 'undefined' && inputGpcHelperApi) {
inputGpcHelperApi.value = state?.gopayHelperApiUrl || ''; const defaultGpcHelperApiUrl = typeof DEFAULT_GPC_HELPER_API_URL !== 'undefined'
? DEFAULT_GPC_HELPER_API_URL
: 'https://gopay.hwork.pro';
inputGpcHelperApi.value = state?.gopayHelperApiUrl || defaultGpcHelperApiUrl;
} }
if (typeof inputGpcHelperCardKey !== 'undefined' && inputGpcHelperCardKey) { if (typeof inputGpcHelperCardKey !== 'undefined' && inputGpcHelperCardKey) {
inputGpcHelperCardKey.value = state?.gopayHelperCardKey || ''; inputGpcHelperCardKey.value = state?.gopayHelperCardKey || '';
@@ -11204,7 +11210,7 @@ btnGpcHelperBalance?.addEventListener('click', async () => {
type: 'REFRESH_GPC_CARD_BALANCE', type: 'REFRESH_GPC_CARD_BALANCE',
source: 'sidepanel', source: 'sidepanel',
payload: { payload: {
gopayHelperApiUrl: inputGpcHelperApi?.value || '', gopayHelperApiUrl: inputGpcHelperApi?.value || DEFAULT_GPC_HELPER_API_URL,
gopayHelperCardKey: inputGpcHelperCardKey?.value || '', gopayHelperCardKey: inputGpcHelperCardKey?.value || '',
gopayHelperCountryCode: selectGpcHelperCountryCode?.value || '+86', gopayHelperCountryCode: selectGpcHelperCountryCode?.value || '+86',
reason: 'manual', reason: 'manual',
@@ -154,6 +154,7 @@ const self = {
}; };
const PERSISTED_SETTING_DEFAULTS = { const PERSISTED_SETTING_DEFAULTS = {
autoStepDelaySeconds: null, autoStepDelaySeconds: null,
gopayHelperApiUrl: 'https://gopay.hwork.pro',
mailProvider: '163', mailProvider: '163',
}; };
function normalizePanelMode(value) { return value === 'sub2api' ? 'sub2api' : (value === 'codex2api' ? 'codex2api' : 'cpa'); } function normalizePanelMode(value) { return value === 'sub2api' ? 'sub2api' : (value === 'codex2api' ? 'codex2api' : 'cpa'); }
@@ -191,6 +192,7 @@ return {
api.normalizePersistentSettingValue('gopayHelperApiUrl', ' https://gopay.hwork.pro/api/checkout/start '), api.normalizePersistentSettingValue('gopayHelperApiUrl', ' https://gopay.hwork.pro/api/checkout/start '),
'https://gopay.hwork.pro' 'https://gopay.hwork.pro'
); );
assert.equal(api.normalizePersistentSettingValue('gopayHelperApiUrl', ''), 'https://gopay.hwork.pro');
assert.equal(api.normalizePersistentSettingValue('gopayHelperCardKey', ' card_123 '), 'card_123'); assert.equal(api.normalizePersistentSettingValue('gopayHelperCardKey', ' card_123 '), 'card_123');
assert.equal(api.normalizePersistentSettingValue('gopayHelperCountryCode', ' 86 '), '+86'); assert.equal(api.normalizePersistentSettingValue('gopayHelperCountryCode', ' 86 '), '+86');
assert.equal(api.normalizePersistentSettingValue('gopayHelperPhoneNumber', ' +86 138-0013-8000 '), '+8613800138000'); assert.equal(api.normalizePersistentSettingValue('gopayHelperPhoneNumber', ' +86 138-0013-8000 '), '+8613800138000');
+6
View File
@@ -23,6 +23,12 @@ test('GoPay utils keeps GPC helper payment method distinct', () => {
test('GoPay utils builds GPC card balance URL from helper endpoints', () => { test('GoPay utils builds GPC card balance URL from helper endpoints', () => {
const api = loadGoPayUtils(); const api = loadGoPayUtils();
assert.equal(api.DEFAULT_GPC_HELPER_API_URL, 'https://gopay.hwork.pro');
assert.equal(api.normalizeGpcHelperBaseUrl(''), 'https://gopay.hwork.pro');
assert.equal(
api.buildGpcHelperApiUrl('', '/api/checkout/start'),
'https://gopay.hwork.pro/api/checkout/start'
);
assert.equal( assert.equal(
api.buildGpcCardBalanceUrl('http://localhost:18473/', ' card key/1 '), api.buildGpcCardBalanceUrl('http://localhost:18473/', ' card key/1 '),
'http://localhost:18473/api/card/balance?card_key=card%20key%2F1' 'http://localhost:18473/api/card/balance?card_key=card%20key%2F1'
+2 -2
View File
@@ -204,7 +204,7 @@ return {
}); });
}); });
test('sidepanel Plus UI shows GPC fields and purchase button only for GPC', () => { test('sidepanel Plus UI shows GPC fields and purchase button only for GPC without API input', () => {
const bundle = [ const bundle = [
extractFunction('normalizePlusPaymentMethod'), extractFunction('normalizePlusPaymentMethod'),
extractFunction('getSelectedPlusPaymentMethod'), extractFunction('getSelectedPlusPaymentMethod'),
@@ -244,7 +244,7 @@ return {
assert.equal(api.rowPayPalAccount.style.display, 'none'); assert.equal(api.rowPayPalAccount.style.display, 'none');
assert.equal(api.btnGpcCardKeyPurchase.style.display, ''); assert.equal(api.btnGpcCardKeyPurchase.style.display, '');
assert.equal(api.rows.rowGpcHelperApi.style.display, ''); assert.equal(api.rows.rowGpcHelperApi.style.display, 'none');
assert.equal(api.rows.rowGpcHelperCardKey.style.display, ''); assert.equal(api.rows.rowGpcHelperCardKey.style.display, '');
assert.equal(api.rows.rowGpcHelperPhone.style.display, ''); assert.equal(api.rows.rowGpcHelperPhone.style.display, '');
assert.match(api.plusPaymentMethodCaption.textContent, /GPC/); assert.match(api.plusPaymentMethodCaption.textContent, /GPC/);
+2
View File
@@ -136,6 +136,8 @@ test('sidepanel html exposes Plus mode, PayPal, and GoPay settings', () => {
assert.match(html, /<option value="gpc-helper">GPC<\/option>/); assert.match(html, /<option value="gpc-helper">GPC<\/option>/);
assert.match(html, /id="btn-gpc-card-key-purchase"/); assert.match(html, /id="btn-gpc-card-key-purchase"/);
assert.match(html, />购买卡密</); assert.match(html, />购买卡密</);
assert.doesNotMatch(html, /GPC API/);
assert.doesNotMatch(html, /id="input-gpc-helper-api"/);
assert.match(html, /id="input-gpc-helper-card-key"/); assert.match(html, /id="input-gpc-helper-card-key"/);
assert.match(html, /id="btn-gpc-helper-balance"/); assert.match(html, /id="btn-gpc-helper-balance"/);
assert.match(html, /id="input-gpc-helper-phone"/); assert.match(html, /id="input-gpc-helper-phone"/);