| 1 | import {Selector} from 'testcafe'; |
| 2 | |
| 3 | fixture `Chrome Validation Tests` |
| 4 | .page `http://localhost:8080/test/page/without-css.html`; |
| 5 | |
| 6 | test('Use a better box model (opinionated).', async t => { |
| 7 | await t |
| 8 | .expect(Selector('html').getStyleProperty('box-sizing')).notEql('border-box'); |
| 9 | }); |
| 10 | |
| 11 | test('Use a more readable tab size (opinionated).', async t => { |
| 12 | await t |
| 13 | .expect(Selector('html').getStyleProperty('tab-size')).notEql('4'); |
| 14 | }); |
| 15 | |
| 16 | test('Correct the line height in all browsers.', async t => { |
| 17 | await t |
| 18 | .expect(Selector('html').getStyleProperty('font-size')).eql('16px') |
| 19 | .expect(Selector('html').getStyleProperty('line-height')).notEql('18.4px'); |
| 20 | }); |
| 21 | |
| 22 | test('Prevent adjustments of font size after orientation changes in iOS.', async t => { |
| 23 | await t |
| 24 | .expect(Selector('html').getStyleProperty('text-size-adjust')).notEql('100%'); |
| 25 | }); |
| 26 | |
| 27 | test('Remove the margin in all browsers.', async t => { |
| 28 | await t |
| 29 | .expect(Selector('body').getStyleProperty('margin-top')).notEql('0px') |
| 30 | .expect(Selector('body').getStyleProperty('margin-right')).notEql('0px') |
| 31 | .expect(Selector('body').getStyleProperty('margin-bottom')).notEql('0px') |
| 32 | .expect(Selector('body').getStyleProperty('margin-left')).notEql('0px'); |
| 33 | }); |
| 34 | |
| 35 | test('Improve consistency of default fonts in all browsers.', async t => { |
| 36 | await t |
| 37 | .expect(Selector('body').getStyleProperty('font-family')).notEql('system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"'); |
| 38 | }); |
| 39 | |
| 40 | test('<hr> should be the correct height.', async t => { |
| 41 | await t |
| 42 | .expect(Selector('hr[data-test--hr]').getStyleProperty('height')).notEql('2px'); |
| 43 | }); |
| 44 | |
| 45 | test('Add the correct text decoration in Safari.', async t => { |
| 46 | await t |
| 47 | .expect(Selector('abbr[data-test--abbr]').getStyleProperty('text-decoration')).eql('underline dotted rgb(0, 0, 0)'); |
| 48 | }); |
| 49 | |
| 50 | test('Add the correct font weight in Chrome and Safari.', async t => { |
| 51 | await t |
| 52 | .expect(Selector('b[data-test--bold]').getStyleProperty('font-weight')).notEql('900') |
| 53 | .expect(Selector('strong[data-test--bold]').getStyleProperty('font-weight')).notEql('900'); |
| 54 | }); |
| 55 | |
| 56 | test('Improve consistency of default fonts in all browsers.', async t => { |
| 57 | await t |
| 58 | .expect(Selector('[data-test--code]').getStyleProperty('font-family')).notEql('ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace'); |
| 59 | }); |
| 60 | |
| 61 | test('Correct the odd `em` font sizing in all browsers.', async t => { |
| 62 | await t |
| 63 | .expect(Selector('[data-test--code]').getStyleProperty('font-size')).notEql('16px'); |
| 64 | }); |
| 65 | |
| 66 | test('Add the correct font size in all browsers.', async t => { |
| 67 | await t |
| 68 | .expect(Selector('[data-test--small]').getStyleProperty('font-size')).notEql('12.8px'); |
| 69 | }); |
| 70 | |
| 71 | test('Prevent `sub` and `sup` elements from affecting the line height in all browsers.', async t => { |
| 72 | await t |
| 73 | .expect(Selector('[data-test--subsup]').getStyleProperty('font-size')).notEql('12px') |
| 74 | .expect(Selector('[data-test--subsup]').getStyleProperty('line-height')).notEql('0px') |
| 75 | .expect(Selector('[data-test--subsup]').getStyleProperty('position')).notEql('relative') |
| 76 | .expect(Selector('[data-test--subsup]').getStyleProperty('vertical-align')).notEql('baseline') |
| 77 | .expect(Selector('sub[data-test--subsup]').getStyleProperty('bottom')).notEql('-3px') |
| 78 | .expect(Selector('sup[data-test--subsup]').getStyleProperty('top')).notEql('-6px'); |
| 79 | }); |
| 80 | |
| 81 | test('Change the font styles in all browsers.', async t => { |
| 82 | await t |
| 83 | .expect(Selector('[data-test--forms-1]').getStyleProperty('font-family')).notEql('MYCUSTOMFONT') |
| 84 | .expect(Selector('[data-test--forms-1]').getStyleProperty('font-size')).notEql('16px') |
| 85 | .expect(Selector('[data-test--forms-1]').getStyleProperty('line-height')).notEql('18.4px'); |
| 86 | }); |
| 87 | |
| 88 | test('Remove the margin in Firefox and Safari.', async t => { |
| 89 | await t |
| 90 | .expect(Selector('[data-test--forms-1]').getStyleProperty('margin-top')).eql('0px') |
| 91 | .expect(Selector('[data-test--forms-1]').getStyleProperty('margin-right')).eql('0px') |
| 92 | .expect(Selector('[data-test--forms-1]').getStyleProperty('margin-bottom')).eql('0px') |
| 93 | .expect(Selector('[data-test--forms-1]').getStyleProperty('margin-left')).eql('0px'); |
| 94 | }); |
| 95 | |
| 96 | test('Text transform should not be inherited.', async t => { |
| 97 | await t |
| 98 | .expect(Selector('button[data-test--forms-1]').getStyleProperty('text-transform')).eql('none') |
| 99 | .expect(Selector('select[data-test--forms-1]').getStyleProperty('text-transform')).eql('none'); |
| 100 | }); |
| 101 | |
| 102 | test('Correct the inability to style clickable types in iOS and Safari.', async t => { |
| 103 | await t |
| 104 | .expect(Selector('button[data-test--forms-1]').getStyleProperty('-webkit-appearance')).eql('button') |
| 105 | .expect(Selector('[type="button"][data-test--forms-1]').getStyleProperty('-webkit-appearance')).notEql('button') |
| 106 | .expect(Selector('[type="reset"][data-test--forms-1]').getStyleProperty('-webkit-appearance')).notEql('button') |
| 107 | .expect(Selector('[type="submit"][data-test--forms-1]').getStyleProperty('-webkit-appearance')).notEql('button'); |
| 108 | }); |
| 109 | |
| 110 | test('Correct the padding in Firefox.', async t => { |
| 111 | await t |
| 112 | .expect(Selector('fieldset[data-test--forms-2]').getStyleProperty('padding-top')).eql('5.6px') |
| 113 | .expect(Selector('fieldset[data-test--forms-2]').getStyleProperty('padding-right')).eql('12px') |
| 114 | .expect(Selector('fieldset[data-test--forms-2]').getStyleProperty('padding-bottom')).eql('10px') |
| 115 | .expect(Selector('fieldset[data-test--forms-2]').getStyleProperty('padding-left')).eql('12px'); |
| 116 | }); |
| 117 | |
| 118 | test('Remove the padding so developers are not caught out when they zero out `fieldset` elements in all browsers.', async t => { |
| 119 | await t |
| 120 | .expect(Selector('legend[data-test--forms-2]').getStyleProperty('padding-top')).eql('0px') |
| 121 | .expect(Selector('legend[data-test--forms-2]').getStyleProperty('padding-right')).notEql('0px') |
| 122 | .expect(Selector('legend[data-test--forms-2]').getStyleProperty('padding-bottom')).eql('0px') |
| 123 | .expect(Selector('legend[data-test--forms-2]').getStyleProperty('padding-left')).notEql('0px'); |
| 124 | }); |
| 125 | |
| 126 | test('Add the correct vertical alignment in Chrome and Firefox.', async t => { |
| 127 | await t |
| 128 | .expect(Selector('progress[data-test--forms-2]').getStyleProperty('vertical-align')).notEql('baseline'); |
| 129 | }); |
| 130 | |
| 131 | test('Correct the cursor style of increment and decrement buttons in Safari.', async t => { |
| 132 | // TODO: Pseudo-elements selector not supported by testcafe (See https://github.com/DevExpress/testcafe/issues/2813). |
| 133 | }); |
| 134 | |
| 135 | test('Correct the odd appearance in Chrome and Safari.', async t => { |
| 136 | await t |
| 137 | .expect(Selector('[type="search"][data-test--forms-1]').getStyleProperty('-webkit-appearance')).notEql('textfield'); |
| 138 | }); |
| 139 | |
| 140 | test('Correct the outline style in Safari.', async t => { |
| 141 | await t |
| 142 | .expect(Selector('[type="search"][data-test--forms-1]').getStyleProperty('outline-offset')).eql('0px'); |
| 143 | }); |
| 144 | |
| 145 | test('Remove the inner padding in Chrome and Safari on macOS.', async t => { |
| 146 | // TODO: Pseudo-elements selector not supported by testcafe (See https://github.com/DevExpress/testcafe/issues/2813). |
| 147 | }); |
| 148 | |
| 149 | test('Correct the inability to style clickable types in iOS and Safari.', async t => { |
| 150 | // TODO: Pseudo-elements selector not supported by testcafe (See https://github.com/DevExpress/testcafe/issues/2813). |
| 151 | }); |
| 152 | |
| 153 | test('Change font properties to `inherit` in Safari.', async t => { |
| 154 | // TODO: Pseudo-elements selector not supported by testcafe (See https://github.com/DevExpress/testcafe/issues/2813). |
| 155 | }); |
| 156 | |
| 157 | test('Add the correct display in Chrome and Safari.', async t => { |
| 158 | await t |
| 159 | .expect(Selector('summary[data-test--interactive]').getStyleProperty('display')).notEql('list-item'); |
| 160 | }); |