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(playwright): add tests for editor theme selection logic #54481

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

huyenltnguyen
Copy link
Member

@huyenltnguyen huyenltnguyen commented Apr 22, 2024

Checklist:

This PR:

Note: While the theme selection logic is fairly simple, the implementation involves window.matchMedia(), which is an API that JSDOM doesn't support. It will require heavily mocking the matchMedia API if we write unit tests, while it's much simpler with e2e as Playwright supports this feature out of the box (https://playwright.dev/docs/api/class-testoptions#test-options-color-scheme).

@github-actions github-actions bot added the scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. label Apr 22, 2024
@huyenltnguyen
Copy link
Member Author

Ugh. Yet another Webkit test that only fails in CI but not local.

test.use({ colorScheme: 'dark' });

test.describe('If the user is signed in', () => {
test.use({ storageState: 'playwright/.auth/certified-user.json' });
Copy link
Member Author

Choose a reason for hiding this comment

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

We do have storageState set during the setup phase:

.storageState({ path: 'playwright/.auth/certified-user.json' });

But for some reason that doesn't have any effect, and the user is logged out, which causes some tests to fail. Setting storageState again within the test suite is the only workaround at the moment, until I can figure out what the issue is.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was confused by this too. It turns out we do setup storageState, but we we don't use it by default. So, any tests that require a signed-in user have to manually specify test.use, like you did here.

Do you think it would be more intuitive to default to using it? I'm leaning towards "yes".

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I see.

Yes, I think it makes sense to make this the default (I guess that's the purpose of the global login step, so that we don't have to log in manually).

@huyenltnguyen huyenltnguyen marked this pull request as ready for review April 26, 2024 16:51
@huyenltnguyen huyenltnguyen requested a review from a team as a code owner April 26, 2024 16:51
@Sembauke Sembauke added the status: merge conflict To be applied to PR's that have a merge conflict and need updating label May 2, 2024
@huyenltnguyen huyenltnguyen added status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. and removed status: merge conflict To be applied to PR's that have a merge conflict and need updating labels May 6, 2024
@huyenltnguyen
Copy link
Member Author

This isn't related to the PR changes, but it's weird that the Python tests failed locally for me, but passed in CI. Those tests failed on my local main, too.

Screenshot 2024-05-06 at 14 56 56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a test to make sure that editor theme is in sync with the app theme
4 participants