Skip to content

feat: allow open option to accept an object#2492

Merged
hiroppy merged 9 commits into
webpack:masterfrom
EslamHiko:open-object
Apr 2, 2020
Merged

feat: allow open option to accept an object#2492
hiroppy merged 9 commits into
webpack:masterfrom
EslamHiko:open-object

Conversation

@EslamHiko

Copy link
Copy Markdown
Contributor
  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

yes

Motivation / Use-Case

complete : #1770

Breaking Changes

no

Additional Info

I've tested it on ubuntu Linux with this config :

devServer: {
    open: { app: ['google-chrome','--incognito']},
    openPage: 'http://google.com',
  }

@codecov

codecov Bot commented Apr 1, 2020

Copy link
Copy Markdown

Codecov Report

Merging #2492 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2492      +/-   ##
==========================================
+ Coverage   93.55%   93.57%   +0.01%     
==========================================
  Files          34       34              
  Lines        1319     1322       +3     
  Branches      379      380       +1     
==========================================
+ Hits         1234     1237       +3     
  Misses         83       83              
  Partials        2        2              
Impacted Files Coverage Δ
lib/utils/runOpen.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c6bdfe4...f1eef86. Read the comment docs.

Comment thread test/server/utils/createConfig.test.js Outdated
Comment on lines +871 to +875
Object.assign({}, argv, {
open: {
app: ['Google Chrome', '--incognito'],
},
}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Object.assign({}, argv, {
open: {
app: ['Google Chrome', '--incognito'],
},
}),
{
...argv,
open: {
app: ['Google Chrome', '--incognito'],
},
},

Comment thread test/server/utils/runOpen.test.js Outdated
).then(() => {
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
`"Unable to open \\"https://example.com/index.html\\" in browser: \\"{\\"app\\":[\\"Google Chrome\\",\\"--incognito\\"]}\\". If you are running in a headless environment, please do not use the --open flag"`
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need better test 😄

@EslamHiko EslamHiko Apr 1, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think the best way to test it is manually because even if I found a way to test chrome the chrome start name is different in operating systems ex :
from https://www.npmjs.com/package/open

The app name is platform dependent. Don't hard code it in reusable modules. 
For example, Chrome is google chrome on macOS, google-chrome on Linux and chrome on Windows.

This is a demo from my machine.
Peek 2020-04-01 18-49

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe we can use other flag, not good idea keep errors in tests in that case

@EslamHiko EslamHiko Apr 1, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@evilebottnawi what about replacing it with:
expect(opn).toBeCalledWith('https://example.com/index.html',{ app: ['Google Chrome', '--incognito'] });
This will assure that the right expected arguments has been passed to open

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good idea 👍

expect(opn).toBeCalledWith('https://example.com/index.html', {
wait: false,
});

@alexander-akait alexander-akait Apr 1, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's return warn check (logMock.warn)

Comment thread test/server/utils/createConfig.test.js Outdated
Comment on lines +871 to +872
Object.assign(
{},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't need these lines.

alexander-akait
alexander-akait previously approved these changes Apr 2, 2020

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/cc @hiroppy

hiroppy
hiroppy previously approved these changes Apr 2, 2020
@hiroppy

hiroppy commented Apr 2, 2020

Copy link
Copy Markdown
Contributor

CI is failing.

@alexander-akait

Copy link
Copy Markdown
Member

/cc @EslamHiko can you fix CI?

@EslamHiko

Copy link
Copy Markdown
Contributor Author

@evilebottnawi Yes, I'll do it in another PR

@alexander-akait

Copy link
Copy Markdown
Member

@EslamHiko we need fix CI problems in that PR 😄

@EslamHiko

Copy link
Copy Markdown
Contributor Author

It's related to test/options.test.js because there's TypeError beside the ValidationError

@EslamHiko EslamHiko dismissed stale reviews from hiroppy and alexander-akait via f1eef86 April 2, 2020 11:58
@EslamHiko

Copy link
Copy Markdown
Contributor Author

/cc @hiroppy @evilebottnawi CI is green now 😅😅 !

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/cc @hiroppy

@hiroppy hiroppy merged commit adeb92e into webpack:master Apr 2, 2020
@EslamHiko EslamHiko deleted the open-object branch April 2, 2020 12:58
@snitin315

Copy link
Copy Markdown
Member

This should be documented opening as an issue for the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants