Skip to content
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

Use data attributes for test selectors #299

Merged
merged 1 commit into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/cypress/integration/element-targeting.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Attaching tooltips to target elements in the DOM on each step', () =>
it('Adds the "shepherd-target" and "shepherd-enabled" classes upon showing a step', () => {
tour.start();

cy.get('.hero-welcome')
cy.get('[data-test-hero-welcome]')
.should('have.class', 'shepherd-target')
.and('have.class', 'shepherd-enabled');
});
Expand All @@ -40,7 +40,7 @@ describe('Attaching tooltips to target elements in the DOM on each step', () =>
tour.start();
tour.next();

cy.get('.hero-welcome')
cy.get('[data-test-hero-welcome]')
.should('not.have.class', 'shepherd-target')
.and('not.have.class', 'shepherd-enabled');
});
Expand Down
12 changes: 6 additions & 6 deletions test/cypress/integration/test.acceptance.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ describe('Shepherd Acceptance Tests', () => {
.contains('Shepherd is a JavaScript library').should('be.visible');

cy.document().then((document) => {
assert.deepEqual(document.querySelector('.hero-welcome'), tour.getCurrentStep().target, '.hero-welcome is the target');
assert.deepEqual(document.querySelector('[data-test-hero-welcome]'), tour.getCurrentStep().target, 'hero welcome is the target');
});
});

it('works with DOM elements', () => {
cy.document().then((document) => {
const heroIncludingElement = document.querySelector('.hero-including');
const heroIncludingElement = document.querySelector('[data-test-hero-including]');

const steps = () => {
return [
Expand Down Expand Up @@ -192,19 +192,19 @@ describe('Shepherd Acceptance Tests', () => {
scrollTo: true
});
tour.start();
cy.get('.hero-scroll').should('have.prop', 'scrollTop').and('eq', 0);
cy.get('[data-test-hero-scroll]').should('have.prop', 'scrollTop').and('eq', 0);
cy.contains('Next').click();
cy.get('.hero-scroll').should('have.prop', 'scrollTop').and('gt', 0);
cy.get('[data-test-hero-scroll]').should('have.prop', 'scrollTop').and('gt', 0);
});

it('scrollTo:false does not scroll', () => {
const tour = setupTour(Shepherd, {
scrollTo: false
});
tour.start();
cy.get('.hero-scroll').should('have.prop', 'scrollTop').and('eq', 0);
cy.get('[data-test-hero-scroll]').should('have.prop', 'scrollTop').and('eq', 0);
cy.contains('Next').click();
cy.get('.hero-scroll').should('have.prop', 'scrollTop').and('eq', 0);
cy.get('[data-test-hero-scroll]').should('have.prop', 'scrollTop').and('eq', 0);
});
});
});
Expand Down
6 changes: 3 additions & 3 deletions test/dummy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
</head>

<body>
<div class="hero-scroll">
<div class="hero-scroll" data-test-hero-scroll>
<div class="hero-outer">
<div class="hero-inner">
<div class="hero-welcome">
<div class="hero-welcome" data-test-hero-welcome>
<h1>Shepherd</h1>

<h2>Guide your users through a tour of your app.</h2>
</div>

<div class="hero-including">
<div class="hero-including" data-test-hero-including>
<h3>Including</h3>

<script type="text/plain" class="language-markup" id="hero-including-code">
Expand Down