Today, Odoo is really tricky to use without seeing the screen, it must be improved to be usable. This PR forbid to use labels without a "for" attribute, add some title, rule and aria attributes in HTML. With that, Odoo will be fully usable with a screen reader. * [IMP] Labels must have a for attribute. Improve accessibility. * [IMP] Better error message when trying to read a missing cached value * [FIX] Add some aria-label and title attributes for screen readers. * [FIX] Template name is not included in the error message in case of SyntaxError in QWeb * [FIX] Improve the Tour failed at step error message to be more explicit. * [IMP] Add aria-labels * [FIX] Add missing aria-label on failing test * [IMP] aria-hidden means hidden. Fix all bad aria-hidden and hide aria-hidden for all. * [IMP] Color names on kanban views and many2many tags * [IMP] Add some checks on views for accessibility. * [IMP] Add `alt` attribute on `img` tags. * [IMP] Add aria-label and title on non-described icons * [IMP] Add button role to widgets with btn class * [IMP] Translate aria and formatted attributes. * [IMP] Remove wrong aria-labelledby * [IMP] Add menu role on dropdowns * [IMP] Buttons must be focusable * [IMP] Add aria attributes on progress bars * [IMP] Improve accessibility of basic widgets * [IMP] Change main layout to more semantic tags * [IMP] Add menuitem role when missing * [IMP] Remove wrong role='presentation' * [IMP] Improve accessibility of tab panels * [IMP] Add aria-invalid on invalid fields * [IMP] Add aria-sort on ordered columns * [IMP] Add role on alerts * [IMP] Use dialog role, header, main and footer tags for modals * [IMP] Add labels on o_status * [IMP] Improve accessibility of kanban view with feeds and articles * [IMP] Add alerts in case of new messages * [IMP] Add widget, navigation or img role to aria-labelled items
134 lines
5.0 KiB
JavaScript
134 lines
5.0 KiB
JavaScript
odoo.define('project.project_kanban_tests', function (require) {
|
|
"use strict";
|
|
|
|
var KanbanView = require('web.KanbanView');
|
|
var testUtils = require('web.test_utils');
|
|
|
|
var createView = testUtils.createView;
|
|
|
|
QUnit.module('project', {
|
|
beforeEach: function () {
|
|
this.data = {
|
|
'ir.attachment': {
|
|
fields: {
|
|
name: {
|
|
string: "Name",
|
|
type: "char"
|
|
},
|
|
},
|
|
records: [{
|
|
id: 1,
|
|
name: "1.png"
|
|
},
|
|
{
|
|
id: 2,
|
|
name: "2.png"
|
|
},
|
|
]
|
|
},
|
|
'project.task': {
|
|
fields: {
|
|
name: {
|
|
string: "Task Title",
|
|
type: "char"
|
|
},
|
|
sequence: {
|
|
string: "sequence",
|
|
type: "integer"
|
|
},
|
|
displayed_image_id: {
|
|
string: "cover",
|
|
type: "many2one",
|
|
relation: "ir.attachment"
|
|
},
|
|
kanban_state: {
|
|
string: "State",
|
|
type: "selection",
|
|
selection: [
|
|
["abc", "ABC"],
|
|
["def", "DEF"],
|
|
["ghi", "GHI"]
|
|
]
|
|
},
|
|
},
|
|
records: [{
|
|
id: 1,
|
|
name: "task1",
|
|
sequence: 1,
|
|
kanban_state: "abc"
|
|
},
|
|
{
|
|
id: 2,
|
|
name: "task2",
|
|
sequence: 2,
|
|
kanban_state: "abc"
|
|
},
|
|
]
|
|
},
|
|
};
|
|
}
|
|
}, function () {
|
|
QUnit.module('image test');
|
|
|
|
QUnit.test('cover_image_test', function (assert) {
|
|
assert.expect(6);
|
|
var kanban = createView({
|
|
View: KanbanView,
|
|
model: 'project.task',
|
|
data: this.data,
|
|
arch: '<kanban class="o_kanban_test">' +
|
|
'<templates>' +
|
|
'<t t-name="kanban-box">' +
|
|
'<div>' +
|
|
'<field name="name"/>' +
|
|
'<div class="o_dropdown_kanban dropdown">' +
|
|
'<a class="dropdown-toggle btn" data-toggle="dropdown" href="#">' +
|
|
'<span class="fa fa-bars fa-lg"/>' +
|
|
'</a>' +
|
|
'<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">' +
|
|
'<li>' +
|
|
'<a type="set_cover">Set Cover Image</a>'+
|
|
'</li>' +
|
|
'</ul>' +
|
|
'</div>' +
|
|
'<div>'+
|
|
'<field name="displayed_image_id" widget="attachment_image"/>'+
|
|
'</div>'+
|
|
'</div>' +
|
|
'</t>' +
|
|
'</templates>' +
|
|
'</kanban>',
|
|
mockRPC: function(route, args) {
|
|
if (args.model === 'ir.attachment' && args.method === 'search_read') {
|
|
return $.when([{
|
|
id: 1,
|
|
name: "1.png"
|
|
},{
|
|
id: 2,
|
|
name: "2.png"
|
|
}]);
|
|
}
|
|
if (args.model === 'project.task' && args.method === 'write') {
|
|
assert.step(args.args[0][0]);
|
|
return this._super(route, args);
|
|
}
|
|
return this._super(route, args);
|
|
},
|
|
});
|
|
assert.strictEqual(kanban.$('img').length, 0, "Initially there is no image.");
|
|
kanban.$('.o_dropdown_kanban [data-type=set_cover]').eq(0).click();
|
|
// single click on image
|
|
$('[role="dialog"]').find("img[data-id='1']").click();
|
|
$('footer.modal-footer .btn-primary').click();
|
|
assert.strictEqual(kanban.$('img[data-src*="/web/image/1"]').length, 1, "Image inserted in record");
|
|
$('.o_dropdown_kanban [data-type=set_cover]').eq(1).click();
|
|
// double click on image
|
|
$('[role="dialog"]').find("img[data-id='2']").dblclick();
|
|
assert.strictEqual(kanban.$('img[data-src*="/web/image/2"]').length, 1, "Image inserted after double click");
|
|
// varify write on both kanban record
|
|
assert.verifySteps([1,2]);
|
|
kanban.destroy();
|
|
});
|
|
});
|
|
});
|