-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] 🚧 v3 #20
base: main
Are you sure you want to change the base?
[WIP] 🚧 v3 #20
Changes from all commits
bfadc98
f439d09
3a7acc5
2be3317
1656c17
b240f77
4fb866b
98bccec
bd26422
709dd01
a9f01ad
8180677
55f82aa
69af918
59f17f5
8ef81e5
ea0468e
3b4011d
1b9c5c9
84c60a3
50d4f43
4c36d99
32e7b2d
51d7939
bdf451f
470625d
3d89c2f
c2c9cbe
06c2e0d
dc17192
a0d2760
56f9905
4ca9788
c64b5f6
90d889b
4fda071
51dad4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
defaults | ||
ie 11 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,9 @@ | |
"browser": true, | ||
"es6": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 2020 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Upgrading to ES2020. |
||
}, | ||
"rules": { | ||
"class-methods-use-this": "off", | ||
"no-console": "off", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ report.html | |
|
||
# Cypress | ||
cypress/videos/ | ||
cypress/screenshots/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{ | ||
"baseUrl": "http://localhost:8080", | ||
"firefoxGcInterval": null, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Removing deprecated Cypress options. |
||
"video": false, | ||
"viewportHeight": 660, | ||
"viewportWidth": 1000 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,10 +29,10 @@ describe('Events', () => { | |
cy.getSlider('test').then(() => expect(fn).to.not.be.called); | ||
|
||
// Scroll to trigger a change, then confirm the callback fired. | ||
// NOTE: Need extra `.wait()` so `expect` happens after the callback. | ||
// NOTE: Need extra `.wait()` so `expect` happens after the callback has debounced. | ||
// eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.getSlider('test').scrollTo('right') | ||
.wait(0) | ||
.wait(350) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Intersection Observer |
||
.then(() => expect(fn).to.be.calledOnce); | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,8 @@ describe('Goto Buttons', () => { | |
.should('equal', 'next'); | ||
}); | ||
|
||
it('checks classes for prev/next terms if the button content is empty', () => { | ||
// TODO: Class matching. Or remove??? | ||
xit('checks classes for prev/next terms if the button content is empty', () => { | ||
cy.get('#prev-terms-class button') | ||
.invoke('attr', 'data-snap-slider-goto') | ||
.should('equal', 'prev'); | ||
|
@@ -91,7 +92,9 @@ describe('Goto Buttons', () => { | |
describe('Classes', () => { | ||
it('adds a current class to numeric buttons when their slide is current', () => { | ||
// Slide to the 3rd item. | ||
cy.getSlider('test').children(':nth-child(3)').scrollIntoView(); | ||
// NOTE: Add `duration` so Intersection Observer fires. | ||
// @see https://github.com/cypress-io/cypress/issues/3848#issuecomment-478132607 | ||
cy.getSlider('test').children(':nth-child(3)').scrollIntoView({ duration: 100 }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Is this |
||
|
||
// Current buttons should have the class. | ||
cy.get('#standard [data-snap-slider-goto*="3"]') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,45 +43,6 @@ describe('HTML API', () => { | |
}); | ||
}); | ||
|
||
it('`[data-snap-slider-align]` specifies the CSS align value for older browsers', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Removing |
||
// Confirm slider start position, then go to the middle slide. | ||
cy.getSlider('align').then(($el) => { | ||
const slider = $el.get(0).SnapSlider; | ||
|
||
expect(slider.container.scrollLeft).to.equal(0); | ||
|
||
slider.goto('middle'); | ||
}); | ||
|
||
// Confirm slider position. | ||
cy.getSlider('align').invoke('scrollLeft').should('equal', 152); | ||
}); | ||
|
||
it('`[data-snap-slider-align]` is empty by default', () => { | ||
cy.getSlider('align-default').then(($el) => { | ||
const slider = $el.get(0).SnapSlider; | ||
|
||
expect(slider.container.getAttribute('data-snap-slider-align')).to.equal(''); | ||
}); | ||
}); | ||
|
||
it('`[data-snap-slider-align]` only applies when CSS Scroll Snap is not supported', () => { | ||
// Confirm slider start position, then go to the middle slide. | ||
cy.getSlider('align-fallback').then(($el) => { | ||
const slider = $el.get(0).SnapSlider; | ||
|
||
expect(slider.container.scrollLeft).to.equal(0); | ||
|
||
slider.goto('middle'); | ||
}); | ||
|
||
// Confirm slider position. | ||
// NOTE: This test needs to be manually checked in Safari. | ||
// Currently, Chrome snaps on JS scroll but Safari does not. | ||
// Safari stays wherever JS scrolled it instead of snapping. | ||
cy.getSlider('align').invoke('scrollLeft').should('equal', 0); | ||
}); | ||
|
||
it('`[data-snap-slider-nav]` inits nav elements', () => { | ||
// We know the nav loaded correctly if all its buttons | ||
// have `[data-snap-slider-goto]` attributes. | ||
|
@@ -141,6 +102,10 @@ describe('HTML API', () => { | |
.should('not.have.attr', 'data-snap-slider-goto'); | ||
}); | ||
|
||
// TODO: Prev/next buttons. | ||
// data-snap-slider-prev | ||
// data-snap-slider-next | ||
|
||
it('`[data-snap-slider-goto="<SLIDE>"]` inits goto buttons in a container or nav element', () => { | ||
// Make sure slider hasn't scrolled yet. | ||
cy.getSlider('goto-buttons').invoke('scrollLeft').should('equal', 0); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ describe('Scroll Offset', () => { | |
|
||
// Confirm slider position. | ||
cy.getSlider('vertical-example').invoke('scrollLeft').should('equal', 0); | ||
cy.getSlider('vertical-example').invoke('scrollTop').should('equal', 320); | ||
cy.getSlider('vertical-example').invoke('scrollTop').should('equal', 288); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Updating scroll positions to match design changes. |
||
}); | ||
|
||
it('works with 2D sliders', () => { | ||
|
@@ -25,14 +25,14 @@ describe('Scroll Offset', () => { | |
const slider = $el.get(0).SnapSlider; | ||
|
||
expect(slider.container.scrollLeft).to.equal(320); | ||
expect(slider.container.scrollTop).to.equal(240); | ||
expect(slider.container.scrollTop).to.equal(224); | ||
|
||
slider.goto('last'); | ||
}); | ||
|
||
// Confirm slider position. | ||
cy.getSlider('2d-example').invoke('scrollLeft').should('equal', 640); | ||
cy.getSlider('2d-example').invoke('scrollTop').should('equal', 480); | ||
cy.getSlider('2d-example').invoke('scrollTop').should('equal', 448); | ||
}); | ||
|
||
it('works with nested sliders', () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Dropping IE support.