Repository navigation
fix(web): ratings show as stars with a short count, without the extra words #1534
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0bc001d
fix(web): ratings show as stars with a short count, without the extra…
JOY 56732eb
fix(web): star messages reach client pages and compare exports keep t…
JOY be54f1e
fix(web): a long star rating wraps inside narrow score boxes
JOY fe6d1c2
fix(web): the compare diff filter reads the lab score as the screen s…
JOY 26d6965
fix(web): empty star ratings and thin-data scores meet contrast
JOY d799803
Merge remote-tracking branch 'origin/dev' into fix/1528-star-ratings
JOY File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
|
|
||
| // Ratings show as stars with the value and a short count, with no verbose | ||
| // words around them (DOS/Rate#1528). | ||
| const PRODUCT = '/smartphones/iphone-16-pro-max-256gb'; | ||
|
|
||
| test('the product scoreboard shows the buyer score as stars with a count', async ({ | ||
| page, | ||
| }) => { | ||
| await page.setViewportSize({ width: 1280, height: 900 }); | ||
| expect((await page.goto(PRODUCT))?.status()).toBe(200); | ||
|
|
||
| const score = page.getByTestId('pdv-user-score'); | ||
| await expect(score).toBeVisible(); | ||
| await expect(score).toHaveAttribute('role', 'img'); | ||
| // "4.6 trên 5 sao, 6 đánh giá": one label for screen readers. | ||
| await expect(score).toHaveAttribute( | ||
| 'aria-label', | ||
| /^\d\.\d trên 5 sao, [\d.]+ đánh giá$/ | ||
| ); | ||
| await expect(score.locator('.rate-stars-value')).toHaveText(/^\d\.\d$/); | ||
| await expect(score.locator('.rate-stars-count')).toHaveText(/^\([\d.]+\)$/); | ||
| // The band colour follows the printed value. | ||
| const value = Number(await score.getAttribute('data-rating')); | ||
| const band = value >= 4 ? 'is-good' : value >= 3 ? 'is-fair' : 'is-poor'; | ||
| await expect(score).toHaveClass(new RegExp(`\\b${band}\\b`)); | ||
| // The fill is the share of five stars. | ||
| const fill = await score | ||
| .locator('.rate-stars-fill') | ||
| .evaluate((el) => (el as HTMLElement).style.width); | ||
| expect(Number.parseFloat(fill)).toBeCloseTo((value / 5) * 100, 5); | ||
|
|
||
| const text = await page.locator('main, body').first().innerText(); | ||
| for (const phrase of [ | ||
| 'bài kiểm chứng', | ||
| 'chuẩn 10 nhóm', | ||
| '(có trọng số)', | ||
| '/ 5.0', | ||
| '(Bayes)', | ||
| ]) { | ||
| expect(text, phrase).not.toContain(phrase); | ||
| } | ||
| }); | ||
|
|
||
| test('product cards and the leaderboard use the same stars', async ({ | ||
| page, | ||
| }) => { | ||
| expect((await page.goto('/smartphones'))?.status()).toBe(200); | ||
| await expect( | ||
| page.locator('.rate-product-card .rate-stars').first() | ||
| ).toBeVisible(); | ||
| expect((await page.goto('/leaderboard'))?.status()).toBe(200); | ||
| await expect(page.locator('.rate-stars[role="img"]').first()).toBeVisible(); | ||
| const text = await page.locator('body').innerText(); | ||
| expect(text).not.toContain('/5.0'); | ||
| expect(text).not.toContain('/ 5.0'); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: DOS/Rate
Length of output: 8989
Script executed:
Repository: DOS/Rate
Length of output: 3012
Script executed:
Repository: DOS/Rate
Length of output: 11251
Wait for a rated
.rate-starselement, not any.rate-starselement..rate-starsalso matches the empty state ofStarRating. This assertion passes when the seeded product has no buyer score. Exclude the empty state so the wait ends only after the score renders.Suggested fix
Committable suggestion