Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): Переносим тесты на доступность в playwright #5276

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

eugpoloz
Copy link
Contributor

@eugpoloz eugpoloz commented Jun 14, 2023

Перенастроила сборку тестов на доступность.

  • @axe-core/playwright проверяет доступность на тех же примерах, что уходят в скриншоты,
  • на базе проверки по всем закриншоченным компонентам собирается общий репорт в HTML с помощью axe-html-reporter (спасибо @inomdzhon за подсказку!),
  • дальше на CI джоба Pull Request / Packages:
    • грузит HTML-репорт в S3
    • сравнивает BASE и HEAD и количество ошибок a11y в них
    • добавляет коммент со ссылкой на репорт, количеством ошибок и статусом (доступность улучшилась/ухудшилась/осталась прежней)
    • падает, если доступность ухудшилась

Где посмотреть:

Нюансы:

axe-html-reporter

Пакет не обновлялся с 2021 года и особенно кастомизировать репорт не позволяет. Возможно, стоит написать свое красивенькое решение, основываясь на репортере playwright, и выложить его в open source. 😈

Коммент со ссылкой на репорт, количеством ошибок и статусом

Сейчас коммент собирается прямо внутри нашей Pull Request / Packages джобы. Но вообще хочу перенести как минимум его создание в gh-actions, чтобы уменьшить дубликацию кода.

@eugpoloz eugpoloz self-assigned this Jun 14, 2023
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 14, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit b3a99b7:

Sandbox Source
VKUI TypeScript Configuration

@github-actions
Copy link
Contributor

github-actions bot commented Jun 14, 2023

size-limit report 📦

Path Size
JS 347.62 KB (0%)
JS (gzip) 106.29 KB (0%)
JS (brotli) 87.81 KB (0%)
JS import Div (tree shaking) 1.43 KB (0%)
CSS 256.49 KB (0%)
CSS (gzip) 33.59 KB (0%)
CSS (brotli) 27.28 KB (0%)

@github-actions
Copy link
Contributor

github-actions bot commented Jun 14, 2023

👀 Docs deployed

Commit 433d088

@codecov
Copy link

codecov bot commented Jun 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (14fccac) 81.26% compared to head (62ce4c4) 79.58%.

❗ Current head 62ce4c4 differs from pull request most recent head b3a99b7. Consider uploading reports for the commit b3a99b7 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5276      +/-   ##
==========================================
- Coverage   81.26%   79.58%   -1.68%     
==========================================
  Files         326      312      -14     
  Lines       10108     9960     -148     
  Branches     3397     3330      -67     
==========================================
- Hits         8214     7927     -287     
- Misses       1894     2033     +139     
Flag Coverage Δ
unittests 79.58% <ø> (-1.68%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 14, 2023

e2e tests

Playwright Report

packages/vkui/src/testing/e2e/index.playwright.ts Outdated Show resolved Hide resolved
Comment on lines 96 to 89
await testInfo.attach('Accessibility Violations', {
body: JSON.stringify(results.violations, null, 2),
contentType: 'application/json',
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сейчас вот такой репорт в случае когда тест не проходит

Скриншот

export const Accordion = ({ getRootRef, className, ...restProps }: AccordionProps) => (
  <details
    aria-hidden2 // вот тут должен ругаться
    className={classNames(styles['Accordion'], className)}
    ref={getRootRef}
    {...restProps}
  />
);

Не смотрела https://github.com/lpelypenko/axe-html-reporter ? Вот тут чел пишет, что интегрировал с @axe-core/playwright. Вот такое выдаёт https://lpelypenko.github.io/axe-html-reporter/. Надо будет его к общему HTML репорту атачить.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Подтащила свеженький репорт, но артефакты в playwright-репорт тоже креплю на всякий случай.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@inomdzhon FYI вот тут коммент с собравшимся репортом-прям-репортом: #5369 (comment)

contentType: 'application/json',
});

expect(results.violations).toEqual([]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Продолжая тему про репорт, сейчас тесты должны падать при проблемах доступности? Или это должно оставаться как warning, пока не исправим всё?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это хороший вопрос, я пока думаю, как бы покрасивее показывать, сколько у нас в целом проблем доступности сейчас.

Вообще идея в том, чтобы влить в мастер число наших текущих violations и сравнивать его с числом в ветке; если в ветке violations по a11y больше, чем в мастере — валим тест.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@inomdzhon в описание добавила:

  • дальше на CI джоба Pull Request / Packages:
    • грузит HTML-репорт в S3
    • сравнивает BASE и HEAD и количество ошибок a11y в них
    • добавляет коммент со ссылкой на репорт, количеством ошибок и статусом (доступность улучшилась/ухудшилась/осталась прежней)
    • падает, если доступность ухудшилась

Ну и вот тут можно посмотреть, как визуально выглядит прошедший тест: #5369 (comment)

Как тебе такое решение? 😉

@eugpoloz eugpoloz force-pushed the eugpoloz/a11y-tests-playwright branch 2 times, most recently from e23c6a8 to 307eed3 Compare June 27, 2023 00:59
@eugpoloz eugpoloz force-pushed the eugpoloz/a11y-tests-playwright branch 3 times, most recently from 7649dad to 485cecc Compare June 27, 2023 20:23
@eugpoloz eugpoloz force-pushed the eugpoloz/a11y-tests-playwright branch 16 times, most recently from 5029846 to 2232256 Compare June 30, 2023 10:03
@eugpoloz eugpoloz force-pushed the eugpoloz/a11y-tests-playwright branch 2 times, most recently from 053ffcf to 3eb1cf6 Compare August 2, 2023 09:26
@eugpoloz eugpoloz force-pushed the eugpoloz/a11y-tests-playwright branch 2 times, most recently from e5368ea to 433d088 Compare August 2, 2023 16:50
@github-actions github-actions bot added the pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности label Aug 10, 2023
@github-actions
Copy link
Contributor

PR закрыт из-за отсутствия активности в течение последних 14 дней. Если это произошло по ошибке или изменения все ещё актуальны, откройте PR повторно.

@github-actions github-actions bot closed this Aug 18, 2023
@eugpoloz eugpoloz added no-stale Добавляет PR в исключения для автоматического закрытия and removed pr-needs-work Автоматизация: PR автоматически закроется через 14 дней при отсутствии активности labels Sep 26, 2023
@eugpoloz eugpoloz reopened this Sep 26, 2023
@eugpoloz eugpoloz marked this pull request as draft September 26, 2023 02:09
@eugpoloz eugpoloz force-pushed the eugpoloz/a11y-tests-playwright branch from 433d088 to 4f145b4 Compare November 24, 2023 17:37
Copy link
Contributor

github-actions bot commented Nov 24, 2023

👀 Docs deployed

Commit b3a99b7

@eugpoloz eugpoloz force-pushed the eugpoloz/a11y-tests-playwright branch from 4f145b4 to 62ce4c4 Compare November 24, 2023 17:55
@eugpoloz eugpoloz force-pushed the eugpoloz/a11y-tests-playwright branch from 62ce4c4 to b3a99b7 Compare January 11, 2024 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y Доступность (цифровая) no-stale Добавляет PR в исключения для автоматического закрытия
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants