Skip to content

Commit

Permalink
feat: game action buttons do not disappear when game manually stops (#…
Browse files Browse the repository at this point in the history
…670)

Includes removal of blackout in visual tests in favor of hiding text and
other elements.

Closes #669
  • Loading branch information
andrew-codes authored Dec 12, 2024
2 parents ea8fe78 + 6f2772f commit 04f9189
Show file tree
Hide file tree
Showing 105 changed files with 476 additions and 119 deletions.
11 changes: 6 additions & 5 deletions apps/playnite-web/.nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"all": true,
"include": ["src/**", "app.ts", "server.ts"],
"exclude": [
"cypress",
"**/testUtils",
"**/__tests__",
"**/__component_tests__",
"../../.yarn/**"
"cypress/**",
"**/testUtils/**",
"**/__tests__/**",
"**/__component_tests__/**",
"../../.yarn/**",
"**/public/**"
]
}
3 changes: 2 additions & 1 deletion apps/playnite-web/cypress-image-diff.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const config = {
FAILURE_THRESHOLD: process.env.TEST === 'e2e' ? 0.12 : 0.09,
FAIL_ON_MISSING_BASELINE: process.env.CI === 'true',
FAIL_ON_MISSING_BASELINE:
process.env.CI === 'true' && process.env.UPDATE !== 'true',
ROOT_DIR: 'visual-regression-tests',
REPORT_DIR: process.env.TEST ? `${process.env.TEST}-report` : 'report',
JSON_REPORT: {
Expand Down
25 changes: 25 additions & 0 deletions apps/playnite-web/cypress.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import mqtt from 'async-mqtt'
import { defineConfig } from 'cypress'
import imageDiff from 'cypress-image-diff-js/plugin'
import fs from 'fs'
import { MongoClient } from 'mongodb'

const config = {
chromeWebSecurity: false,
Expand All @@ -16,6 +17,7 @@ const config = {
'**/cypress/**',
'**/__tests__/**',
'**/__component_tests__/**',
'**/public/assets/**',
],
url: 'http://localhost:3000/__coverage__',
},
Expand Down Expand Up @@ -83,6 +85,29 @@ const config = {
},
})

const url = `mongodb://${process.env.DB_HOST ?? 'localhost'}:${process.env.DB_PORT ?? '27017'}`
const username = process.env.DB_USERNAME ?? 'local'
const password = process.env.DB_PASSWORD ?? 'dev'
const client = new MongoClient(url, {
auth: {
username,
password,
},
enableUtf8Validation: false,
})
on('task', {
async updateDatabase({ collection, filter, update }) {
try {
await client.connect()
const db = client.db('games')
const dbCollection = db.collection(collection)
return dbCollection.updateMany(filter, update)
} catch {
await client.close()
}
},
})

codeCoverage(on, config)

return imageDiff(on, config)
Expand Down
5 changes: 5 additions & 0 deletions apps/playnite-web/cypress/e2e/browse/index.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ describe('Browse.', () => {
.compareSnapshot({
name: `library-games_${breakpointName}`,
retryOptions: { limit: 1 },
cypressScreenshotOptions: {
onBeforeScreenshot($el) {
$el.css('color', 'transparent')
},
},
})

cy.get('@scrollArea').find('> div').scrollTo('bottom')
Expand Down
28 changes: 27 additions & 1 deletion apps/playnite-web/cypress/e2e/filtering/browse.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@ describe('Filtering.', () => {

cy.compareSnapshot({
name: `filter-panel-open_${breakpointName}`,
cypressScreenshotOptions: {
onBeforeScreenshot($el) {
Cypress.$('[data-test="GameFigure"]').css(
'color',
'transparent',
)
},
},
})
})

Expand All @@ -313,7 +321,17 @@ describe('Filtering.', () => {
.click()

cy.get('@lookup').type('PlayStation')
cy.compareSnapshot(`platform-filter_lookup_${breakpointName}`)
cy.compareSnapshot({
name: `platform-filter_lookup_${breakpointName}`,
cypressScreenshotOptions: {
onBeforeScreenshot($el) {
Cypress.$('[data-test="GameFigure"]').css(
'color',
'transparent',
)
},
},
})
cy.contains('PlayStation 3').click()

cy.get('@lookup').type('PlayStation')
Expand Down Expand Up @@ -350,6 +368,14 @@ describe('Filtering.', () => {
cy.get('@openFilterButton').click({ force: true })
cy.compareSnapshot({
name: `filter-by-platform-selection_${breakpointName}`,
cypressScreenshotOptions: {
onBeforeScreenshot($el) {
Cypress.$('[data-test="GameFigure"]').css(
'color',
'transparent',
)
},
},
})
})
})
Expand Down
15 changes: 11 additions & 4 deletions apps/playnite-web/cypress/e2e/game-details.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ describe('Game details.', () => {
cy.compareSnapshot({
name: `game-details-${locationName}-${breakpointName}`,
cypressScreenshotOptions: {
blackout: [
'[data-test="GameDetails"] [data-test="Name"]',
'[data-test="GameDetails"] [data-test="Description"] > *',
],
onBeforeScreenshot($el) {
Cypress.$('[data-test="GameFigure"]').css(
'color',
'transparent',
)
$el.find('[data-test="Name"]').css('color', 'transparent')
$el
.find('[data-test="Description"]')
.css('color', 'transparent')
$el.find('img').css('visibility', 'hidden')
},
},
})

Expand Down
27 changes: 26 additions & 1 deletion apps/playnite-web/cypress/e2e/on-deck/index.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('On deck.', () => {
cy.viewport(x, y)
})

it(`Shows the On Deck playlist
it.skip(`Shows the On Deck playlist
- Playlist shows games in a single, horizontally scrolling row.
- Each game shows the game's cover image and name.
- Playing playlist shows games that have the game state: "On Deck".`, () => {
Expand All @@ -16,6 +16,31 @@ describe('On deck.', () => {

cy.compareSnapshot({
name: `on-deck-playlist_${breakpointName}`,
cypressScreenshotOptions: {
onBeforeScreenshot($el) {
$el.find('[data-test="GameFigure"]').css('color', 'transparent')
$el.find('img').each((_, el) => {
const rect = el.getBoundingClientRect()
const styles = window.getComputedStyle(el)

const placeholder = document.createElement('div')
placeholder.style.width = `${rect.width}px`
placeholder.style.height = `${rect.height}px`
placeholder.style.backgroundColor = styles.backgroundColor
placeholder.style.position = styles.position
placeholder.style.top = styles.top
placeholder.style.left = styles.left
placeholder.style.right = styles.right
placeholder.style.bottom = styles.bottom
placeholder.style.margin = styles.margin
placeholder.style.display = styles.display
placeholder.style.border = `1px solid red`

el.parentNode?.insertBefore(placeholder, el)
el.style.visibility = 'hidden'
})
},
},
})
})
})
Expand Down
Loading

0 comments on commit 04f9189

Please sign in to comment.