Skip to content

Commit 27fafde

Browse files
authored
feat: Updating reporter panel's default width to match new designs (#20231)
* feat: Updating default reporter width to 450px * Updating component tests to account for new default panel 2 width * Giving the cypress-in-cypress tests a little more room to breath * Updating trigger test coordinate assertions to be have consistent results regardless of AUT scaling * Updating scale assertion now that available width has changed
1 parent 2997e0e commit 27fafde

File tree

6 files changed

+48
-23
lines changed

6 files changed

+48
-23
lines changed

packages/app/cypress/e2e/cypress-in-cypress-component.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import defaultMessages from '@packages/frontend-shared/src/locales/en-US.json'
22
import { snapshotAUTPanel } from './support/snapshot-aut-panel'
33

4-
describe('Cypress In Cypress', { viewportWidth: 1200 }, () => {
4+
describe('Cypress In Cypress', { viewportWidth: 1500 }, () => {
55
beforeEach(() => {
66
cy.scaffoldProject('cypress-in-cypress')
77
cy.findBrowsers()

packages/app/cypress/e2e/cypress-in-cypress-e2e.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import defaultMessages from '@packages/frontend-shared/src/locales/en-US.json'
22
import { snapshotAUTPanel } from './support/snapshot-aut-panel'
33

4-
describe('Cypress In Cypress', { viewportWidth: 1200 }, () => {
4+
describe('Cypress In Cypress', { viewportWidth: 1500 }, () => {
55
beforeEach(() => {
66
cy.scaffoldProject('cypress-in-cypress')
77
cy.findBrowsers()

packages/app/cypress/e2e/cypress-in-cypress-run-mode.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Cypress In Cypress - run mode', { viewportWidth: 1200 }, () => {
1818

1919
// confirm expected content is rendered
2020
cy.contains('1000x660').should('be.visible')
21-
cy.contains('84%').should('be.visible')
21+
cy.contains('71%').should('be.visible')
2222
cy.contains('Chrome 1').should('be.visible')
2323
cy.contains('http://localhost:4455/cypress/e2e/dom-content.html').should('be.visible')
2424

packages/app/src/runner/ResizablePanels.cy.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ describe('<ResizablePanels />', { viewportWidth: 1500, defaultCommandTimeout: 40
6868
assertWidth('panel1', minPanel1Width)
6969

7070
// drag panel 1 to the maximum space available and attempt to go above it
71-
dragHandleToClientX('panel1', 680)
72-
dragHandleToClientX('panel1', 691)
73-
assertWidth('panel1', 680)
71+
dragHandleToClientX('panel1', 550)
72+
dragHandleToClientX('panel1', 561)
73+
assertWidth('panel1', 550)
7474
dragHandleToClientX('panel1', 700)
75-
assertWidth('panel1', 680)
75+
assertWidth('panel1', 550)
7676

7777
// panel 2 was not reduced
7878
assertWidth('panel2', defaultPanel2Width)
@@ -163,9 +163,10 @@ describe('<ResizablePanels />', { viewportWidth: 1500, defaultCommandTimeout: 40
163163

164164
cy.contains('panel2').should('not.be.visible')
165165
assertWidth('panel1', defaultPanel1Width)
166-
dragHandleToClientX('panel1', 1000)
167-
assertWidth('panel1', 1000)
168-
assertWidth('panel3', 500)
166+
dragHandleToClientX('panel1', 950)
167+
dragHandleToClientX('panel1', 955)
168+
assertWidth('panel1', 950)
169+
assertWidth('panel3', 550)
169170
})
170171

171172
it('Panel 3 resizes correctly when both panels are hidden', () => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export const runnerConstants = {
22
defaultSpecListWidth: 280,
3-
defaultReporterWidth: 320,
3+
defaultReporterWidth: 450,
44
}

packages/driver/cypress/e2e/commands/actions/trigger.cy.js

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -782,11 +782,15 @@ describe('src/cy/commands/actions/trigger', () => {
782782

783783
describe('position argument', () => {
784784
it('can trigger event on center by default', (done) => {
785-
const $button = cy.$$('<button />').css({ width: 200, height: 100 }).prependTo(cy.$$('body'))
785+
const height = 100
786+
const $button = cy.$$('<button />').css({ width: 200, height }).prependTo(cy.$$('body'))
786787

787788
const onMouseover = function (e) {
788789
expect(e.clientX).to.equal(108)
789-
expect(e.clientY).to.equal(50)
790+
791+
// NOTE: in firefox, the element's top value can vary depending on how the AUT is scaled.
792+
// So we factor the top value into our assertion in a manner similar to the coordinate calculations.
793+
expect(e.clientY).to.equal((height / 2) + Math.floor(e.target.getBoundingClientRect().top))
790794

791795
done()
792796
}
@@ -797,25 +801,30 @@ describe('src/cy/commands/actions/trigger', () => {
797801
})
798802

799803
it('can trigger event on center', (done) => {
800-
const $button = cy.$$('<button />').css({ width: 200, height: 100 }).prependTo(cy.$$('body'))
804+
const height = 100
805+
const $button = cy.$$('<button />').css({ width: 200, height }).prependTo(cy.$$('body'))
801806

802807
const onMouseover = function (e) {
803808
expect(e.clientX).to.equal(108)
804-
expect(e.clientY).to.equal(50)
809+
810+
// NOTE: in firefox, the element's top value varies depending on how the AUT is scaled. So we factor
811+
// the top value into our assertion in a manner similar to the coordinate calculations.
812+
expect(e.clientY).to.equal((height / 2) + Math.floor(e.target.getBoundingClientRect().top))
805813

806814
done()
807815
}
808816

809817
$button.on('mouseover', onMouseover)
810-
811818
cy.get('button:first').trigger('mouseover', 'center')
812819
})
813820

814821
it('can trigger event on topLeft', (done) => {
815822
const $button = cy.$$('<button />').css({ width: 200, height: 100 }).prependTo(cy.$$('body'))
816823
const onMouseover = function (e) {
817824
expect(e.clientX).to.equal(8)
818-
// NOTE: firefox leaves 1px on top of element on scroll, so add top offset
825+
826+
// NOTE: in firefox, the element's top value varies depending on how the AUT is scaled. So we factor
827+
// the top value into our assertion in a manner similar to the coordinate calculations.
819828
expect(e.clientY).to.equal(0 + Math.ceil(e.target.getBoundingClientRect().top))
820829

821830
done()
@@ -831,6 +840,9 @@ describe('src/cy/commands/actions/trigger', () => {
831840

832841
const onMouseover = function (e) {
833842
expect(e.clientX).to.equal(207)
843+
844+
// NOTE: in firefox, the element's top value varies depending on how the AUT is scaled. So we factor
845+
// the top value into our assertion in a manner similar to the coordinate calculations.
834846
expect(e.clientY).to.equal(0 + Math.ceil(e.target.getBoundingClientRect().top))
835847

836848
done()
@@ -842,11 +854,15 @@ describe('src/cy/commands/actions/trigger', () => {
842854
})
843855

844856
it('can trigger event on bottomLeft', (done) => {
845-
const $button = cy.$$('<button />').css({ width: 200, height: 100 }).prependTo(cy.$$('body'))
857+
const height = 100
858+
const $button = cy.$$('<button />').css({ width: 200, height }).prependTo(cy.$$('body'))
846859

847860
const onMouseover = function (e) {
848861
expect(e.clientX).to.equal(8)
849-
expect(e.clientY).to.equal(99)
862+
863+
// NOTE: in firefox, the element's top value varies depending on how the AUT is scaled. So we factor
864+
// the top value into our assertion in a manner similar to the coordinate calculations.
865+
expect(e.clientY).to.equal(height + (Math.floor(e.target.getBoundingClientRect().top) - 1))
850866

851867
done()
852868
}
@@ -857,11 +873,15 @@ describe('src/cy/commands/actions/trigger', () => {
857873
})
858874

859875
it('can trigger event on bottomRight', (done) => {
860-
const $button = cy.$$('<button />').css({ width: 200, height: 100 }).prependTo(cy.$$('body'))
876+
const height = 100
877+
const $button = cy.$$('<button />').css({ width: 200, height }).prependTo(cy.$$('body'))
861878

862879
const onMouseover = function (e) {
863880
expect(e.clientX).to.equal(207)
864-
expect(e.clientY).to.equal(99)
881+
882+
// NOTE: in firefox, the element's top value varies depending on how the AUT is scaled. So we factor
883+
// the top value into our assertion in a manner similar to the coordinate calculations.
884+
expect(e.clientY).to.equal(height + (Math.floor(e.target.getBoundingClientRect().top) - 1))
865885

866886
done()
867887
}
@@ -872,11 +892,15 @@ describe('src/cy/commands/actions/trigger', () => {
872892
})
873893

874894
it('can pass options along with position', (done) => {
875-
const $button = cy.$$('<button />').css({ width: 200, height: 100 }).prependTo(cy.$$('body'))
895+
const height = 100
896+
const $button = cy.$$('<button />').css({ width: 200, height }).prependTo(cy.$$('body'))
876897

877898
const onMouseover = function (e) {
878899
expect(e.clientX).to.equal(207)
879-
expect(e.clientY).to.equal(99)
900+
901+
// NOTE: in firefox, the element's top value varies depending on how the AUT is scaled. So we factor
902+
// the top value into our assertion in a manner similar to the coordinate calculations.
903+
expect(e.clientY).to.equal(height + (Math.floor(e.target.getBoundingClientRect().top) - 1))
880904

881905
done()
882906
}

0 commit comments

Comments
 (0)