Skip to content

Conversation

@OS-pedrolourenco
Copy link
Contributor

Issue number: internal


What is the current behavior?

This PR is a follow-up of this one: #30117

What is the new behavior?

  • This PR adds a snapshot test and modifies the existing one in order to test the change done in the previous PR.

Does this introduce a breaking change?

  • Yes
  • No

Other information

@vercel
Copy link

vercel bot commented Jan 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ionic-framework ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2025 3:56pm

@github-actions github-actions bot added the package: core @ionic/core package label Jan 14, 2025
@OS-pedrolourenco OS-pedrolourenco marked this pull request as ready for review January 14, 2025 20:04
@OS-pedrolourenco OS-pedrolourenco requested a review from a team as a code owner January 14, 2025 20:04
Copy link
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

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

The PR also needs:

  • a test test, not feat, since you're adding a test
  • not be redundant, the component is already mentioned in the scope so no need to mention it again. The same goes for the type.

test(tab-bar): add snapshot for box shadow

Copy link
Contributor

Choose a reason for hiding this comment

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

Snapshots should always aim to be as small as possible. That's why the original test was using tabBar instead of content. Since we want to capture the box shadow, then create a container that has padding and use the container for the snapshot instead for both tests. Here's some pseudo code:

.container {
   padding: 20px 10px;
}

<ion-content>
   <div class="container">
      <ion-tab-bar>
   </div>
</ion-content>

const container = page.locator('.container');

await expect(container).toHaveScreenshot...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. The compact snapshots look a bit strange though.
By the way, I ended up not using the container in your suggestion seen as though it had no effect on the snapshots.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is because I used pseudo code as in my code is only semi complete so:

  1. Please use the proper syntax
  2. Add the suggested code to the correct locations
  3. use the container
.container {
   padding: 20px 10px;
}

<ion-content>
   <div class="container">
      <ion-tab-bar> // not complete, use proper syntax
   </div>
</ion-content>

const container = page.locator('.container');

await expect(container).toHaveScreenshot... // not complete, use proper syntax

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hope I have addressed your concern with my latest commit. The only adjustment I had to do was to manually set the container dimensions on the compact tab bar test since, with only the padding attribute set up, the container shown in the snapshot did not fit the tab bar for some reason and was hiding it instead:
image
If you have any suggestion for better working around this, please let me know.

Copy link
Contributor

Choose a reason for hiding this comment

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

I went ahead and made the appropriate changes since it seems that my comments regarding using proper syntax is not being understood well. I would highly recommend reviewing my changes since it showcases how tests should be written for Ionic. Thanks!

@OS-pedrolourenco OS-pedrolourenco changed the title feat(tab-bar): add snapshot tests to tab-bar shadow change test(tab-bar): add snapshot tests to tab-bar shadow change Jan 15, 2025
@OS-pedrolourenco OS-pedrolourenco changed the title test(tab-bar): add snapshot tests to tab-bar shadow change test(tab-bar): add snapshot for box shadow Jan 15, 2025
Copy link
Contributor

Choose a reason for hiding this comment

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

This is because I used pseudo code as in my code is only semi complete so:

  1. Please use the proper syntax
  2. Add the suggested code to the correct locations
  3. use the container
.container {
   padding: 20px 10px;
}

<ion-content>
   <div class="container">
      <ion-tab-bar> // not complete, use proper syntax
   </div>
</ion-content>

const container = page.locator('.container');

await expect(container).toHaveScreenshot... // not complete, use proper syntax

Copy link
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

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

LGTM, assigning to Brandy for a second check. Once she gives an approval, then this PR can be merged.

@thetaPC thetaPC requested a review from brandyscarney January 16, 2025 16:56
</ion-tab-button>
</ion-tab-bar>
`,
<ion-content>
Copy link
Member

Choose a reason for hiding this comment

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

We should remove ion-content as this is not needed

Copy link
Member

@brandyscarney brandyscarney left a comment

Choose a reason for hiding this comment

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

Approving with the removal of ion-content 🙂

@OS-pedrolourenco OS-pedrolourenco merged commit b3e869e into next Jan 17, 2025
47 checks passed
@OS-pedrolourenco OS-pedrolourenco deleted the ROU-11503-snapshot-tests branch January 17, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants