Skip to content

Commit 6b16b0e

Browse files
committed
test(perf): verify route-profile stylesheets load
Require every direct-load stylesheet URL to resolve during Cypress coverage.
1 parent e585faa commit 6b16b0e

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎apps/docs/e2e/RouteProfiles.cy.res‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ let expectProfile = expectation =>
2929
| Playground => get(".cm-editor")->should("be.visible")->ignore
3030
}
3131

32+
let expectLoadedStyles = () =>
33+
Cypress.cyWindow()->Cypress.thenPromise(async window => {
34+
let styles = await window.document
35+
->Cypress.querySelectorAll(`link[rel="stylesheet"][href]`)
36+
->Cypress.elementsFrom
37+
->Array.map(async link => {
38+
let response = await window->Cypress.windowFetch(link->Cypress.elementHref)
39+
Cypress.expect(
40+
response->Cypress.fetchStatus,
41+
~message=link->Cypress.elementHref,
42+
)->Cypress.equal(200)
43+
await response->Cypress.responseText
44+
})
45+
->Promise.all
46+
Cypress.expect(styles->Array.length)->Cypress.greaterThan(0)
47+
})
48+
3249
// static-server needs a trailing slash to resolve nested index.html files.
3350
let directLoadPath = path =>
3451
Cypress.baseUrl()->String.includes("127.0.0.1:4173") ? path ++ "/" : path
@@ -41,7 +58,7 @@ describe("Route profiles", () => {
4158
`direct ${name} load has styles and hydrates`,
4259
() => {
4360
visit(directLoadPath(path))
44-
get(`link[rel="stylesheet"]`)->should("exist")->ignore
61+
expectLoadedStyles()->ignore
4562
expectProfile(expectation)
4663
},
4764
)

0 commit comments

Comments
 (0)