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

Test suite for supportedProperty #11

Merged
merged 1 commit into from
Feb 20, 2017

Conversation

cvle
Copy link
Member

@cvle cvle commented Dec 1, 2016

Test cases are taken from http://shouldiprefix.com/ marked as use prefixes. Additionally the transition property is tested.

The following issues have been discovered and fixed:

  • Fixes issue when prefixing the filter property
  • Fallback to ms prefix on edge

@cvle
Copy link
Member Author

cvle commented Dec 1, 2016

We will need to do this for supportedValue as well.

@cvle cvle force-pushed the property-prefix-test-suite branch 2 times, most recently from 6914564 to e335d5c Compare December 1, 2016 09:20
full: 2,
}

const cases = [
Copy link
Member

Choose a reason for hiding this comment

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

can we somehow avoid maintaining this list, but instead generating it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wouldn't know how. There is no list anywhere connecting the caniuse feature name with the actual css properties. And then there are some edge cases, where we have to specifically follow the caniuse footnotes, explaining the differences in implementation and adhere to those. I think this is the best we can get.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I can try relying on https://github.com/postcss/postcss-js for this. Let me see if it works.

@cvle cvle changed the title Test suite for supportedProperty [WIP] Test suite for supportedProperty Dec 1, 2016
@cvle cvle force-pushed the property-prefix-test-suite branch from e335d5c to 0feb6f4 Compare December 1, 2016 11:01
@cvle
Copy link
Member Author

cvle commented Dec 1, 2016

Changed fixture to be generated from all available properties and using prefixes from autoprefixer. I think we can rely on autoprefixer to be correct, wdyt? Now the tests are all failing due to various wrong prefixes. We have to deal with the issues one by one.

@kof
Copy link
Member

kof commented Dec 1, 2016

I think thats the right way to go. Are there many issues?

@cvle
Copy link
Member Author

cvle commented Dec 1, 2016

I'll make a list.

@cvle
Copy link
Member Author

cvle commented Dec 1, 2016

Some of the issues can be sorted out by correctly ignoring unsupported properties by the autoprefixer.

@kof
Copy link
Member

kof commented Dec 1, 2016

Why does auto detection fail in those cases?

@cvle
Copy link
Member Author

cvle commented Dec 1, 2016

I think we can solve some cases for Edge by prefering ms prefix over the webkit prefix to align with the autoprefixer. Some issues from Opera can probably be solved by falling back to the webkit prefix. Others I don't know yet. It could possibly be like the filter property, where there is support for the same property without a prefix which behaves different than with a prefix.

@kof
Copy link
Member

kof commented Dec 1, 2016

where there is support for the same property without a prefix which behaves different than with a prefix.

prefix has been always used for experimental implementations, if it works without we should use without.

@cvle
Copy link
Member Author

cvle commented Dec 2, 2016

Not always. I noticed that for the filter property, browser supports only the url() value when not using a prefix, but support others like grayscale() when using the prefix. That's why it failed in the tests. So it happens that for some properties there is a non-prefixed version and a prefixed-version that behaves differently. I guess some of the issues above could be caused by that.

@kof
Copy link
Member

kof commented Dec 2, 2016

That makes sense, looks like prefixed version just implements more features which haven't been unprefixed yet. Bad for auto detection though. Maybe we should leave such props out for user to decide?

@kof
Copy link
Member

kof commented Dec 2, 2016

Actually we need to do exactly the same like static auto prefixer does in such cases. Because in SSR a static prefixer will be used and we need a consistency.

@kof
Copy link
Member

kof commented Dec 2, 2016

I was thinking to use https://github.com/rofrischmann/inline-style-prefix-all for the static version.

@cvle
Copy link
Member Author

cvle commented Dec 2, 2016

All static prefixers follow the caniuse data, I will try to stick to that. For the filter property I already have a solution by checking whether the unprefixed property accepts a grayscale value and if not use the prefixed property if available.

I'm currently using the data from autoprefixer here. It contains a list of properties and browsers that needs a prefix which I did manually before. But I cannot tell using this data whether the property is fully supported or not supported at all. I will work on a PR to expose the feature name so we can query the caniuse db by ourself.

I removed the Todo list above, it was inaccurate. I'll do another one when it's ready.

@kof
Copy link
Member

kof commented Dec 21, 2016

Wondering if this will also prefix the gradient…

@cvle
Copy link
Member Author

cvle commented Dec 23, 2016

The PR here is a test suite for supportedProperty. Gradient is a case for supportedValue. Though I think the prefix should work, but we can only know for sure when we add a test case. What makes you wonder?

@kof
Copy link
Member

kof commented Dec 23, 2016

Yeah, wrong pr, because this is a long standing issue cssinjs/jss#90

@kof
Copy link
Member

kof commented Dec 23, 2016

Can I help with this? What needs to be done?

@cvle
Copy link
Member Author

cvle commented Dec 24, 2016

I almost finished generating a better test fixture, then we can see which test cases are failing.

@cvle
Copy link
Member Author

cvle commented Dec 24, 2016

Related: Fyrd/caniuse#3070

@cvle
Copy link
Member Author

cvle commented Dec 24, 2016

Pending PR: postcss/autoprefixer#758

@kof
Copy link
Member

kof commented Jan 13, 2017

@cvle how can I help here? we recently released http://cssinjs.org/ Now I can start with the next thing, I would probably start cssinjs/jss#356 if you are going to finish this. Otherwise I need to do this, because its important.

@cvle
Copy link
Member Author

cvle commented Jan 13, 2017

I'm a bit occupied with some projects, but I am still determined to get this done. Now that autoprefixer merged my PR, I can update this.

@cvle
Copy link
Member Author

cvle commented Feb 11, 2017

Sorry for letting this stale for so long. I scheduled some time to work on this for the coming week. I'm finishing one of my projects soon so I'll have more time.

@kof
Copy link
Member

kof commented Feb 11, 2017

Looking forward to it! By the way @rofrischmann mentioned in chat that he is happy to help. He built inline-style-prefixer

@robinweser
Copy link
Member

True story. I'd love to help. Also got a lot of knowledge in that field actually.

@cvle
Copy link
Member Author

cvle commented Feb 19, 2017

Ok I started working on this again. This is now my main focus. I appreciate your help @rofrischmann, great!

@cvle
Copy link
Member Author

cvle commented Feb 20, 2017

Please review my commit. It adds the autoprefixer test suite, but doesn't fix any of the failing tests. Let's deal with the issues one by one until we have full compliance.

if (failMsgs.length > 0) {
failMsgs.forEach(err => {
const logMsg = `${currentBrowser.id} ${currentBrowser.version} ${err}`
console.log(logMsg) // eslint-disable-line no-console
Copy link
Member

Choose a reason for hiding this comment

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

in other repos we have started to use the warning module

Copy link
Member

Choose a reason for hiding this comment

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

Why do we catch the assertions and log the messages anyways? Shouldn't we just let let them throw and fix the code to support everything correctly?

Copy link
Member Author

Choose a reason for hiding this comment

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

If you throw immediately, you will only see the first non matching property prefix. This way we have a whole list and an overview of what needs to be done. We also can easily spot related property prefix errors.

Copy link
Member Author

Choose a reason for hiding this comment

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

The logging is meant for the CI log, not for end users, so I think the warning module is unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is also needed because the karma mocha reporter screws up the summary when running with multiple browsers..

Copy link
Member Author

@cvle cvle Feb 20, 2017

Choose a reason for hiding this comment

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

I will add comments to clarify this

Copy link
Member

Choose a reason for hiding this comment

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

do we need it just for now to see an overview? after we fix them all, we can go back to normal assertion?

Copy link
Member

Choose a reason for hiding this comment

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

by the way, we could generate it() statements witha n assertion together, this should fix the reporting, it exits basically because one it is one test case, by design one it shouldn't have lots of assertions actually.

Copy link
Member Author

Choose a reason for hiding this comment

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

True lets do that. But we will still need to log to the console, because of the karma-mocha-reporter issue. The problem is that when two browsers fail the same test but outputs a different message, only the first message is reported in the summary.

@cvle
Copy link
Member Author

cvle commented Feb 20, 2017

Wait before review, I'm not ready.

@cvle
Copy link
Member Author

cvle commented Feb 20, 2017

Ok ready. Now I give an unique string for each test for each browser so karma-mocha-reporter gives a good summary 👍

@cvle cvle changed the title [WIP] Test suite for supportedProperty Test suite for supportedProperty Feb 20, 2017
@kof
Copy link
Member

kof commented Feb 20, 2017

nice!

@kof kof merged commit f872ce3 into cssinjs:master Feb 20, 2017
@kof
Copy link
Member

kof commented Feb 20, 2017

merged

@cvle
Copy link
Member Author

cvle commented Feb 21, 2017

Related: postcss/autoprefixer#792

@cvle
Copy link
Member Author

cvle commented Feb 23, 2017

Related: postcss/autoprefixer#793

@cvle
Copy link
Member Author

cvle commented Feb 23, 2017

Related: Fyrd/caniuse#3189

@cvle
Copy link
Member Author

cvle commented Feb 23, 2017

Related: Fyrd/caniuse#3190

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.

3 participants