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

Dialogs: Add axe tests #4991

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 37 additions & 0 deletions components/dialog/test/dialog-confirm.axe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import '../dialog-confirm.js';
import '../../button/button.js';
import { expect, fixture, html } from '@brightspace-ui/testing';

describe('d2l-dialog-confirm', () => {

it('closed', async() => {
const el = await fixture(html`<d2l-dialog-confirm></d2l-dialog-confirm>`);
await expect(el).to.be.accessible();
});

it('default with title-text', async() => {
const el = await fixture(html`<d2l-dialog-confirm opened title-text="My Dialog" text="My dialog content"></d2l-dialog-confirm>`);
await expect(el).to.be.accessible();
});

it('critical', async() => {
const el = await fixture(html`<d2l-dialog-cofirm opened title-text="My Dialog" critical text="My dialog content"></d2l-dialog-confirm>`);
await expect(el).to.be.accessible();
});

it('footer buttons', async() => {
const el = await fixture(html`
<d2l-dialog-cofirm title-text="Dialog Title" opened text="My dialog content">
<d2l-button slot="footer" primary data-dialog-action="done">Done</d2l-button>
<d2l-button slot="footer" data-dialog-action>Cancel</d2l-button>
</d2l-dialog-confirm>
`);
await expect(el).to.be.accessible();
});

it('no title-text', async() => {
const el = await fixture(html`<d2l-dialog-cofirm opened text="My dialog content"></d2l-dialog-confirm>`);
await expect(el).to.be.accessible();
});

});
44 changes: 44 additions & 0 deletions components/dialog/test/dialog-fullscreen.axe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import '../dialog-fullscreen.js';
import '../../button/button.js';
import { expect, fixture, html } from '@brightspace-ui/testing';

describe('d2l-dialog-fullscreen', () => {

it('closed', async() => {
const el = await fixture(html`<d2l-dialog-fullscreen></d2l-dialog-fullscreen>`);
await expect(el).to.be.accessible();
});

it('default with title-text', async() => {
const el = await fixture(html`<d2l-dialog-fullscreen opened title-text="My Dialog"></d2l-dialog-fullscreen>`);
await expect(el).to.be.accessible();
});

it('footer buttons', async() => {
const el = await fixture(html`
<d2l-dialog-fullscreen title-text="Dialog Title" opened>
<div>Some dialog content</div>
<d2l-button slot="footer" primary data-dialog-action="done">Done</d2l-button>
<d2l-button slot="footer" data-dialog-action>Cancel</d2l-button>
</d2l-dialog-fullscreen>
`);
await expect(el).to.be.accessible();
});

it.skip('no title-text', async() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently list title-text as optional, but it's an axe violation if not present on this and d2l-dialog (d2l-dialog-confirm uses text as backup). I've asked Jeff what he would recommend here.

const el = await fixture(html`<d2l-dialog-fullscreen opened>My content</d2l-dialog-fullscreen>`);
await expect(el).to.be.accessible();
});

it.skip('tall content', async() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the problem we want to address in the defect.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And presumably this test fails if it isn't skipped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does indeed!

const el = await fixture(html`
<d2l-dialog-fullscreen opened title-text="My Dialog">
<div style="overflow-y: scroll; height:200px;">
<div style="height: 10000px;">My content</div>
</div>
</d2l-dialog-fullscreen>
`);
await expect(el).to.be.accessible();
});

});
49 changes: 49 additions & 0 deletions components/dialog/test/dialog.axe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import '../dialog.js';
import '../../button/button.js';
import { expect, fixture, html } from '@brightspace-ui/testing';

describe('d2l-dialog', () => {

it('closed', async() => {
const el = await fixture(html`<d2l-dialog></d2l-dialog>`);
await expect(el).to.be.accessible();
});

it('default with title-text', async() => {
const el = await fixture(html`<d2l-dialog opened title-text="My Dialog"></d2l-dialog>`);
await expect(el).to.be.accessible();
});

it('describe-content', async() => {
const el = await fixture(html`<d2l-dialog opened title-text="My Dialog" describe-content>My content</d2l-dialog>`);
await expect(el).to.be.accessible();
});

it('footer buttons', async() => {
const el = await fixture(html`
<d2l-dialog title-text="Dialog Title" opened>
<div>Some dialog content</div>
<d2l-button slot="footer" primary data-dialog-action="done">Done</d2l-button>
<d2l-button slot="footer" data-dialog-action>Cancel</d2l-button>
</d2l-dialog>
`);
await expect(el).to.be.accessible();
});

it.skip('no title-text', async() => {
const el = await fixture(html`<d2l-dialog opened>My content</d2l-dialog>`);
await expect(el).to.be.accessible();
});

it.skip('tall content', async() => {
const el = await fixture(html`
<d2l-dialog opened title-text="My Dialog">
<div style="overflow-y: scroll; height:200px;">
<div style="height: 10000px;">My content</div>
</div>
</d2l-dialog>
`);
await expect(el).to.be.accessible();
});

});
Loading