Merge pull request 'Complete support request catalogue, shared actions and mobile signatures (328)' (#40) from dev/MC:dev/ticket-328-support-polish into checkpoint/alpha-1.0.0.3
Reviewed-on: unimatrix/MC#40
This commit is contained in:
commit
080b5b1499
11 changed files with 169 additions and 15 deletions
|
|
@ -32,7 +32,7 @@ function dune_shared_header($html) {
|
|||
// DuneRealms native MyBB surface polish
|
||||
if(($_SERVER['HTTP_HOST']??'')==='forums.dunerealms.com'){
|
||||
$html=str_replace('/dune-navigation.js?v=canonical-362','/dune-navigation.js?v=canonical-362',$html);
|
||||
$html=str_ireplace('</head>','<link rel="stylesheet" href="/dune-forum-polish.css?v=1"></head>',$html);
|
||||
$html=str_ireplace('</head>','<link rel="stylesheet" href="/dune-forum-polish.css?v=328-1"></head>',$html);
|
||||
$html=preg_replace_callback('/<body\b([^>]*)>/i',function($m){$attrs=$m[1];if(preg_match('/\bclass=["\']([^"\']*)["\']/i',$attrs))$attrs=preg_replace('/\bclass=(["\'])([^"\']*)\1/i','class="$2 dune-forum"',$attrs,1);else $attrs.=' class="dune-forum"';return '<body'.$attrs.'>';},$html,1);
|
||||
}
|
||||
if(!str_contains($html,'class="dune-shared-footer"'))$html=str_ireplace('</body>',file_get_contents($base.'shared-footer.html').'</body>',$html);
|
||||
|
|
|
|||
|
|
@ -45,3 +45,20 @@ body.dune-forum .post .author_information .smalltext{display:inline-block;margin
|
|||
body.dune-forum .post .author_statistics{position:relative;border:1px solid #8c82485e;border-left:2px solid #baa25e;background:#0c24187a;box-shadow:inset 0 0 0 2px #d4bd6010;border-radius:4px;padding:9px 14px!important;line-height:1.65;font-size:11px;color:#ced8bd!important}
|
||||
body.dune-forum .post .author_statistics a{color:#e7c77d!important}
|
||||
@media(max-width:650px){body.dune-forum .post .post_author{padding:19px!important}body.dune-forum .post .post_author::after{left:auto;right:22px;top:25px;transform:none;width:75px;height:75px;opacity:.07}body.dune-forum .post .author_statistics{margin-top:13px;display:inline-block;max-width:calc(100% - 30px)}body.dune-forum .post .author_information .largetext{font-size:17px}}
|
||||
|
||||
/* Native MyBB's 990/970px minima must not force mobile readers into a desktop canvas. */
|
||||
@media(max-width:760px){
|
||||
body.dune-forum #container{min-width:0!important;width:calc(100% - 24px)!important;max-width:calc(100% - 24px)!important;box-sizing:border-box}
|
||||
body.dune-forum .wrapper{min-width:0!important;width:100%!important;max-width:100%;box-sizing:border-box;overflow-wrap:anywhere}
|
||||
body.dune-forum #content{padding:12px!important;box-sizing:border-box}
|
||||
body.dune-forum .post :is(.post_content,.post_author){width:100%!important;min-width:0;box-sizing:border-box}
|
||||
body.dune-forum .post_body{overflow-wrap:anywhere}
|
||||
body.dune-forum .post_body img{max-width:100%;height:auto}
|
||||
body.dune-forum :is(textarea,select,input.textbox){max-width:100%;box-sizing:border-box}
|
||||
body.dune-forum .dune-managed-signature-panel>table,body.dune-forum .dune-managed-signature-panel>table>tbody{display:block;width:100%!important;white-space:normal!important}
|
||||
body.dune-forum .dune-managed-signature-panel>table>tbody>tr{display:flex;flex-wrap:wrap;gap:14px;white-space:normal!important}
|
||||
body.dune-forum .dune-managed-signature-panel>table>tbody>tr>td{display:block;max-width:100%;padding:0!important;border:0!important}
|
||||
body.dune-forum .dune-managed-signature-panel td :is(table,tbody){display:block;max-width:100%;white-space:normal!important}
|
||||
body.dune-forum .dune-managed-signature-panel td tr{display:flex;flex-wrap:wrap;gap:4px;white-space:normal!important}
|
||||
body.dune-forum .dune-managed-signature-panel td td{display:block;padding:0!important}
|
||||
}
|
||||
|
|
|
|||
27
website/integrations/osticket/SUPPORT-POLISH-328.md
Normal file
27
website/integrations/osticket/SUPPORT-POLISH-328.md
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# Support intake and native presentation (328)
|
||||
|
||||
This package implements consolidated sources 119, 133 and 134. It changes presentation and adds a customer-facing Sales intake; it does not change account checks, ticket access, Legal routing, department email addresses or award eligibility.
|
||||
|
||||
## Request catalogue
|
||||
|
||||
The homepage resolves an explicit list through `Topic::getPublicHelpTopics()`. It presents parental requests (with the separate child-removal link), GDPR removal, general help, Sales, forum help, technical problems, access issues, ban appeals and Alpha signup. Missing/non-public topics produce no card. Existing priority relationships and specialised appeal/Alpha handlers remain intact. Cards use two equal desktop columns and one mobile column; the final card has the same treatment as every other card.
|
||||
|
||||
`configure-public-sales.php` defaults to a read-only plan. Run it with `--apply` only for an authorised rollout. It creates **Customer sales enquiries**, routed through the existing Sales department/team, using only standard Ticket Details form 2. The existing private **Sales enquiries** email/internal topic remains private and unchanged. The installer requires transactional topic tables, serialises creation with a named lock, validates repeat runs and refuses routing/form drift. It does not create a ticket or process a payment/refund.
|
||||
|
||||
## Shared actions
|
||||
|
||||
Keep the existing `/dune-actions.css` and `/dune-actions.js` design system. Remove conflicting card/submit overrides rather than adding another button theme. The workspace shares typography and control sizing while retaining the shared neutral, approval and destructive variants, keyboard focus and disabled styles. Busy controls have a progress cursor.
|
||||
|
||||
The small Support-only `dune-support-actions.js` supplement gives native ticket-action links explicit semantics. A reused native `#confirm-form` derives its colour from the current hidden `do` action, so an “OK” button for deletion stays visibly destructive and a later owner-change confirmation loses the destructive treatment. It responds to PJAX/popup insertion and modal visibility changes. It only changes presentation classes/data attributes; it never invokes an action, changes a form field, submits a request or grants permission.
|
||||
|
||||
## Managed signatures and mobile forum
|
||||
|
||||
Preserve managed identity, original conversation bodies and email signature markup. The existing author checks, duplicate-signature protection and **25 verified closures in the same department** eligibility policy remain unchanged. Mobile CSS wraps presentation-table seal groups inside their container on Support and MyBB. MyBB's legacy 990/970px container minima are removed only below the mobile breakpoint; post text, images and native controls fit the available width.
|
||||
|
||||
Focused acceptance includes public-catalogue routing/private-topic omission, 86 native presentation checks preserving forms/CSRF/uploads/PJAX/JSON, seven ticket-author/signature checks, 16 departmental-award checks and three native-action tests under Node 22. PHP/JS syntax checks also pass. Source/avatar/receipt/payment/progression tests are outside this presentation change.
|
||||
|
||||
Browser verification uses an isolated Support fixture for desktop/mobile and confirmation-state changes, and a temporary candidate CSS overlay on the real public forum thread for mobile layout. The overlay is removed by reloading; it is not a publication. In that mobile check the 13 managed seal images loaded, the signature fit its container, and page width fell from 990px to within a 390px viewport. Final production form links/layout and installer idempotency must be verified during rollout. No real ticket, reply, refund, deletion or ban is submitted for QA.
|
||||
|
||||
## Rollback
|
||||
|
||||
Restore only the native PHP/CSS/JS files from the recorded per-rollout backup, preserving later unrelated edits. No static website Worker rebuild is required. If rolling back the new Sales intake, hide/disable only the newly created topic after checking whether it has received real tickets; retain those tickets and their history. Never restore entire native topic/ticket tables over subsequent customer activity. Existing private topics, mail settings, ranks, signatures and award records require no database rollback.
|
||||
36
website/integrations/osticket/configure-public-sales.php
Normal file
36
website/integrations/osticket/configure-public-sales.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
// Private CLI installer: a separate customer intake; the email/internal topic stays private.
|
||||
if (PHP_SAPI !== 'cli') exit(1);
|
||||
$apply = in_array('--apply', $argv, true);
|
||||
$c = json_decode(file_get_contents('/home/dunerealms/.config/integrations.json'), true);
|
||||
$db = new PDO('mysql:host='.$c['host'].';dbname='.$c['database'].';charset=utf8mb4', $c['username'], $c['password'], [PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE=>PDO::FETCH_ASSOC]);
|
||||
$source = $db->query("SELECT h.* FROM drsupport_help_topic h JOIN drsupport_department d ON d.id=h.dept_id WHERE h.topic='Sales enquiries' AND h.ispublic=0 AND d.name='Sales'")->fetch();
|
||||
if (!$source || !$db->query('SELECT id FROM drsupport_form WHERE id=2')->fetchColumn()) throw new RuntimeException('Private Sales route or standard Ticket Details form missing');
|
||||
$name = 'Customer sales enquiries';
|
||||
$lookup = $db->prepare('SELECT * FROM drsupport_help_topic WHERE topic=?');
|
||||
$lookup->execute([$name]);$existing=$lookup->fetch();
|
||||
function checkSalesIntake($row, $source, $db) {
|
||||
if ((int)$row['ispublic']!==1 || (int)$row['dept_id']!==(int)$source['dept_id'] || (int)$row['team_id']!==(int)$source['team_id'] || (int)$row['staff_id']!==0) throw new RuntimeException('Customer Sales intake routing drift; review manually');
|
||||
$q=$db->prepare('SELECT form_id FROM drsupport_help_topic_form WHERE topic_id=? ORDER BY form_id');$q->execute([$row['topic_id']]);
|
||||
if (array_map('intval',$q->fetchAll(PDO::FETCH_COLUMN))!==[2]) throw new RuntimeException('Customer Sales intake has unexpected forms');
|
||||
}
|
||||
if ($existing) { checkSalesIntake($existing,$source,$db);echo json_encode(['topicId'=>(int)$existing['topic_id'],'created'=>false,'privateTopicUnchanged'=>true]).PHP_EOL;exit; }
|
||||
if (!$apply) {echo json_encode(['wouldCreate'=>$name,'departmentId'=>(int)$source['dept_id'],'standardFormId'=>2,'privateTopicUnchanged'=>true]).PHP_EOL;exit;}
|
||||
$engines=$db->query("SELECT ENGINE FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME IN ('drsupport_help_topic','drsupport_help_topic_form')")->fetchAll(PDO::FETCH_COLUMN);
|
||||
if (count($engines)!==2 || array_filter($engines,static fn($v)=>strtoupper($v)!=='INNODB')) throw new RuntimeException('Transactional topic tables required');
|
||||
if ((int)$db->query("SELECT GET_LOCK('dune:public-sales:328',5)")->fetchColumn()!==1) throw new RuntimeException('Sales intake installer busy');
|
||||
try {
|
||||
$db->beginTransaction();
|
||||
$lookup->execute([$name]);$existing=$lookup->fetch();
|
||||
if ($existing) {checkSalesIntake($existing,$source,$db);$id=(int)$existing['topic_id'];$created=false;}
|
||||
else {
|
||||
$row=$source;unset($row['topic_id']);$row['topic']=$name;$row['ispublic']=1;$row['staff_id']=0;
|
||||
$row['notes']='Customer-facing Sales request. Manual review; no automatic refund, entitlement or payment action. Never request passwords or card details. Internal Sales email topic remains private.';
|
||||
$row['created']=$row['updated']=gmdate('Y-m-d H:i:s');
|
||||
$columns=array_keys($row);$q=$db->prepare('INSERT INTO drsupport_help_topic (`'.implode('`,`',$columns).'`) VALUES ('.implode(',',array_fill(0,count($columns),'?')).')');$q->execute(array_values($row));$id=(int)$db->lastInsertId();
|
||||
$q=$db->prepare("INSERT INTO drsupport_help_topic_form(topic_id,form_id,sort,extra) VALUES(?,2,1,'{}')");$q->execute([$id]);
|
||||
$lookup->execute([$name]);checkSalesIntake($lookup->fetch(),$source,$db);$created=true;
|
||||
}
|
||||
$db->commit();echo json_encode(['topicId'=>$id,'created'=>$created,'privateTopicUnchanged'=>true]).PHP_EOL;
|
||||
} catch (Throwable $e) {if($db->inTransaction())$db->rollBack();throw $e;}
|
||||
finally {$db->query("SELECT RELEASE_LOCK('dune:public-sales:328')");}
|
||||
30
website/integrations/osticket/dune-support-actions.js
Normal file
30
website/integrations/osticket/dune-support-actions.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* Supplement the shared action system with native osTicket action semantics.
|
||||
Presentation only: never clicks, submits, changes form values or authorises an action. */
|
||||
(() => {
|
||||
if (!document.body.classList.contains('dune-support-workspace')) return;
|
||||
const selector='a.ticket-action,a.confirm-action,#confirm-form input[type=submit],#confirm-form button[type=submit]';
|
||||
function kind(element) {
|
||||
if (element.closest('#confirm-form')) {
|
||||
return element.closest('form')?.querySelector('input[name=do]')?.value === 'delete' ? 'danger' : 'admin';
|
||||
}
|
||||
const href=element.getAttribute('href')||'';
|
||||
if (element.closest('li.danger') || /\/status\/delete(?:$|[?#])/.test(href) || href==='#banemail') return 'danger';
|
||||
if (href==='#unbanemail') return 'approve';
|
||||
return 'admin';
|
||||
}
|
||||
function refresh() {
|
||||
for (const element of document.querySelectorAll(selector)) {
|
||||
if (!element.classList.contains('dune-button')) element.classList.add('dune-button');
|
||||
const action=kind(element);
|
||||
if (element.dataset.duneAction!==action) element.dataset.duneAction=action;
|
||||
// Explicit native semantics take priority over the generic text classifier.
|
||||
if (element.dataset.duneAutoAction) delete element.dataset.duneAutoAction;
|
||||
}
|
||||
}
|
||||
refresh();
|
||||
let scheduled=false;
|
||||
new MutationObserver(() => {
|
||||
if (scheduled) return;
|
||||
scheduled=true;queueMicrotask(() => {scheduled=false;refresh();});
|
||||
}).observe(document.documentElement,{childList:true,subtree:true,attributes:true,attributeFilter:['style','hidden','value']});
|
||||
})();
|
||||
|
|
@ -9,12 +9,16 @@ $cards = [
|
|||
['Parental requests','FOR PARENTS & GUARDIANS','Request parental consent or ask about a child’s account. The Legal team reviews requests manually; this form does not automatically grant consent or change an account.','Parental consent request [Preview]','Open parental request','seals/department-legal-v2-150.png'],
|
||||
['GDPR data removal','PRIVACY & ACCOUNT DATA','Ask the Legal team to review deletion of your account data. Identify the relevant account and explain your request. Ownership and scope are verified before any action. Do not upload passwords or identity documents.','GDPR data removal request','Request data removal','seals/department-legal-150.png'],
|
||||
['General support','ACCOUNT, WEBSITE & GAME HELP','Tell Support what went wrong, where it happened, when it happened and what you tried. Include the error message or a relevant screenshot without passwords or unrelated personal information.','General support','Get support','nav-support-full-v2.webp'],
|
||||
['Sales enquiries','ORDERS & SHOP QUESTIONS','Ask Sales about an order, a shop item or a purchase issue. Include the order reference if available. Never send passwords, payment card details or account credentials.','Customer sales enquiries','Contact Sales','seals/department-sales-150.png'],
|
||||
['Forum support','HELP WITH THE BOARDS','Ask for help using the community boards or explain a forum account problem. Include the relevant page and error message without private messages or unrelated personal information.','Forum support','Get forum support','seals/department-forum-support-150.png'],
|
||||
['Report a problem','TECHNICAL ISSUES','Describe the issue, the page or world affected, when it happened and the steps needed to reproduce it. Attach only relevant screenshots or logs without credentials.','Report a Problem','Report a problem','nav-support-full-v2.webp'],
|
||||
['Access issues','GET HELP SIGNING IN','Explain which DuneRealms service you cannot access and the error you see. Staff will verify account ownership before changing access. Do not share passwords or verification codes.','Access Issue','Get access help','nav-account-full-v2.webp'],
|
||||
['Appeal a ban','REQUEST A MODERATION REVIEW','Use the ban ID to open a private appeal linked to the original ban. Explain the situation and attach relevant evidence. A pending appeal does not itself remove a ban.','Ban appeal','Open ban appeal','seals/department-ban-appeals-150.png'],
|
||||
['Become an Alpha tester','HELP SHAPE THE REALMS','Java or Bedrock, new or experienced: tell us what you would like to test. Applications are reviewed privately by Support.','Alpha Tester Signup','Sign up for Alpha testing','news-community.webp'],
|
||||
];
|
||||
$esc = static fn($v) => htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8');
|
||||
?>
|
||||
<link rel="stylesheet" href="/dune-support-home.css?v=20261102-1">
|
||||
<link rel="stylesheet" href="/dune-support-home.css?v=328-1">
|
||||
<div id="dune-support-home" class="dune-support-home">
|
||||
<div class="dune-support-options" aria-label="Support request types">
|
||||
<?php foreach ($cards as [$title,$label,$description,$topic,$button,$art]):
|
||||
|
|
|
|||
|
|
@ -50,6 +50,16 @@ body.dune-support-client :is(#header,#nav){display:none!important}
|
|||
.dune-support-submenu img{object-fit:contain;flex:none;filter:drop-shadow(0 2px 2px #0004)}
|
||||
body.dune-support.dune-support-workspace #dune-support-home.dune-support-home{padding:0!important}
|
||||
body.dune-support-workspace #content{font-family:Manrope,system-ui,sans-serif!important}
|
||||
body.dune-support-workspace .dune-button.dune-button.dune-button:not(.redactor-toolbar *):not(.tox *){font:600 14px/1.4 Manrope,system-ui,sans-serif!important;min-height:40px;white-space:normal}
|
||||
body.dune-support-workspace .dune-button.dune-button.dune-button[aria-busy=true]{cursor:progress;opacity:.7}
|
||||
@media(max-width:760px){
|
||||
body.dune-support-workspace .dune-managed-signature-panel>table,body.dune-support-workspace .dune-managed-signature-panel>table>tbody{display:block;width:100%!important;white-space:normal!important}
|
||||
body.dune-support-workspace .dune-managed-signature-panel>table>tbody>tr{display:flex;flex-wrap:wrap;gap:14px;white-space:normal!important}
|
||||
body.dune-support-workspace .dune-managed-signature-panel>table>tbody>tr>td{display:block;max-width:100%;padding:0!important;border:0!important}
|
||||
body.dune-support-workspace .dune-managed-signature-panel td :is(table,tbody){display:block;max-width:100%;white-space:normal!important}
|
||||
body.dune-support-workspace .dune-managed-signature-panel td tr{display:flex;flex-wrap:wrap;gap:4px;white-space:normal!important}
|
||||
body.dune-support-workspace .dune-managed-signature-panel td td{display:block;padding:0!important}
|
||||
}
|
||||
body.dune-support-client #content>h1{display:none}
|
||||
body.dune-support-workspace .dune-service-terms{padding:26px;border:1px solid #74814e;border-radius:12px;background:linear-gradient(130deg,#203f32,#102b21);line-height:1.7}
|
||||
body.dune-support-workspace .dune-support-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}
|
||||
|
|
@ -59,16 +69,12 @@ body.dune-support-workspace .dune-support-card>div{display:flex;flex-direction:c
|
|||
body.dune-support-workspace .dune-support-card .eyebrow{margin:0 0 7px;color:#d9bb70}
|
||||
body.dune-support-workspace .dune-support-card h2{font:700 24px/1.3 Manrope,system-ui,sans-serif!important;margin:3px 0 14px!important;color:#f1d58f!important}
|
||||
body.dune-support-workspace .dune-support-card p{font-size:14px;line-height:1.7;color:#c1d0bc;max-width:65ch}
|
||||
body.dune-support-workspace .dune-support-card a.button{margin-top:auto;background:#c6a551!important;color:#10261c!important;border-color:#d4b464!important;box-shadow:none;font:650 14px/1.4 Manrope,system-ui,sans-serif!important}
|
||||
body.dune-support-workspace .dune-support-card a.button{margin-top:auto}
|
||||
body.dune-support-workspace .dune-support-card .dune-secondary-request{margin:14px 0 0;font-size:12px;color:#e7c575}
|
||||
body.dune-support-workspace .dune-support-card:last-child{grid-column:1/-1;display:grid;grid-template-columns:140px minmax(0,1fr);align-items:center;gap:26px}
|
||||
body.dune-support-workspace .dune-support-card:last-child>img{width:140px;height:120px}
|
||||
body.dune-support-workspace .dune-support-card:last-child a.button{margin-top:7px}
|
||||
body.dune-support-workspace .dune-support-track{padding:18px 0;text-align:center;font-size:12px;color:#adc3ac}
|
||||
body.dune-support-workspace #content>form,body.dune-support-client #ticketInfo{box-sizing:border-box;border:1px solid #74814e!important;border-radius:12px!important;background:linear-gradient(130deg,#203f32,#102b21)!important;padding:24px!important;margin:20px 0!important;box-shadow:inset 0 0 0 4px #c2a15108}
|
||||
body.dune-support-workspace #content>form :is(th,td){line-height:1.7}
|
||||
body.dune-support-workspace #content>form h2{color:#f1d58f!important;border-bottom:1px solid #526b4b;padding-bottom:14px}
|
||||
body.dune-support-client #content :is(input[type=submit],button[type=submit],a.button){border-radius:7px!important;padding:11px 17px!important;font:650 14px/1.4 Manrope,system-ui,sans-serif!important}
|
||||
body.dune-support-workspace #footer{max-width:1120px;margin:20px auto!important;background:none!important;border:0!important;color:#9cb39b;font-size:11px}
|
||||
@media(max-width:760px){
|
||||
body.dune-support-workspace #container{width:calc(100% - 24px)!important;max-width:calc(100% - 24px)!important;margin:16px auto!important}
|
||||
|
|
@ -83,8 +89,6 @@ body.dune-support-workspace #footer{max-width:1120px;margin:20px auto!important;
|
|||
.dune-support-submenu img{width:28px;height:28px}
|
||||
body.dune-support-workspace .dune-support-options{grid-template-columns:1fr}
|
||||
body.dune-support-workspace .dune-support-card{padding:20px}
|
||||
body.dune-support-workspace .dune-support-card:last-child{display:flex;gap:14px}
|
||||
body.dune-support-workspace .dune-support-card:last-child>img{width:100px;height:90px}
|
||||
body.dune-support-workspace #content>form{padding:18px!important}
|
||||
}
|
||||
/* Client register: retain the native table, sort links, search and pagination. */
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
<?php
|
||||
class Topic {
|
||||
static $topics=[1=>'General support',2=>'Ban appeal',14=>'Parental consent request [Preview]',15=>'Parental data removal [Preview]',18=>'Alpha Tester Signup',19=>'GDPR data removal request'];
|
||||
static $topics=[1=>'General support',2=>'Ban appeal',10=>'Report a Problem',11=>'Access Issue',12=>'Forum support',14=>'Parental consent request [Preview]',15=>'Parental data removal [Preview]',18=>'Alpha Tester Signup',19=>'GDPR data removal request',21=>'Customer sales enquiries'];
|
||||
static function getPublicHelpTopics(){return self::$topics;}
|
||||
}
|
||||
function render(){ob_start();include __DIR__.'/dune-support-home.php';return ob_get_clean();}
|
||||
function check($v){if(!$v)throw new RuntimeException('Support home regression');}
|
||||
$html=render();check(substr_count($html,'class="dune-support-card"')===5);
|
||||
$html=render();check(substr_count($html,'class="dune-support-card"')===9);
|
||||
$previous=-1;foreach(['Parental requests','GDPR data removal','General support','Appeal a ban','Become an Alpha tester'] as $name){$at=strpos($html,'<h2>'.$name.'</h2>');check($at!==false&&$at>$previous);$previous=$at;}
|
||||
foreach(['/open.php?topicId=14','/open.php?topicId=15','/open.php?topicId=19','/open.php?topicId=1','/appeal.php','/alpha-signup.php','/view.php'] as $url)check(str_contains($html,'href="'.$url.'"'));
|
||||
foreach(['/open.php?topicId=14','/open.php?topicId=15','/open.php?topicId=19','/open.php?topicId=1','/open.php?topicId=10','/open.php?topicId=11','/open.php?topicId=12','/open.php?topicId=21','/appeal.php','/alpha-signup.php','/view.php'] as $url)check(str_contains($html,'href="'.$url.'"'));
|
||||
check(!str_contains($html,'Welcome to the Support Center'));check(str_contains($html,'does not automatically'));
|
||||
unset(Topic::$topics[19]);$without=render();check(!str_contains($without,'Request data removal'));check(substr_count($without,'class="dune-support-card"')===4);
|
||||
unset(Topic::$topics[19]);$without=render();check(!str_contains($without,'Request data removal'));check(substr_count($without,'class="dune-support-card"')===8);
|
||||
unset(Topic::$topics[21]);Topic::$topics[17]='Sales enquiries';Topic::$topics[20]='Development task';Topic::$topics[16]='Legal enquiries';$without=render();check(!str_contains($without,'Contact Sales'));foreach([16,17,20]as$id)check(!str_contains($without,'href="/open.php?topicId='.$id.'"'));
|
||||
Topic::$topics=[];check(!str_contains(render(),'class="dune-support-card"'));
|
||||
echo "Support home public-topic routing, priority, missing-topic and content checks passed\n";
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ function dune_support_workspace(string $html, string $path): string {
|
|||
else $attrs .= ' class="'.$classes.'"';
|
||||
return '<body'.$attrs.'>';
|
||||
}, $html, 1);
|
||||
return str_ireplace('</head>', '<link rel="stylesheet" href="/dune-support-workspace.css?v=364-4"><script src="/dune-support-workspace.js?v=364-4" defer></script></head>', $html);
|
||||
return str_ireplace('</head>', '<link rel="stylesheet" href="/dune-support-workspace.css?v=328-1"><script src="/dune-support-workspace.js?v=364-4" defer></script><script src="/dune-support-actions.js?v=328-1" defer></script></head>', $html);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ foreach(['/index.php','/open.php','/tickets.php','/view.php','/login.php','/alph
|
|||
check(str_contains($out,'https://cp.dunerealms.com/'),'Account return link missing');
|
||||
check(str_contains($out,$form),'Native form changed: '.$path);
|
||||
check(substr_count($out,'<section class="dune-support-workspace-hero"')===1,'Exactly one hero: '.$path);
|
||||
check(str_contains($out,'/dune-support-workspace.css?v=364-4'),'Style missing');
|
||||
check(str_contains($out,'/dune-support-workspace.css?v=328-1'),'Style missing');
|
||||
check(str_contains($out,'native dune-support-workspace'),'Native class lost');
|
||||
check(str_contains($out,str_starts_with($path,'/scp/')?'dune-support-staff':'dune-support-client'),'Workspace mismatch');
|
||||
check(dune_support_workspace($out,$path)===$out,'Not idempotent');
|
||||
|
|
|
|||
34
website/tests/support-actions.test.mjs
Normal file
34
website/tests/support-actions.test.mjs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {readFileSync} from 'node:fs';
|
||||
import vm from 'node:vm';
|
||||
|
||||
const script=readFileSync(new URL('../integrations/osticket/dune-support-actions.js',import.meta.url),'utf8');
|
||||
function element({href='',danger=false,form=null}={}) {
|
||||
const classes=new Set();return {dataset:{duneAutoAction:'true'},classList:{contains:x=>classes.has(x),add:x=>classes.add(x)},
|
||||
getAttribute:name=>name==='href'?href:null,
|
||||
closest:selector=>selector==='#confirm-form'||selector==='form'?form:selector==='li.danger'&&danger?{}:null};
|
||||
}
|
||||
function run(elements,workspace=true) {
|
||||
let observer,options;const body={classList:{contains:()=>workspace}};
|
||||
vm.runInNewContext(script,{document:{body,documentElement:{},querySelectorAll:()=>elements},queueMicrotask,
|
||||
MutationObserver:class {constructor(callback){observer=callback;}observe(_root,config){options=config;}}});
|
||||
return {refresh:async()=>{observer();await Promise.resolve();},get options(){return options;}};
|
||||
}
|
||||
test('native destructive links retain distinct danger semantics and unban is approval',()=>{
|
||||
const remove=element({href:'#tickets/7/status/delete'}),menu=element({danger:true}),ban=element({href:'#banemail'}),unban=element({href:'#unbanemail'}),other=element({href:'#assign'});
|
||||
run([remove,menu,ban,unban,other]);
|
||||
for(const el of [remove,menu,ban])assert.equal(el.dataset.duneAction,'danger');
|
||||
assert.equal(unban.dataset.duneAction,'approve');assert.equal(other.dataset.duneAction,'admin');
|
||||
assert.equal(remove.dataset.duneAutoAction,undefined);assert.equal(remove.classList.contains('dune-button'),true);
|
||||
});
|
||||
test('a reused native confirmation follows the current hidden action instead of stale button text',async()=>{
|
||||
const action={value:'delete'},form={querySelector:()=>action},confirm=element({form});const runtime=run([confirm]);
|
||||
assert.equal(confirm.dataset.duneAction,'danger');action.value='changeuser';await runtime.refresh();assert.equal(confirm.dataset.duneAction,'admin');
|
||||
action.value='delete';await runtime.refresh();assert.equal(confirm.dataset.duneAction,'danger');
|
||||
assert.deepEqual(Array.from(runtime.options.attributeFilter),['style','hidden','value']);
|
||||
});
|
||||
test('native popup/PJAX controls added later are included; unrelated pages are untouched',async()=>{
|
||||
const elements=[];const runtime=run(elements);const added=element({danger:true});elements.push(added);await runtime.refresh();assert.equal(added.dataset.duneAction,'danger');
|
||||
const untouched=element({danger:true});const other=run([untouched],false);assert.equal(untouched.dataset.duneAction,undefined);assert.equal(other.options,undefined);
|
||||
});
|
||||
Loading…
Reference in a new issue

Staff