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

Update waiting condition for full page screenshots #362

Merged
merged 4 commits into from
Aug 22, 2022

Conversation

spinillos
Copy link
Member

The condition that we are using for individual panels isn't working for full page screenshots.

panelsRendered value is increased every time a panel is rendered. But a panel could be renderer several times when scrolling. For example, when a panel is partially visible increases panelsRendered, and when scroll, it increases this value again.

So (window as any).panelsRendered >= panelCount could be success even if we have any panel loading data. If we have a slow query, the result could be a screenshot with a loading panel, when we are expecting to see data.

The condition for full pages is the following:

  • Count [data-panelId] as total panels of the dashboard (rendered or not). It includes rows and panels.
  • .dashboard-row returns the number of rows.
  • .panel-content returns the value of RENDERED panels excluding rows (rows don't have this class).

So the condition is going to wait to all panels to render OR reach the timeout.

Copy link
Contributor

@ArturWierzbicki ArturWierzbicki left a comment

Choose a reason for hiding this comment

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

🚀

(isFullPage) => {
if (isFullPage) {
const panelCount = document.querySelectorAll('[data-panelId]').length;
const totalPanelsRendered = document.querySelectorAll('.panel-content').length + document.querySelectorAll('.dashboard-row').length;
Copy link
Contributor

@ArturWierzbicki ArturWierzbicki Aug 17, 2022

Choose a reason for hiding this comment

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

its probably worth adding a comment what .panel-content refers to (ie. when exactly does a component with panel-content class show up), and why do we add the .dashboard-row

return page.waitForFunction(
() => {
(isFullPage) => {
if (isFullPage) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add a comment explaining why full page screenshots require a different waiting logic?

@spinillos spinillos merged commit 3905b1b into master Aug 22, 2022
@spinillos spinillos deleted the update-waiting-condition-screenshots branch August 22, 2022 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants