snap-ally 0.1.1-beta → 0.2.2-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,9 @@ document.addEventListener('DOMContentLoaded', () => {
12
12
  }
13
13
 
14
14
  // Set up custom severity colors if provided
15
- applyCustomColors(data);
15
+ // Unwrap nested data format used by accessibility reports (e.g. { data: reportData })
16
+ const effective = data.data || data;
17
+ applyCustomColors(effective);
16
18
 
17
19
  // Determine which template we are on based on root containers
18
20
  if (document.getElementById('report-summary-root')) {
@@ -516,16 +518,7 @@ function renderAccessibilityReport(injectedData) {
516
518
  bClone.querySelector('.bug-rule-name').textContent = v.help;
517
519
  bClone.querySelector('.bug-snippet-text').textContent = snippetText;
518
520
 
519
- const btn = bClone.querySelector('.btn-bug');
520
- // generateAdoPayload binding
521
- const safeSnippet = escapeHtml(snippetText);
522
- const wcag = escapeHtml(v.wcagRule || (v.tags ? v.tags.join(', ') : ''));
523
- btn.setAttribute(
524
- 'onclick',
525
- `event.preventDefault(); event.stopPropagation(); window.generateAdoPayload('${escapeHtml(v.id || 'Unknown ID')}', '${escapeHtml(v.help || 'No Help Provided')}', '${escapeHtml(node.failureSummary || '')}', '${escapeHtml(node.html || '')}', '${impact || 'unknown'}', '${escapeHtml(node.screenshotBase64 || node.screenshot || node.screenshotPath || '')}', '${escapeHtml(videoPath || '')}', '${safeSnippet}', '${wcag}')`
526
- );
527
-
528
- const failSec = bClone.querySelector('.bug-failure-summary');
521
+ // Parse steps for both the card display and the bug dialog
529
522
  let stepsArray = node.steps || [];
530
523
  if (typeof stepsArray === 'string') {
531
524
  try {
@@ -535,6 +528,18 @@ function renderAccessibilityReport(injectedData) {
535
528
  }
536
529
  }
537
530
 
531
+ const btn = bClone.querySelector('.btn-bug');
532
+ // generateAdoPayload binding — encode steps as JSON for safe transport
533
+ const safeSnippet = escapeHtml(snippetText);
534
+ const wcag = escapeHtml(v.wcagRule || (v.tags ? v.tags.join(', ') : ''));
535
+ const safeStepsJson = encodeURIComponent(JSON.stringify(stepsArray));
536
+ btn.setAttribute(
537
+ 'onclick',
538
+ `event.preventDefault(); event.stopPropagation(); window.generateAdoPayload('${escapeHtml(v.id || 'Unknown ID')}', '${escapeHtml(v.help || 'No Help Provided')}', '${escapeHtml(node.failureSummary || '')}', '${escapeHtml(node.html || '')}', '${impact || 'unknown'}', '${escapeHtml(node.screenshotBase64 || node.screenshot || node.screenshotPath || '')}', '${escapeHtml(videoPath || '')}', '${safeSnippet}', '${wcag}', '${safeStepsJson}')`
539
+ );
540
+
541
+ const failSec = bClone.querySelector('.bug-failure-summary');
542
+
538
543
  if (stepsArray && stepsArray.length > 0) {
539
544
  failSec.innerHTML = `<ol style="margin: 0; padding-left: 18px; line-height: 1.5;">${stepsArray.map((s) => `<li>${escapeHtml(s)}</li>`).join('')}</ol>`;
540
545
  failSec.style.fontFamily = 'Inter, sans-serif';
@@ -740,7 +745,8 @@ window.generateAdoPayload = function (
740
745
  screenshotBase64,
741
746
  videoPath,
742
747
  snippet,
743
- wcag
748
+ wcag,
749
+ stepsJson
744
750
  ) {
745
751
  const pat = sessionStorage.getItem('userToken');
746
752
  if (!pat && window.bootstrap) {
@@ -754,11 +760,32 @@ window.generateAdoPayload = function (
754
760
  document.getElementById('bugTitleInput').value = `[A11y] ${help} (${snippet})`;
755
761
  document.getElementById('bugSeverityInput').value = severity;
756
762
 
757
- const data = window.snapAllyData || {};
763
+ const rawData = window.snapAllyData || {};
764
+ const data = rawData.data || rawData;
758
765
  const currentUrl = document.getElementById('bugUrlPreview');
759
766
  if (currentUrl) currentUrl.textContent = data.pageUrl || data.pageKey || 'Resource';
760
767
 
761
- const stepsHtml = `
768
+ // Decode the reproduction steps passed from the violation card
769
+ let reproSteps = [];
770
+ if (stepsJson) {
771
+ try {
772
+ reproSteps = JSON.parse(decodeURIComponent(stepsJson));
773
+ } catch {
774
+ reproSteps = [];
775
+ }
776
+ }
777
+
778
+ // Build the reproduction steps HTML section
779
+ let reproStepsHtml = '';
780
+ if (reproSteps.length > 0) {
781
+ reproStepsHtml = `
782
+ <div style="border-top: 1px solid #e2e8f0; margin: 8px 0; padding-top: 8px;"><b>Reproduction Steps:</b></div>
783
+ <ol style="margin: 8px 0; padding-left: 20px; line-height: 1.6; font-family: Inter, sans-serif;">
784
+ ${reproSteps.map((s) => `<li>${escapeHtml(s)}</li>`).join('')}
785
+ </ol>`;
786
+ }
787
+
788
+ const failureHtml = `
762
789
  <div style="font-family: monospace; background: #fffcf0; padding: 12px; border: 1px solid #e2e8f0;">
763
790
  ${failureSummary ? failureSummary.replace(/\\n/g, '<br>') : 'Issue discovered via static analysis scans.'}
764
791
  </div>
@@ -768,11 +795,15 @@ window.generateAdoPayload = function (
768
795
  </div>
769
796
  `;
770
797
 
798
+ // Combine everything into the full repro HTML used for both preview and ADO payload
799
+ const stepsHtml = reproStepsHtml + failureHtml;
800
+
771
801
  document.getElementById('bugReproPreview').innerHTML = `
772
802
  <div style="margin-bottom: 4px;"><b>Rule:</b> ${axeId} (${wcag})</div>
773
803
  <div style="margin-bottom: 8px;"><b>Recommendation:</b> ${help}</div>
804
+ ${reproStepsHtml ? reproStepsHtml : ''}
774
805
  <div style="border-top: 1px solid #e2e8f0; margin: 8px 0; padding-top: 8px;"><b>Failure Summary:</b></div>
775
- ${stepsHtml}
806
+ ${failureHtml}
776
807
  `;
777
808
 
778
809
  const screenshotPreview = document.getElementById('bugScreenshotPreview');
@@ -814,7 +845,8 @@ window.generateAdoPayload = function (
814
845
  };
815
846
 
816
847
  async function uploadAttachment(blob, name) {
817
- const data = window.snapAllyData || {};
848
+ const rawData = window.snapAllyData || {};
849
+ const data = rawData.data || rawData;
818
850
  const org = data.adoOrganization;
819
851
  const proj = data.adoProject;
820
852
  const pat = sessionStorage.getItem('userToken');
@@ -833,7 +865,8 @@ async function uploadAttachment(blob, name) {
833
865
  }
834
866
 
835
867
  async function submitFinalBug() {
836
- const data = window.snapAllyData || {};
868
+ const rawData = window.snapAllyData || {};
869
+ const data = rawData.data || rawData;
837
870
  const org = data.adoOrganization;
838
871
  const proj = data.adoProject;
839
872
  const pat = sessionStorage.getItem('userToken');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snap-ally",
3
- "version": "0.1.1-beta",
3
+ "version": "0.2.2-beta",
4
4
  "description": "A custom Playwright reporter for Accessibility testing using Axe, with HTML reporting and Azure DevOps integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",