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

Wait for marker_unique_id.html E2E test to render before taking a screenshot #4847

Conversation

aloisklink
Copy link
Member

📑 Summary

Sometimes, Cypress takes the screenshot for cypress/platform/marker_unique_id.html early, before mermaid has finished rendering the diagrams. This results in the following error when running pnpm run e2e:

  Running:  marker_unique_id.spec.js                                                        (1 of 1)


  Marker Unique IDs Per Diagram
    1) should render a blue arrow tip in second digram


  0 passing (4s)
  1 failing

  1) Marker Unique IDs Per Diagram
       should render a blue arrow tip in second digram:
     Error: Image size (1000x688) different than saved snapshot size (1000x854).
See diff for details: /mermaid/cypress/snapshots/marker_unique_id.spec.js/__diff_output__/Marker-Unique-IDs-Per-Diagram-should-render-a-blue-arrow-tip-in-second-digram.diff.png
      at Context.eval (webpack:///./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/cypress-image-snapshot/command.js:51:0)

Marker-Unique-IDs-Per-Diagram-should-render-a-blue-arrow-tip-in-second-digram diff

Fixes: 924c9e9 and bceae92 (from PR #4825)

📏 Design Decision

Instead of taking a screenshot instantly, I've told Cypress to wait until it can see 4 SVGs on the given HTML page.

Because this is just a test change, I've labelled this PR as Skip changelog, since there's no point in putting it in the release notes.

Requesting a review from @sidharthv96, as they helped write these Cypress E2E tests a few days ago in #4825 😄.

📋 Tasks

Make sure you

@aloisklink aloisklink added the Skip changelog Don't include in the changelog label Sep 16, 2023
@netlify
Copy link

netlify bot commented Sep 16, 2023

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 335ba40
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/650738db66a4ec0008bfd21e
😎 Deploy Preview https://deploy-preview-4847--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@aloisklink aloisklink changed the title Wait for marker_unique_id.html E2E test to rendering before taking a screenshot Wait for marker_unique_id.html E2E test to render before taking a screenshot Sep 16, 2023
@codecov
Copy link

codecov bot commented Sep 16, 2023

Codecov Report

Merging #4847 (335ba40) into develop (4201e47) will decrease coverage by 0.84%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4847      +/-   ##
===========================================
- Coverage    80.55%   79.71%   -0.84%     
===========================================
  Files          148      148              
  Lines        13024    13024              
  Branches       612      612              
===========================================
- Hits         10491    10382     -109     
- Misses        2400     2509     +109     
  Partials       133      133              
Flag Coverage Δ
e2e 84.75% <ø> (-1.04%) ⬇️
unit 43.67% <ø> (ø)

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

see 11 files with indirect coverage changes

Copy link
Member

@sidharthv96 sidharthv96 left a comment

Choose a reason for hiding this comment

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

<script type="module">
      import mermaid from './mermaid.esm.mjs';
-      mermaid.initialize({ startOnLoad: true, logLevel: 0 });
+      mermaid.initialize({ startOnLoad: false, logLevel: 0 });
+      await mermaid.run();
      if (window.Cypress) {
        window.rendered = true;
      }
</script>

Changing this in the HTML might be the better way, as the window.rendered exists to make sure the rendering has completed.

Sometimes, Cypress takes the screenshot for marker_unique_id.html early,
before mermaid has finished rendering the diagrams.

Fixes: 924c9e9

Co-authored-by: Sidharth Vinod <[email protected]>
@aloisklink aloisklink force-pushed the test/wait-for-4825-e2e-test-to-finish branch from df216f7 to 335ba40 Compare September 17, 2023 17:35
@aloisklink
Copy link
Member Author

Changing this in the HTML might be the better way, as the window.rendered exists to make sure the rendering has completed.

Yep! That works just as well :)

I thought you might have had a reason for doing startOnLoad: true, so I didn't want to change it, but changing it is the easiest way of doing things.

@sidharthv96 sidharthv96 added this pull request to the merge queue Sep 19, 2023
Merged via the queue into mermaid-js:develop with commit d6f1c11 Sep 19, 2023
17 checks passed
@aloisklink aloisklink deleted the test/wait-for-4825-e2e-test-to-finish branch September 19, 2023 11:26
fuxingloh referenced this pull request in fuxingloh/contented Nov 3, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [mermaid](https://togithub.com/mermaid-js/mermaid) | [`10.5.1` ->
`10.6.0`](https://renovatebot.com/diffs/npm/mermaid/10.5.1/10.6.0) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/mermaid/10.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/mermaid/10.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/mermaid/10.5.1/10.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/mermaid/10.5.1/10.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>mermaid-js/mermaid (mermaid)</summary>

###
[`v10.6.0`](https://togithub.com/mermaid-js/mermaid/releases/tag/v10.6.0):
10.6.0

[Compare
Source](https://togithub.com/mermaid-js/mermaid/compare/v10.5.1...v10.6.0)

#### What's Changed

- Add new chart xychart by
[@&#8203;subhash-halder](https://togithub.com/subhash-halder) in
[https://github.com/mermaid-js/mermaid/pull/4413](https://togithub.com/mermaid-js/mermaid/pull/4413)

#### Fix

- bug/4849\_center_axis_labels by
[@&#8203;dreathed](https://togithub.com/dreathed) in
[https://github.com/mermaid-js/mermaid/pull/4860](https://togithub.com/mermaid-js/mermaid/pull/4860)
- Better handling of large flowcharts and long edges
[@&#8203;knsv](https://togithub.com/knsv)

#### Docs

- Add new Atlassian integrations by
[@&#8203;janjonas](https://togithub.com/janjonas) in
[https://github.com/mermaid-js/mermaid/pull/4862](https://togithub.com/mermaid-js/mermaid/pull/4862)
- docs: fix typo by
[@&#8203;dennis0324](https://togithub.com/dennis0324) in
[https://github.com/mermaid-js/mermaid/pull/4887](https://togithub.com/mermaid-js/mermaid/pull/4887)
- Update notes on orientation in GitGraph documentation by
[@&#8203;guypursey](https://togithub.com/guypursey) in
[https://github.com/mermaid-js/mermaid/pull/4897](https://togithub.com/mermaid-js/mermaid/pull/4897)
- Enhancment: twitter logo in doc by
[@&#8203;chaursiyasanjeet](https://togithub.com/chaursiyasanjeet) in
[https://github.com/mermaid-js/mermaid/pull/4925](https://togithub.com/mermaid-js/mermaid/pull/4925)
- Update link for the Mermaid integration in JetBrains IDEs by
[@&#8203;FirstTimeInForever](https://togithub.com/FirstTimeInForever) in
[https://github.com/mermaid-js/mermaid/pull/4883](https://togithub.com/mermaid-js/mermaid/pull/4883)

#### Chores

- Wait for `marker_unique_id.html` E2E test to render before taking a
screenshot by [@&#8203;aloi](https://togithub.com/aloi)

sklink[https://github.com/mermaid-js/mermaid/pull/4847](https://togithub.com/mermaid-js/mermaid/pull/4847)4847
- Wait for `theme-directives.html` E2E test to render before taking a
screenshot by [@&#8203;aloisklink](https://togithub.com/aloisklink) in
[https://github.com/mermaid-js/mermaid/pull/4846](https://togithub.com/mermaid-js/mermaid/pull/4846)
- chore(deps): update all patch dependencies (patch) by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/mermaid-js/mermaid/pull/4851](https://togithub.com/mermaid-js/mermaid/pull/4851)
- chore(dev-deps): update `@typescript-eslint/*` plugins to v6 (major)
by [@&#8203;aloisklink](https://togithub.com/aloisklink) in
[https://github.com/mermaid-js/mermaid/pull/4857](https://togithub.com/mermaid-js/mermaid/pull/4857)
- chore: shorten `flow-huge.spec.js` test case using `.repeat` by
[@&#8203;Yokozuna59](https://togithub.com/Yokozuna59) in
[https://github.com/mermaid-js/mermaid/pull/4859](https://togithub.com/mermaid-js/mermaid/pull/4859)
- Publish Live Editor previews for the `develop` & `next` branches by
[@&#8203;sidharthv96](https://togithub.com/sidharthv96) in
[https://github.com/mermaid-js/mermaid/pull/4841](https://togithub.com/mermaid-js/mermaid/pull/4841)
- chore(deps): update all minor dependencies (minor) by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/mermaid-js/mermaid/pull/4870](https://togithub.com/mermaid-js/mermaid/pull/4870)
- chore(deps): update all patch dependencies (patch) by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/mermaid-js/mermaid/pull/4869](https://togithub.com/mermaid-js/mermaid/pull/4869)
- Commented out broken test by
[@&#8203;nirname](https://togithub.com/nirname) in
[https://github.com/mermaid-js/mermaid/pull/4913](https://togithub.com/mermaid-js/mermaid/pull/4913)
- chore(deps): update all patch dependencies (patch) by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/mermaid-js/mermaid/pull/4891](https://togithub.com/mermaid-js/mermaid/pull/4891)
- fix(class): avoid duplicate definition of fill by
[@&#8203;Mister-Hope](https://togithub.com/Mister-Hope) in
[https://github.com/mermaid-js/mermaid/pull/4929](https://togithub.com/mermaid-js/mermaid/pull/4929)
- chore(deps): update all minor dependencies (minor) by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/mermaid-js/mermaid/pull/4892](https://togithub.com/mermaid-js/mermaid/pull/4892)
- making consitent config imports from diagramAPI by
[@&#8203;dreathed](https://togithub.com/dreathed) in
[https://github.com/mermaid-js/mermaid/pull/4889](https://togithub.com/mermaid-js/mermaid/pull/4889)
- fix(typos): Fix minor typos in the source code by
[@&#8203;mribeirodantas](https://togithub.com/mribeirodantas) in
[https://github.com/mermaid-js/mermaid/pull/4928](https://togithub.com/mermaid-js/mermaid/pull/4928)
- chore(deps): update all patch dependencies (patch) by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/mermaid-js/mermaid/pull/4945](https://togithub.com/mermaid-js/mermaid/pull/4945)
- Bump [@&#8203;babel/traverse](https://togithub.com/babel/traverse)
from 7.22.10 to 7.23.2 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/mermaid-js/mermaid/pull/4951](https://togithub.com/mermaid-js/mermaid/pull/4951)
- Replace rehype-mermaidjs with rehype-mermaid by
[@&#8203;remcohaszing](https://togithub.com/remcohaszing) in
[https://github.com/mermaid-js/mermaid/pull/4970](https://togithub.com/mermaid-js/mermaid/pull/4970)

#### New Contributors

- [@&#8203;dreathed](https://togithub.com/dreathed) made their first
contribution in
[https://github.com/mermaid-js/mermaid/pull/4860](https://togithub.com/mermaid-js/mermaid/pull/4860)
- [@&#8203;janjonas](https://togithub.com/janjonas) made their first
contribution in
[https://github.com/mermaid-js/mermaid/pull/4862](https://togithub.com/mermaid-js/mermaid/pull/4862)
- [@&#8203;dennis0324](https://togithub.com/dennis0324) made their first
contribution in
[https://github.com/mermaid-js/mermaid/pull/4887](https://togithub.com/mermaid-js/mermaid/pull/4887)
- [@&#8203;FirstTimeInForever](https://togithub.com/FirstTimeInForever)
made their first contribution in
[https://github.com/mermaid-js/mermaid/pull/4883](https://togithub.com/mermaid-js/mermaid/pull/4883)
- [@&#8203;guypursey](https://togithub.com/guypursey) made their first
contribution in
[https://github.com/mermaid-js/mermaid/pull/4897](https://togithub.com/mermaid-js/mermaid/pull/4897)
- [@&#8203;chaursiyasanjeet](https://togithub.com/chaursiyasanjeet) made
their first contribution in
[https://github.com/mermaid-js/mermaid/pull/4925](https://togithub.com/mermaid-js/mermaid/pull/4925)
- [@&#8203;mribeirodantas](https://togithub.com/mribeirodantas) made
their first contribution in
[https://github.com/mermaid-js/mermaid/pull/4928](https://togithub.com/mermaid-js/mermaid/pull/4928)

**Full Changelog**:
mermaid-js/mermaid@v10.5.1...v10.6.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/levaintech/contented).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMS41IiwidXBkYXRlZEluVmVyIjoiMzcuMzEuNSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip changelog Don't include in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants