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(navigation-bar): playwright refactor #6377

Merged
merged 2 commits into from
Oct 26, 2023

Conversation

ZhuoyuJin
Copy link
Contributor

@ZhuoyuJin ZhuoyuJin commented Oct 18, 2023

Proposed behaviour

Refactor Navigation Bar tests from Cypress to Playwright

Current behaviour

Tests are currently Cypress

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Cypress automation tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in CodeSandbox/storybook
  • Add new Cypress test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

N/A

Testing instructions

Testing instructions

  • Run Navigation Bar tests in Playwright Test Runner to check if the navigation-bar.pw.tsx file passed
  • Run all other tests in Playwright Test Runner to check none of the other *.pw.tsx files have regressed

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 18, 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 f8c0633:

Sandbox Source
carbon-quickstart Configuration
carbon-quickstart-typescript Configuration

@divyajindel
Copy link
Contributor

Hi @ZhuoyuJin , Navigation-bar component is missing in storybook so could you please fix that.

await expect(navigation).toBeVisible();
} else {
await expect(navigation).not.toBeAttached;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocking change, but this is a bit neater.

if (boolean) {
     await expect(navigation).not.toBeAttached;     
} else {
     await expect(navigation).toBeVisible();
}


if (position === "fixed") {
await expect(navigationBar(page).nth(0)).toBeVisible();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I might be wrong but I think the top navigation bar should not be visible if its position is set to fixed. This may be passing because toBeVisible finds elements that are not onscreen but which are in the DOM. I think toBeInViewport does what the test requires.

There should also be an else assertion to verify that the top navigation bar is visible when its position is set to sticky.

@DipperTheDan DipperTheDan self-requested a review October 23, 2023 13:52
Comment on lines 7 to 18
import {
Default,
DarkTheme,
WhiteTheme,
BlackTheme,
ExampleWithMenu,
IsLoading,
WithCustomSpacing,
ContentMaxWidthBox,
Sticky,
Fixed,
} from "../../../src/components/navigation-bar/navigation-bar.stories";
Copy link
Contributor

Choose a reason for hiding this comment

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

question(non-blocking): I thought if we were using stories/examples for Playwright tests, they had to be in the ./components.test-pw file? I could well be wrong here (and tell me if I am because it'll save me a load of time moving the examples to a different file) but that's what I've been doing 😆

@@ -120,4 +120,4 @@ top/bottom can be offset using the `offset` prop.

### Navigation Bar

Copy link
Contributor

Choose a reason for hiding this comment

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

question(non-blocking): There appears to be a change here but the two lines look the same?

@ZhuoyuJin ZhuoyuJin force-pushed the playwright_refactor_navigation_bar branch from c455d1b to 67d57d6 Compare October 25, 2023 08:16
);

test.describe("Accessibility tests for NavigationBar component", () => {
test("should pass accessibility tests Default story", async ({
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick/suggestion(non-blocking): Sorry, I should have mentioned this yesterday when I suggested moving them to the test-pw file. As these are no longer stories it should just be:

Suggested change
test("should pass accessibility tests Default story", async ({
test("should pass accessibility tests Default example", async ({

Same for the others below too. Sorry! My bad 😢

stephenogorman
stephenogorman previously approved these changes Oct 25, 2023
@ZhuoyuJin ZhuoyuJin force-pushed the playwright_refactor_navigation_bar branch 2 times, most recently from 068fb93 to 90102fa Compare October 26, 2023 08:46
DipperTheDan
DipperTheDan previously approved these changes Oct 26, 2023
stephenogorman
stephenogorman previously approved these changes Oct 26, 2023
@ZhuoyuJin ZhuoyuJin force-pushed the playwright_refactor_navigation_bar branch from 553a335 to ad423cb Compare October 26, 2023 14:15
@ZhuoyuJin ZhuoyuJin marked this pull request as ready for review October 26, 2023 14:55
@ZhuoyuJin ZhuoyuJin requested review from a team as code owners October 26, 2023 14:55
@ZhuoyuJin ZhuoyuJin merged commit c8c7bcb into master Oct 26, 2023
24 checks passed
@ZhuoyuJin ZhuoyuJin deleted the playwright_refactor_navigation_bar branch October 26, 2023 15:22
@carbonci
Copy link
Collaborator

🎉 This PR is included in version 123.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants