29 lines
1.5 KiB
JavaScript
29 lines
1.5 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const source = fs.readFileSync(path.join(__dirname, '..', 'utils', 'CommonUtil.js'), 'utf8');
|
|
|
|
function assertContains(pattern, message) {
|
|
if (!pattern.test(source)) {
|
|
console.error(message);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
assertContains(/topbar__btn--signin/, 'Expected public topbar to inject a sign-in button.');
|
|
assertContains(/CommonUtil\.signIn\(/, 'Expected sign-in button to call CommonUtil.signIn().');
|
|
assertContains(/text:\s*['"]\u7b7e\u5230['"]/, 'Expected sign-in button text to be sign in.');
|
|
assertContains(/ensureTopbarSignInStyle/, 'Expected public topbar to install a dedicated sign-in button style.');
|
|
assertContains(/\.topbar__btn--signin\s*\{/, 'Expected dedicated sign-in button CSS to be injected.');
|
|
assertContains(/setTopbarSignInSigned/, 'Expected a shared helper to lock the topbar sign-in button.');
|
|
assertContains(/\u5df2\u7b7e\u5230/, 'Expected signed state text to be already signed.');
|
|
assertContains(/mineSignInStatus|\/api\/web\/mine\/sign-in\/status/, 'Expected topbar to load the current sign-in status.');
|
|
assertContains(/\u5df2\u7b7e\u5230\|\u5df2\u7b7e\|\u5df2\u7ecf\u7b7e\u5230\|\u7b7e\u5230\u8fc7/, 'Expected already-signed API messages to lock the button.');
|
|
|
|
if (/class:\s*['"][^'"]*topbar__btn--signin[^'"]*topbar__btn--primary/.test(source)) {
|
|
console.error('Expected sign-in button to use a quieter dedicated style, not the primary button style.');
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('topbar sign-in checks passed');
|