mirror of
https://github.com/dwaxweiler/connector-mobilizon
synced 2025-02-16 11:41:24 +01:00
add group not found error message #11
This commit is contained in:
parent
80dd0c9c50
commit
34aaaa7db9
@ -1,5 +1,6 @@
|
|||||||
### [Unreleased]
|
### [Unreleased]
|
||||||
#### Added
|
#### Added
|
||||||
|
- Add specific error message for the case the group is not found
|
||||||
#### Changed
|
#### Changed
|
||||||
- Set minimum PHP version to oldest officially supported 7.4
|
- Set minimum PHP version to oldest officially supported 7.4
|
||||||
- Update dependencies
|
- Update dependencies
|
||||||
|
@ -17,6 +17,9 @@ test.beforeEach(t => {
|
|||||||
const listElement = document.createElement('li')
|
const listElement = document.createElement('li')
|
||||||
listElement.setAttribute('style', 'display: none;')
|
listElement.setAttribute('style', 'display: none;')
|
||||||
t.context.list.appendChild(listElement)
|
t.context.list.appendChild(listElement)
|
||||||
|
const listElement2 = document.createElement('li')
|
||||||
|
listElement2.setAttribute('style', 'display: none;')
|
||||||
|
t.context.list.appendChild(listElement2)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('#displayEvents one event', t => {
|
test('#displayEvents one event', t => {
|
||||||
@ -38,24 +41,32 @@ test('#displayEvents one event', t => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
displayEvents({ data, document, list })
|
displayEvents({ data, document, list })
|
||||||
t.is(list.children.length, 2)
|
t.is(list.children.length, 3)
|
||||||
t.is(list.children[1].childNodes[0].tagName, 'A')
|
t.is(list.children[2].childNodes[0].tagName, 'A')
|
||||||
t.is(list.children[1].childNodes[0].getAttribute('href'), 'b')
|
t.is(list.children[2].childNodes[0].getAttribute('href'), 'b')
|
||||||
t.is(list.children[1].childNodes[0].childNodes[0].nodeValue, 'a')
|
t.is(list.children[2].childNodes[0].childNodes[0].nodeValue, 'a')
|
||||||
t.is(list.children[1].childNodes[1].tagName, 'BR')
|
t.is(list.children[2].childNodes[1].tagName, 'BR')
|
||||||
t.is(list.children[1].childNodes[2].nodeValue, '15/04/2021 10:30 - 15:30')
|
t.is(list.children[2].childNodes[2].nodeValue, '15/04/2021 10:30 - 15:30')
|
||||||
t.is(list.children[1].childNodes[3].tagName, 'BR')
|
t.is(list.children[2].childNodes[3].tagName, 'BR')
|
||||||
t.is(list.children[1].childNodes[4].nodeValue, 'c, d')
|
t.is(list.children[2].childNodes[4].nodeValue, 'c, d')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('#displayErrorMessage no children added', t => {
|
test('#displayErrorMessage no children added', t => {
|
||||||
const list = t.context.list
|
const list = t.context.list
|
||||||
displayErrorMessage({ data: '', list })
|
displayErrorMessage({ data: '', list })
|
||||||
t.is(list.children.length, 1)
|
t.is(list.children.length, 2)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('#displayErrorMessage error message display', t => {
|
test('#displayErrorMessage error message display', t => {
|
||||||
const list = t.context.list
|
const list = t.context.list
|
||||||
displayErrorMessage({ data: '', list })
|
displayErrorMessage({ data: '', list })
|
||||||
t.is(list.children[0].style.display, 'block')
|
t.is(list.children[0].style.display, 'block')
|
||||||
|
t.is(list.children[1].style.display, 'none')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('#displayErrorMessage group not found error message display', t => {
|
||||||
|
const list = t.context.list
|
||||||
|
displayErrorMessage({ data: 'group_not_found', list })
|
||||||
|
t.is(list.children[0].style.display, 'none')
|
||||||
|
t.is(list.children[1].style.display, 'block')
|
||||||
})
|
})
|
||||||
|
@ -47,5 +47,13 @@ export function displayEvents({ data, document, list }) {
|
|||||||
|
|
||||||
export function displayErrorMessage({ data, list }) {
|
export function displayErrorMessage({ data, list }) {
|
||||||
console.error(data)
|
console.error(data)
|
||||||
list.children[0].style.display = 'block'
|
if (Object.prototype.hasOwnProperty.call(data, 'response') &&
|
||||||
|
Object.prototype.hasOwnProperty.call(data.response, 'errors') &&
|
||||||
|
data.response.errors.length > 0 &&
|
||||||
|
Object.prototype.hasOwnProperty.call(data.response.errors[0], 'code') &&
|
||||||
|
data.response.errors[0].code === 'group_not_found') {
|
||||||
|
list.children[1].style.display = 'block'
|
||||||
|
} else {
|
||||||
|
list.children[0].style.display = 'block'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,4 +12,5 @@ if (!defined('ABSPATH')) {
|
|||||||
data-time-zone="<?php echo esc_attr($timeZone); ?>"
|
data-time-zone="<?php echo esc_attr($timeZone); ?>"
|
||||||
<?php echo $isShortOffsetNameShown ? 'data-is-short-offset-name-shown' : ''; ?>>
|
<?php echo $isShortOffsetNameShown ? 'data-is-short-offset-name-shown' : ''; ?>>
|
||||||
<li style="display: none;"><?php esc_html_e('The events could not be loaded!', 'connector-mobilizon'); ?></li>
|
<li style="display: none;"><?php esc_html_e('The events could not be loaded!', 'connector-mobilizon'); ?></li>
|
||||||
|
<li style="display: none;"><?php esc_html_e('The group could not be found!', 'connector-mobilizon'); ?></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user