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

chore(testkit): add playwright test drivers #2561

Merged
merged 25 commits into from
Oct 30, 2024
Merged

chore(testkit): add playwright test drivers #2561

merged 25 commits into from
Oct 30, 2024

Conversation

uziab
Copy link
Contributor

@uziab uziab commented Oct 27, 2024

This PR adds playwright drivers to vibe as a separate package. The playwright drivers mimic vibe components functionality by using playwright test. This would allow developers to import vibe based page object modules directly to their e2e projects.

@uziab uziab requested a review from talkor October 27, 2024 07:38
@uziab uziab requested a review from a team as a code owner October 27, 2024 07:38
Copy link
Member

@talkor talkor left a comment

Choose a reason for hiding this comment

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

Amazing work!! 🧪 This will be incredibly useful

packages/testing-kit/README.md Outdated Show resolved Hide resolved
packages/testing-kit/package.json Outdated Show resolved Hide resolved
packages/testing-kit/package.json Outdated Show resolved Hide resolved
packages/testing-kit/package.json Outdated Show resolved Hide resolved
packages/testing-kit/package.json Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

Do you find this separation to categories helpful? Because we keep the components folder structure flat. I don't mind having this structure, just wondering what's the benefits

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we made the separation as in core/.storybook/preview.tsx, I think it would be easier to import drivers if they are categorized by types. If you think otherwise i don't mind changing it.

Copy link
Member

Choose a reason for hiding this comment

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

Got it, sounds legit

packages/testing-kit/package.json Outdated Show resolved Hide resolved
actionTimeout: 30000,
bypassCSP: true,
launchOptions: {
args: ["--disable-web-security"]
Copy link
Member

Choose a reason for hiding this comment

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

Is this safe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes it's a launch argument in chrome that prevents same-origin policy issues. We probably do not need it at this point but I added it just in case our tests would need additional navigations in the future. For example if we run both core and style and need to navigate in between them.

import { test, expect } from '@playwright/test';
import { Button } from '../buttons/Button'; // Assuming you have this Button class

test('should fire a click event and log to console', async ({ page }) => {
Copy link
Member

Choose a reason for hiding this comment

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

Do these test rely on the core package? I thought it's suppose to be the other way around, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we need to run storybook in core to run these tests. Playwright can start storybook by itself and run the tests.

packages/testing-kit/src/inputs/DropDown.ts Outdated Show resolved Hide resolved
@uziab uziab requested a review from talkor October 29, 2024 09:08
Copy link
Member

@talkor talkor left a comment

Choose a reason for hiding this comment

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

This is fantastic 🤩

.github/workflows/test.yml Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
packages/testkit/README.md Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

Got it, sounds legit

let textfieldLocator

test.beforeEach(async ({ page }) => {
await page.goto("/?path=/story/inputs-textfield--overview");
Copy link
Member

Choose a reason for hiding this comment

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

Is there a better way to handle it? If the paths will change it will break tests

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 moved the paths to a separate file it would make it easier to maintain that way but I don't see anyway we could avoid breaking tests if paths change because it purely depends on core.

packages/testkit/tsconfig.json Show resolved Hide resolved
@talkor talkor changed the title Add playwright test drivers chore(testkit): add playwright test drivers Oct 30, 2024
@talkor talkor merged commit 574a339 into master Oct 30, 2024
8 of 9 checks passed
@talkor talkor deleted the playwright-drivers branch October 30, 2024 16:40
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.

3 participants