Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add aria-describedby, aria-roledescription #3808

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8d96518
accessibility.js -> ts; + set aria-roledescription; add spec
weedySeaDragon Nov 15, 2022
0d9566d
diagrams: use a11y title,desc specific method (was renamed)
weedySeaDragon Nov 15, 2022
d997076
add "roledescription" to cSpell list of words (as in 'aria-roledescri…
weedySeaDragon Nov 15, 2022
c331305
Merge remote-tracking branch 'MERMAID/develop' into feat/3626-aria-ro…
weedySeaDragon Nov 17, 2022
03a11e1
(minor) fix typo
weedySeaDragon Nov 17, 2022
4d7496b
add error checking (empty diagramType, title, desc) to a11y methods
weedySeaDragon Nov 17, 2022
8a3c4f6
MockedD3: node() return Element; add selectAll()
weedySeaDragon Nov 17, 2022
1fc0294
move mocks specific to only seq spec files out of global d3 mock
weedySeaDragon Nov 17, 2022
1ad537b
d3 mock: use MockedD3; remove sequence specific mock code
weedySeaDragon Nov 17, 2022
f62c5d9
add diagram renderer mocks
weedySeaDragon Nov 17, 2022
29efc11
put a11y into mermaidAPI render; add render spec (mock diagram render…
weedySeaDragon Nov 17, 2022
0adc6a6
remove a11y from individual diagrams; now happens in mermaidAPI render
weedySeaDragon Nov 17, 2022
4fb4aa4
doc: revise A11y: fix multi-line ex, +describedby, alpha sort examples
weedySeaDragon Nov 17, 2022
9cc862b
doc: adding diagrams: revise a11y section
weedySeaDragon Nov 17, 2022
68b1805
(minor) fix typo, whitespace formatting
weedySeaDragon Nov 17, 2022
b51759d
set describeby to accessible description element id
weedySeaDragon Nov 17, 2022
6952640
format .md files
weedySeaDragon Nov 18, 2022
67a015c
re-re-fixed the contributing doc
weedySeaDragon Nov 18, 2022
2a98791
use optional chaining check for get acc title and get acc description
weedySeaDragon Nov 20, 2022
a9c3373
export D3Element from mermaidAPI; use in accessibility
weedySeaDragon Nov 20, 2022
626a474
Merge remote-tracking branch 'MERMAID/develop' into feat/3626-aria-de…
weedySeaDragon Nov 25, 2022
7508cd7
(minor) fix comment, comment typo
weedySeaDragon Nov 27, 2022
f1bc2de
use MockedD3, spies in util insertTitle spec (remove MockD3)
weedySeaDragon Nov 27, 2022
6e486d3
add test for multi-line accDescr
weedySeaDragon Nov 27, 2022
2030885
update /docs
weedySeaDragon Nov 27, 2022
e9d4372
Merge remote-tracking branch 'MERMAID/develop' into feat/3626-aria-de…
weedySeaDragon Nov 28, 2022
6044e9e
make test title clearer
weedySeaDragon Nov 28, 2022
2bf753a
use camelCase
weedySeaDragon Nov 28, 2022
f036d58
Merge remote-tracking branch 'MERMAID/develop' into feat/3626-aria-de…
weedySeaDragon Dec 1, 2022
bfe3f30
remove typeof
weedySeaDragon Dec 1, 2022
96996d0
Merge remote-tracking branch 'MERMAID/develop' into feat/3626-aria-de…
weedySeaDragon Dec 3, 2022
b1dd000
Merge remote-tracking branch 'MERMAID/develop' into feat/3626-aria-de…
weedySeaDragon Dec 7, 2022
1c9a559
common function for a11y; add to renderAsync; + renderAsync spec
weedySeaDragon Dec 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions __mocks__/c4Renderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Mocked C4Context diagram renderer
*/

import { vi } from 'vitest';

export const drawPersonOrSystemArray = vi.fn();
export const drawBoundary = vi.fn();

export const setConf = vi.fn();

export const draw = vi.fn().mockImplementation(() => {
return '';
});

export default {
drawPersonOrSystemArray,
drawBoundary,
setConf,
draw,
};
16 changes: 16 additions & 0 deletions __mocks__/classRenderer-v2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Mocked class diagram v2 renderer
*/

import { vi } from 'vitest';

export const setConf = vi.fn();

export const draw = vi.fn().mockImplementation(() => {
return '';
});

export default {
setConf,
draw,
};
13 changes: 13 additions & 0 deletions __mocks__/classRenderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Mocked class diagram renderer
*/

import { vi } from 'vitest';

export const draw = vi.fn().mockImplementation(() => {
return '';
});

export default {
draw,
};
71 changes: 3 additions & 68 deletions __mocks__/d3.ts
Original file line number Diff line number Diff line change
@@ -1,79 +1,14 @@
// @ts-nocheck TODO: Fix TS
import { vi } from 'vitest';

const NewD3 = function () {
/**
*
*/
function returnThis() {
return this;
}
return {
append: function () {
return NewD3();
},
lower: returnThis,
attr: returnThis,
style: returnThis,
text: returnThis,
0: {
0: {
getBBox: function () {
return {
height: 10,
width: 20,
};
},
},
},
};
};
import { MockedD3 } from '../packages/mermaid/src/tests/MockedD3';

export const select = function () {
return new NewD3();
return new MockedD3();
};

export const selectAll = function () {
return new NewD3();
return new MockedD3();
};

export const curveBasis = 'basis';
export const curveLinear = 'linear';
export const curveCardinal = 'cardinal';

export const MockD3 = (name, parent) => {
const children = [];
const elem = {
get __children() {
return children;
},
get __name() {
return name;
},
get __parent() {
return parent;
},
node() {
return {
getBBox() {
return {
x: 5,
y: 10,
height: 15,
width: 20,
};
},
};
},
};
elem.append = (name) => {
const mockElem = MockD3(name, elem);
children.push(mockElem);
return mockElem;
};
elem.lower = vi.fn(() => elem);
elem.attr = vi.fn(() => elem);
elem.text = vi.fn(() => elem);
elem.style = vi.fn(() => elem);
return elem;
};
16 changes: 16 additions & 0 deletions __mocks__/erRenderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Mocked er diagram renderer
*/

import { vi } from 'vitest';

export const setConf = vi.fn();

export const draw = vi.fn().mockImplementation(() => {
return '';
});

export default {
setConf,
draw,
};
24 changes: 24 additions & 0 deletions __mocks__/flowRenderer-v2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Mocked flow (flowchart) diagram v2 renderer
*/

import { vi } from 'vitest';

export const setConf = vi.fn();
export const addVertices = vi.fn();
export const addEdges = vi.fn();
export const getClasses = vi.fn().mockImplementation(() => {
return {};
});

export const draw = vi.fn().mockImplementation(() => {
return '';
});

export default {
setConf,
addVertices,
addEdges,
getClasses,
draw,
};
16 changes: 16 additions & 0 deletions __mocks__/ganttRenderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Mocked gantt diagram renderer
*/

import { vi } from 'vitest';

export const setConf = vi.fn();

export const draw = vi.fn().mockImplementation(() => {
return '';
});

export default {
setConf,
draw,
};
13 changes: 13 additions & 0 deletions __mocks__/gitGraphRenderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Mocked git (graph) diagram renderer
*/

import { vi } from 'vitest';

export const draw = vi.fn().mockImplementation(() => {
return '';
});

export default {
draw,
};
15 changes: 15 additions & 0 deletions __mocks__/journeyRenderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Mocked pie (picChart) diagram renderer
*/

import { vi } from 'vitest';
export const setConf = vi.fn();

export const draw = vi.fn().mockImplementation(() => {
return '';
});

export default {
setConf,
draw,
};
13 changes: 13 additions & 0 deletions __mocks__/pieRenderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Mocked pie (picChart) diagram renderer
*/

import { vi } from 'vitest';

export const draw = vi.fn().mockImplementation(() => {
return '';
});

export default {
draw,
};
13 changes: 13 additions & 0 deletions __mocks__/requirementRenderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Mocked requirement diagram renderer
*/

import { vi } from 'vitest';

export const draw = vi.fn().mockImplementation(() => {
return '';
});

export default {
draw,
};
23 changes: 23 additions & 0 deletions __mocks__/sequenceRenderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Mocked sequence diagram renderer
*/

import { vi } from 'vitest';

export const bounds = vi.fn();
export const drawActors = vi.fn();
export const drawActorsPopup = vi.fn();

export const setConf = vi.fn();

export const draw = vi.fn().mockImplementation(() => {
return '';
});

export default {
bounds,
drawActors,
drawActorsPopup,
setConf,
draw,
};
22 changes: 22 additions & 0 deletions __mocks__/stateRenderer-v2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Mocked state diagram v2 renderer
*/

import { vi } from 'vitest';

export const setConf = vi.fn();
export const getClasses = vi.fn().mockImplementation(() => {
return {};
});
export const stateDomId = vi.fn().mockImplementation(() => {
return 'mocked-stateDiagram-stateDomId';
});
export const draw = vi.fn().mockImplementation(() => {
return '';
});

export default {
setConf,
getClasses,
draw,
};
1 change: 1 addition & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"rect",
"rects",
"redmine",
"roledescription",
"sandboxed",
"setupgraphviewbox",
"shiki",
Expand Down
32 changes: 0 additions & 32 deletions cypress/integration/rendering/gantt.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,38 +310,6 @@ describe('Gantt diagram', () => {
);
});

it('should render accessibility tags', function () {
const expectedTitle = 'Gantt Diagram';
const expectedAccDescription = 'Tasks for Q4';
renderGraph(
`
gantt
accTitle: ${expectedTitle}
accDescr: ${expectedAccDescription}
dateFormat YYYY-MM-DD
section Section
A task :a1, 2014-01-01, 30d
`,
{}
);
cy.get('svg').should((svg) => {
const el = svg.get(0);
const children = [...el.children];

const titleEl = children.find(function (node) {
return node.tagName === 'title';
});
const descriptionEl = children.find(function (node) {
return node.tagName === 'desc';
});

expect(titleEl).to.exist;
expect(titleEl.textContent).to.equal(expectedTitle);
expect(descriptionEl).to.exist;
expect(descriptionEl.textContent).to.equal(expectedAccDescription);
});
});

it('should render a gantt diagram with tick is 15 minutes', () => {
imgSnapshotTest(
`
Expand Down
Loading