@afixt/test-utils 1.1.4 → 1.1.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afixt/test-utils",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Various utilities for accessibility testing",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -319,6 +319,23 @@ function getAccessibleName(element) {
319
319
  }
320
320
  }
321
321
 
322
+ // STEP 11-3: object element
323
+ // Per ACT Rule 8fc3b6, object elements rendering non-text content
324
+ // can receive accessible name from aria-labelledby, aria-label (handled above),
325
+ // title attribute, or fallback content (handled at end via getAccessibleText)
326
+ // STEP 11-3.1: use title attribute
327
+ // STEP 11-3.2: fallback content is handled at the end via getAccessibleText
328
+ if (element.tagName.toLowerCase() === "object") {
329
+ if (element.hasAttribute("title")) {
330
+ const titleValue = element.getAttribute("title");
331
+ if (strlen(titleValue) > 0) {
332
+ return titleValue;
333
+ }
334
+ }
335
+ // Fallback content will be handled by getAccessibleText at the end
336
+ // So we don't return false here - let it fall through
337
+ }
338
+
322
339
  // STEP 12: table element
323
340
  // STEP 12.1: caption element
324
341
  // STEP 12.2: use the title attribute
@@ -292,4 +292,34 @@ describe('getAccessibleName', () => {
292
292
  const select = document.querySelector('select');
293
293
  expect(getAccessibleName(select)).toBe(false);
294
294
  });
295
+
296
+ it('should handle object element with title attribute', () => {
297
+ document.body.innerHTML = `<object data="chart.pdf" type="application/pdf" title="Q4 Sales Report"></object>`;
298
+ const obj = document.querySelector('object');
299
+ expect(getAccessibleName(obj)).toBe('Q4 Sales Report');
300
+ });
301
+
302
+ it('should handle object element with fallback content', () => {
303
+ document.body.innerHTML = `<object data="diagram.svg" type="image/svg+xml"><p>Network architecture diagram</p></object>`;
304
+ const obj = document.querySelector('object');
305
+ expect(getAccessibleName(obj)).toBe('Network architecture diagram');
306
+ });
307
+
308
+ it('should handle object element with aria-label', () => {
309
+ document.body.innerHTML = `<object data="chart.pdf" aria-label="Annual Revenue Chart"></object>`;
310
+ const obj = document.querySelector('object');
311
+ expect(getAccessibleName(obj)).toBe('Annual Revenue Chart');
312
+ });
313
+
314
+ it('should return false for object element without accessible name', () => {
315
+ document.body.innerHTML = `<object data="chart.pdf" type="application/pdf"></object>`;
316
+ const obj = document.querySelector('object');
317
+ expect(getAccessibleName(obj)).toBe(false);
318
+ });
319
+
320
+ it('should handle object element with empty title', () => {
321
+ document.body.innerHTML = `<object data="chart.pdf" title=""></object>`;
322
+ const obj = document.querySelector('object');
323
+ expect(getAccessibleName(obj)).toBe(false);
324
+ });
295
325
  });