test: more tests on TailwindCSS configuration#74
Conversation
Summary of ChangesHello @colinaaa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly expands the test suite for the TailwindCSS plugin, ensuring proper functionality across various configuration scenarios. It introduces dedicated tests for custom plugins, CSS prefixing, and theme extensions, thereby enhancing the reliability and stability of the plugin's integration with Rsbuild. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds a good set of tests for various TailwindCSS configuration options, including plugins, prefixes, and themes. The changes also improve existing tests by ensuring elements are present before interaction. My review focuses on suggesting a more idiomatic way to write the Playwright tests using locators, which can improve readability and robustness.
| await page.waitForSelector('#test', { state: 'attached' }); | ||
|
|
||
| const style = await page.evaluate(() => { | ||
| const el = document.getElementById('test'); | ||
|
|
||
| if (!el) { | ||
| throw new Error('#test not found'); | ||
| } | ||
|
|
||
| const computed = window.getComputedStyle(el); | ||
| return { | ||
| position: computed.getPropertyValue('position'), | ||
| top: computed.getPropertyValue('top'), | ||
| }; | ||
| }); |
There was a problem hiding this comment.
For better readability and to leverage Playwright's auto-waiting mechanism, it's recommended to use page.locator() to select elements. This avoids manual waitForSelector and simplifies the code by removing the need to manually find the element and check for its existence within page.evaluate(). Using locators makes the test more robust and idiomatic.
const style = await page.locator('#test').evaluate((el) => {
const computed = window.getComputedStyle(el);
return {
position: computed.getPropertyValue('position'),
top: computed.getPropertyValue('top'),
};
});| await page.waitForSelector('#test', { state: 'attached' }); | ||
|
|
||
| const display = await page.evaluate(() => { | ||
| const el = document.getElementById('test'); | ||
|
|
||
| if (!el) { | ||
| throw new Error('#test not found'); | ||
| } | ||
|
|
||
| return window.getComputedStyle(el).getPropertyValue('display'); | ||
| }); |
There was a problem hiding this comment.
For better readability and to leverage Playwright's auto-waiting mechanism, it's recommended to use page.locator() to select elements. This avoids manual waitForSelector and simplifies the code by removing the need to manually find the element and check for its existence within page.evaluate(). Using locators makes the test more robust and idiomatic.
const display = await page
.locator('#test')
.evaluate((el) => window.getComputedStyle(el).getPropertyValue('display'));| await page.waitForSelector('#test', { state: 'attached' }); | ||
|
|
||
| const color = await page.evaluate(() => { | ||
| const el = document.getElementById('test'); | ||
|
|
||
| if (!el) { | ||
| throw new Error('#test not found'); | ||
| } | ||
|
|
||
| return window.getComputedStyle(el).getPropertyValue('color'); | ||
| }); |
There was a problem hiding this comment.
For better readability and to leverage Playwright's auto-waiting mechanism, it's recommended to use page.locator() to select elements. This avoids manual waitForSelector and simplifies the code by removing the need to manually find the element and check for its existence within page.evaluate(). Using locators makes the test more robust and idiomatic.
const color = await page
.locator('#test')
.evaluate((el) => window.getComputedStyle(el).getPropertyValue('color'));
No description provided.