Skip to content

Commit

Permalink
Fix/ci unit test issue (#700)
Browse files Browse the repository at this point in the history
* test: prevent issue on CI

* test: debug on CI

* docs: comment fix

* fix: prevent issue on CI
  • Loading branch information
fterra-encora authored Dec 29, 2023
1 parent baaf1c9 commit 74edd3c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions frontend/src/composables/useFocus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,24 @@ export const useFocus = (): {
): Ref<OptionalElement> => {
const refComponent = ref<OptionalElement>(undefined)
setTimeout(() => {
if (!document) {
// Prevent error on CI
return;
}
refComponent.value = setActionOn(componentName, key, action)
if (callback) {
// We need to detect the end of the scrolling
// Use event 'scroll' if browser does not support 'scrollend'
const eventName = 'onscrollend' in window ? 'scrollend' : 'scroll'

const scrollEndListener = () => {
callback(refComponent)
document.removeEventListener(eventName, polyfilledListener)
}
callback(refComponent);
if (!document) {
// Prevent error on CI
return;
}
document.removeEventListener(eventName, polyfilledListener);
};

let scrollEndTimer: NodeJS.Timeout

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ describe("<ContactGroupComponent />", () => {
});

// Debugging issue on CI.
cy.window().then((value) => cy.task("log", `window: ${value}`));
cy.document().then((value) => cy.task("log", `document: ${value}`));
cy.get("#firstName_1");

cy.focused().should("have.id", "firstName_1");
Expand Down

0 comments on commit 74edd3c

Please sign in to comment.