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