webdriverio-community / wdio-html-reporter

Fork of wdio-html-format-reporter
MIT License
18 stars 27 forks source link

Only first test error is expandable #67

Closed mikrivorot closed 2 years ago

mikrivorot commented 2 years ago

Issue

Only first error stack is expandable, can't expand all next error stacks: image

The problems is in master-report.html - in generated file click event is attached only to first element with class expandable-control

...
        let expandable = document.querySelector('.expandable-control');
        if (expandable) {
            expandable.addEventListener('click', event => {
                event.currentTarget.querySelector('span').classList.toggle('glyphicon-chevron-down');
                event.currentTarget.querySelector('span').classList.toggle('glyphicon-chevron-up');
                let panel = event.currentTarget.nextElementSibling.querySelector('.pre.stack.panel');
                slideToggle(panel, 100);
            });
        }
...

Repo to reproduce the issue: https://github.com/mikrivorot/wdio-html-reporter-error

Suggestion Generate code with

        document.querySelectorAll('.expandable-control').forEach(item => {
            item.addEventListener('click', event => {
                event.currentTarget.querySelector('span').classList.toggle('glyphicon-chevron-down');
                event.currentTarget.querySelector('span').classList.toggle('glyphicon-chevron-up');
                let panel = event.currentTarget.nextElementSibling.querySelector('.pre.stack.panel');
                slideToggle(panel, 100);
            });
        });

instead of

        let expandable = document.querySelector('.expandable-control');
        if (expandable) {
            expandable.addEventListener('click', event => {
                event.currentTarget.querySelector('span').classList.toggle('glyphicon-chevron-down');
                event.currentTarget.querySelector('span').classList.toggle('glyphicon-chevron-up');
                let panel = event.currentTarget.nextElementSibling.querySelector('.pre.stack.panel');
                slideToggle(panel, 100);
            });
        }

here: https://github.com/rpii/wdio-html-reporter/blob/d1f277e6851afb8a70e8d4ebe4bd641670df1a5f/templates/report.html#L324

rpii commented 2 years ago

Yes please do. thanks for the excellent analysis

On Mon, Sep 6, 2021 at 4:13 AM Margarita Krivorot @.***> wrote:

Is it possible to fork the repo and propose code changes in a PR?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rpii/wdio-html-reporter/issues/67#issuecomment-913564424, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEABIEMBGWYJ26XAEWWQZXDUASOZRANCNFSM5DQBKSTA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

mikrivorot commented 2 years ago

Solution proposed in https://github.com/rpii/wdio-html-reporter/pull/68

rpii commented 2 years ago

pull request completed