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

fix: Add hover states for test titles in reporter #21635

Merged
merged 5 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ commands:
package:
description: package to target
type: enum
enum: ['frontend-shared', 'launchpad', 'app']
enum: ['frontend-shared', 'launchpad', 'app', 'reporter']
browser:
description: browser shortname to target
type: string
Expand Down Expand Up @@ -1132,6 +1132,7 @@ jobs:
run-frontend-shared-component-tests-chrome,
run-launchpad-component-tests-chrome,
run-launchpad-integration-tests-chrome,
run-reporter-component-tests-chrome,
run-webpack-dev-server-integration-tests,
run-vite-dev-server-integration-tests
- run:
Expand Down Expand Up @@ -1475,6 +1476,21 @@ jobs:
browser: electron
experimentalSessionAndOrigin: true

run-reporter-component-tests-chrome:
<<: *defaults
parameters:
<<: *defaultsParameters
percy:
type: boolean
default: false
parallelism: 7
steps:
- run-new-ui-tests:
browser: chrome
percy: << parameters.percy >>
package: reporter
type: ct

reporter-integration-tests:
<<: *defaults
parallelism: 3
Expand Down Expand Up @@ -2324,6 +2340,11 @@ linux-workflow: &linux-workflow
percy: true
requires:
- build
- run-reporter-component-tests-chrome:
context: [test-runner:cypress-record-key, test-runner:percy]
percy: true
requires:
- build
- reporter-integration-tests:
context: [test-runner:cypress-record-key, test-runner:percy]
requires:
Expand Down Expand Up @@ -2413,6 +2434,7 @@ linux-workflow: &linux-workflow
- run-frontend-shared-component-tests-chrome
- run-launchpad-component-tests-chrome
- run-launchpad-integration-tests-chrome
- run-reporter-component-tests-chrome

# various testing scenarios, like building full binary
# and testing it on a real project
Expand Down
12 changes: 12 additions & 0 deletions packages/reporter/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { defineConfig } from 'cypress'
import webpackConfig from './webpack.config.ts'

export default defineConfig({
projectId: 'ypt4pf',
reporter: '../../node_modules/cypress-multi-reporters/index.js',

reporterOptions: {
configFile: '../../mocha-reporter-config.json',
},

retries: {
runMode: 2,
openMode: 0,
},

e2e: {
baseUrl: 'http://localhost:5006',
setupNodeEvents (_on, config) {
Expand All @@ -22,4 +26,12 @@ export default defineConfig({
viewportHeight: 660,
viewportWidth: 400,
},

component: {
devServer: {
framework: 'react',
bundler: 'webpack',
webpackConfig,
},
},
})
12 changes: 12 additions & 0 deletions packages/reporter/cypress/support/component-index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Components App</title>
</head>
<body>
<div data-cy-root class="reporter" style="padding: 20px;"></div>
</body>
</html>
8 changes: 8 additions & 0 deletions packages/reporter/cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { mount } from 'cypress/react'
import 'cypress-real-events/support'
import { installCustomPercyCommand } from '@packages/ui-components/cypress/support/customPercyCommand'

import '../../src/main.scss'

Cypress.Commands.add('mount', mount)
Copy link
Contributor

Choose a reason for hiding this comment

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

You mentioned in slack there was an issue with

declare global {
  namespace Cypress {
    interface Chainable {
      mount: typeof mount
    }
  }
}

I added this and included cypress/support/component.ts in the tsconfig and everything compiled fine, plus it removed some of the ts warnings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue with that was because I wasn't using our webpack configs (and therefor everything was broken, that just being one example). I'll add the type addition back in.

installCustomPercyCommand()
24 changes: 24 additions & 0 deletions packages/reporter/src/hooks/hooks.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react'
import { Hook } from './hooks'

import '../main.scss'

describe('hooks/hooks.tsx', () => {
it('should mount', () => {
const model = {
failed: false,
hookName: 'TEST BODY',
}

cy.mount(<div className="runnable suite">
<div className="hooks-container">
<Hook model={model} showNumber={false} />
</div>
</div>)

cy.percySnapshot()

cy.contains('TEST BODY').click().realHover()
cy.percySnapshot()
})
})
4 changes: 1 addition & 3 deletions packages/reporter/src/hooks/hooks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
width: 100%;

&:hover {
.collapsible-header {
color: $gray-300;
}
background-color: $gray-900;

.hook-open-in-ide {
cursor: pointer;
Expand Down
2 changes: 1 addition & 1 deletion packages/reporter/src/runnables/runnables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

.collapsible-header-inner {
&:hover {
background-color: $gray-1000;
background-color: $gray-900;
cursor: pointer;
}

Expand Down
27 changes: 27 additions & 0 deletions packages/reporter/src/test/test.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react'
import Test from './test'

describe('test/test.tsx', () => {
it('should mount', () => {
const model = {
isOpen: false,
level: 0,
state: 'passed',
title: 'foobar',
attempts: [],
}

const appState = {
studioActive: false,
}

cy.mount(<div className="runnable suite">
<Test model={model} appState={appState} />
</div>)

cy.percySnapshot()

cy.contains('foobar').click().realHover()
cy.percySnapshot()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ElementOverrideManager {
*/
performOverrides (cy: Cypress.cy, overrides: NonNullable<CustomSnapshotOptions['elementOverrides']>) {
const observer = new MutationObserver((mutations) => {
this.mutationStack ??= []
this.mutationStack = this.mutationStack || []
this.mutationStack.push(...mutations)
})

Expand Down