Skip to content

Commit 05803d9

Browse files
author
Oleksandr Dubovyk
committed
MC-40653: Duplicate ID issue on the account page
- fixed - added test
1 parent 3b397a9 commit 05803d9

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed

app/design/frontend/Magento/blank/Magento_Theme/web/js/theme.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ define([
1717
});
1818

1919
$('.panel.header > .header.links').clone().appendTo('#store\\.links');
20+
$('#store\\.links .customer-menu li a').each(function () {
21+
var id = $(this).attr('id');
22+
23+
if (id !== undefined) {
24+
$(this).attr('id', id + '_mobile');
25+
}
26+
});
2027

2128
keyboardHandler.apply();
2229
});
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<div class="panel header">
8+
<!-- This markup portion is the source for Mobile View Navigation Menu -->
9+
<ul class="header links">
10+
<li class="greet welcome" data-bind="scope: 'customer'">
11+
<span class="logged-in">Welcome, John Doe!</span>
12+
</li>
13+
14+
<li class="customer-welcome active">
15+
<span class="customer-name active" role="button">
16+
<button type="button" class="action switch" data-action="customer-menu-toggle">
17+
<span>Change</span>
18+
</button>
19+
</span>
20+
21+
<div class="customer-menu" data-target="dropdown" aria-hidden="false">
22+
<ul class="header links">
23+
<li>
24+
<a href="http://magento.store/account/" id="my-account">My Account</a>
25+
</li>
26+
<li class="link wishlist" data-bind="scope: 'wishlist'">
27+
<a href="http://magento.store/wishlist/" id="my-wishlist">My WishList</a>
28+
</li>
29+
<li>
30+
<a href="http://magento.store/orders/" id="my-orders">My Orders</a>
31+
</li>
32+
<li>
33+
<a href="http://magento.store/addresses/" id="my-addresses">My Addresses</a>
34+
</li>
35+
<li class="link authorization-link" data-label="or">
36+
<a href="http://magento.store/customer/account/logout/">Sign Out</a>
37+
</li>
38+
</ul>
39+
</div>
40+
</li>
41+
<li class="link authorization-link" data-label="or">
42+
<a href="http://magento.store/customer/account/logout/">Sign Out</a>
43+
</li>
44+
</ul>
45+
</div>
46+
47+
<div id="store.links">
48+
<!-- Navigation Menu for Mobile View will be cloned here from the source -->
49+
</div>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
/* eslint-disable max-nested-callbacks */
7+
define([
8+
'jquery',
9+
'squire',
10+
'text!tests/assets/lib/web/mage/account_menu.html'
11+
], function ($, Squire, header) {
12+
'use strict';
13+
14+
describe('Magento_Theme/js/theme', function () {
15+
var injector = new Squire(),
16+
mocks = {};
17+
18+
beforeEach(function (done) {
19+
var $menu = $(header);
20+
21+
$('body').append($menu);
22+
23+
injector.mock(mocks);
24+
injector.require(['Magento_Theme/js/theme'], function () {
25+
done();
26+
});
27+
});
28+
29+
afterEach(function () {
30+
try {
31+
injector.clean();
32+
injector.remove();
33+
header = null;
34+
} catch (e) {}
35+
});
36+
37+
it('should add suffix "_mobile" to the html ID attribute (if exists) ' +
38+
'for every menu link to make IDs unique after cloning', function () {
39+
var suffix = '_mobile',
40+
menuItems = [
41+
{
42+
id: '#my-account' + suffix,
43+
link: 'http://magento.store/account/'
44+
},
45+
{
46+
id: '#my-wishlist' + suffix,
47+
link: 'http://magento.store/wishlist/'
48+
},
49+
{
50+
id: '#my-orders' + suffix,
51+
link: 'http://magento.store/orders/'
52+
},
53+
{
54+
id: '#my-addresses' + suffix,
55+
link: 'http://magento.store/addresses/'
56+
}
57+
];
58+
59+
menuItems.forEach(function (item) {
60+
expect($(item.id).attr('href')).toBe(item.link)
61+
});
62+
});
63+
});
64+
});

0 commit comments

Comments
 (0)