Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 48816c6

Browse files
Fix more Desktop GUI layout issues (cypress-io#4914)
* fix warning message layout issue * ensure footer is at bottom when project error displayed * fix warning about autoFocus
1 parent 42cbe20 commit 48816c6

File tree

7 files changed

+67
-33
lines changed

7 files changed

+67
-33
lines changed

packages/desktop-gui/cypress/integration/error_message_spec.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe('ErrorMessage', function () {
1+
describe('Error Message', function () {
22
beforeEach(function () {
33
this.err = {
44
message: 'Port 2020 is already in use.',
@@ -182,4 +182,15 @@ describe('ErrorMessage', function () {
182182
expect(this.ipc.externalOpen).to.not.be.called
183183
})
184184
})
185+
186+
it('footer is at bottom when error is displayed (issue #4912)', function () {
187+
this.ipc.openProject.rejects(this.err)
188+
this.start()
189+
190+
cy.get('footer').invoke('position').then(({ top }) => {
191+
cy.get('footer').invoke('outerHeight').then((height) => {
192+
expect(top).to.equal(Cypress.config('viewportHeight') - height)
193+
})
194+
})
195+
})
185196
})

packages/desktop-gui/cypress/integration/project_mode_spec.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ describe('Project Mode', function () {
2727
this.ipc.openProject.resolves(openProject.promise)
2828
this.start()
2929

30-
cy.get('footer').invoke('position').its('top').should('be.gt', 50)
30+
cy.get('footer').invoke('position').then(({ top }) => {
31+
cy.get('footer').invoke('outerHeight').then((height) => {
32+
expect(top).to.equal(Cypress.config('viewportHeight') - height)
33+
})
34+
})
3135
})
3236

3337
describe('when specs load', function () {

packages/desktop-gui/cypress/integration/warning_message_spec.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe('WarningMessage', function () {
1+
describe('Warning Message', function () {
22
beforeEach(function () {
33
cy.fixture('specs').as('specs')
44
this.warningObj = {
@@ -124,6 +124,14 @@ describe('WarningMessage', function () {
124124
})
125125
})
126126

127+
it('displays warning above specs (issue #4912)', function () {
128+
cy.shouldBeOnProjectSpecs().then(() => {
129+
this.ipc.onProjectWarning.yield(null, this.warningObj)
130+
})
131+
132+
cy.get('.specs').invoke('position').its('top').should('gt', 100)
133+
})
134+
127135
context('with multiple warnings', function () {
128136
beforeEach(function () {
129137
this.warningObj2 = {

packages/desktop-gui/src/project/error-message.jsx

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,32 +56,34 @@ class ErrorMessage extends Component {
5656
let err = this.props.error
5757

5858
return (
59-
<div className='full-alert alert alert-danger error'>
60-
<p className='header'>
61-
<i className='fa fa-warning'></i>{' '}
62-
<strong>{err.title || 'Can\'t start server'}</strong>
63-
</p>
64-
<span className='alert-content'>
65-
<div ref={(node) => this.errorMessageNode = node} dangerouslySetInnerHTML={{
66-
__html: md.render(err.message),
67-
}}></div>
68-
{err.details && (
69-
<ErrorDetails err={err} />
70-
)}
71-
{err.portInUse && (
72-
<div>
73-
<hr />
74-
<p>To fix, stop the other running process or change the port in <code>cypress.json</code></p>
75-
</div>
76-
)}
77-
</span>
78-
<button
79-
className='btn btn-default btn-sm'
80-
onClick={this.props.onTryAgain}
81-
>
82-
<i className='fa fa-refresh'></i>{' '}
83-
Try Again
84-
</button>
59+
<div className='full-alert-container'>
60+
<div className='full-alert alert alert-danger error'>
61+
<p className='header'>
62+
<i className='fa fa-warning'></i>{' '}
63+
<strong>{err.title || 'Can\'t start server'}</strong>
64+
</p>
65+
<span className='alert-content'>
66+
<div ref={(node) => this.errorMessageNode = node} dangerouslySetInnerHTML={{
67+
__html: md.render(err.message),
68+
}}></div>
69+
{err.details && (
70+
<ErrorDetails err={err} />
71+
)}
72+
{err.portInUse && (
73+
<div>
74+
<hr />
75+
<p>To fix, stop the other running process or change the port in <code>cypress.json</code></p>
76+
</div>
77+
)}
78+
</span>
79+
<button
80+
className='btn btn-default btn-sm'
81+
onClick={this.props.onTryAgain}
82+
>
83+
<i className='fa fa-refresh'></i>{' '}
84+
Try Again
85+
</button>
86+
</div>
8587
</div>
8688
)
8789
}

packages/desktop-gui/src/project/project.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.project-content {
22
display: flex;
3+
flex-direction: column;
34
flex-grow: 2;
45
margin-bottom: 0;
56
width: 100%;

packages/desktop-gui/src/runs/setup-project-modal.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class SetupProject extends Component {
141141
</div>
142142
<div>
143143
<input
144-
autoFocus='true'
144+
autoFocus={true}
145145
ref='projectName'
146146
type='text'
147147
className='form-control'

packages/desktop-gui/src/styles/components/_alerts.scss

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,17 @@
3737
}
3838
}
3939

40+
.full-alert-container {
41+
align-items: center;
42+
display: flex;
43+
flex-grow: 2;
44+
justify-content: center;
45+
}
46+
4047
.full-alert {
4148
overflow: auto;
4249
text-align: center;
4350
padding: 20px;
44-
margin: 80px 60px 60px;
4551

4652
.alert-content {
4753
text-align: left;
@@ -76,12 +82,14 @@
7682
}
7783

7884
.project-content .alert-warning {
79-
position: relative;
8085
border-bottom: 1px solid #ddd;
86+
flex-grow: 0;
87+
flex-shrink: 0;
88+
position: relative;
8189

8290
code, pre {
83-
color: #8a6d3b;
8491
border: none;
92+
color: #8a6d3b;
8593
}
8694
}
8795

0 commit comments

Comments
 (0)