Repository navigation
Commit fc08fdb
committed
Fix Unit Tests: version-gate navigation block markup expectations
Cherry-pick of two commits, applied in order:
- 1062062 ("Fix navigation block
rendering unit test (#76685)")
- 29d7db9a4ec9c0fbb7f74879465bcb700a4b12de ("Fix navigation block
unit test and e2e test (#76692)", second attempt at the same fix)
Both are 100% test-only, no production code touched. Excluded the
test/e2e/specs/editor/plugins/block-hooks.spec.js hunk from the
second commit — End-to-End Tests already pass on this branch, and
this change isn't needed to fix the failing PHPUnit tests, so it's
out of scope here.
Root cause: WordPress core changed two aspects of navigation block
markup as of WP 7.0 — the leading space before the
'wp-block-navigation-item' class on <li> wrappers, and a trailing
semicolon in inline 'style' attributes on submenu <ul> wrappers.
Both commits use is_wp_version_compatible('7.0') to assert the old
markup against older cores and the new markup against 7.0+, so the
suite stays green across the WordPress versions Gutenberg supports
regardless of which core wp-env happens to pull.
Also fixed a real bug carried over from both upstream commits (still
present verbatim on wp/7.0 today): in
class-wp-navigation-block-renderer-test.php,
test_gutenberg_default_block_is_enclosed_in_li_tags()'s
is_wp_version_compatible('7.0') branch set $expected but never
called $this->assertEquals() — only the 'else' (pre-7.0) branch
did. On WP >= 7.0 the test would silently pass without asserting
anything at all. Moved the assertEquals call after the if/else so
it runs in both cases.1 parent e7f072d commit fc08fdb
2 files changed
Lines changed: 53 additions & 19 deletions
File tree
- phpunit/blocks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
134 | 148 | | |
135 | 149 | | |
136 | 150 | | |
| |||
158 | 172 | | |
159 | 173 | | |
160 | 174 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
170 | 198 | | |
171 | 199 | | |
172 | 200 | | |
| |||
0 commit comments