* feat: tests for series list on article page * feat: test for jump to comments button (needs fix) * feat: tests for reaction drawer on article page * feat: test for full date on hover?? * feat: add full date on hover tests for all pages with publish dates * fixed jumping to comments test * move initialisers to packs * fix coverage issues * fix flaky login modal spec * switch back to using onclick instead of addEventListener
24 lines
673 B
JavaScript
24 lines
673 B
JavaScript
function assertions(_chai, _utils) {
|
|
_chai.Assertion.addMethod('within_viewport', function withinViewport() {
|
|
const elements = this._obj;
|
|
|
|
cy.window().then((window) => {
|
|
const viewportRight = window.innerWidth;
|
|
const viewportBottom = window.innerHeight;
|
|
|
|
const bounds = elements[0].getBoundingClientRect();
|
|
|
|
this.assert(
|
|
bounds.top < viewportBottom &&
|
|
bounds.bottom > 0 &&
|
|
bounds.left < viewportRight &&
|
|
bounds.right > 0,
|
|
'expected #{this} to be within the viewport',
|
|
'expected #{this} to not be within the viewport',
|
|
this._obj,
|
|
);
|
|
});
|
|
});
|
|
}
|
|
|
|
chai.use(assertions);
|