Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.
Open
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
2 changes: 1 addition & 1 deletion cypress/fixtures/events.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"results": [
{
"id": "b2a60543-6356-4ab5-b766-d66b96187b14",
"name": "asdasdfas",
"name": "My First Amazing Event",
"country": {
"countryName": "United Kingdom",
"continent": "EU",
Expand Down
32 changes: 32 additions & 0 deletions cypress/fixtures/publicDojo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"entity$": "-/cd/dojos",
"name": "Dublin Ninja Kids",
"geoPoint": {
"lat": 53.349351,
"lon": -6.247585999999956
},
"stage": 0,
"urlSlug": "ie/dublin/dublinkids",
"private": 0,
"verified": 1,
"id": "b850b40e-1e10-4e3a-8a46-d076c94946c6",
"address1": "CHQ Building,1 Custom House Quay, North Dock",
"countryName": "Ireland",
"email": "dublinninjakids@gmail.com",
"facebook": "https://www.facebook.com/CoderDojo",
"googleGroup": "https://google.group.com/dublinninjakids",
"twitter": "https://twitter.com/CoderDojo",
"notes": "<p>This is the Dojo details section</p>\n",
"needMentors": 0,
"placeName": "Dublin",
"city": {
"name": "Dublin"
},
"frequency": "1/m",
"alternativeFrequency": "3rd",
"day": 4,
"startTime": "10:00:00",
"endTime": "11:30:00",
"website": "www.dublinninjakids.com",
"supporterImage": "http://www.xconomy.com/wordpress/wp-content/images/2013/01/dogpatch-labs-logo.png"
}
56 changes: 56 additions & 0 deletions cypress/integration/dojos/dojo-details_spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,67 @@
import page from '../../pages/dojo-details';

const currentYear = (new Date()).getFullYear();
describe('Dojos details', () => {
beforeEach(() => {
cy.server();
cy.route('/api/2.0/users/instance', 'fx:parentLoggedIn').as('loggedIn');
cy.route('POST', '/api/2.0/dojos/find', 'fx:publicDojo').as('dojo');
cy.fixture('publicDojo.json').as('privateDojo').then((dojo) => {
dojo.private = 1;
});
});

it('should show the dojo details', () => {
cy.visit('/dojos/ie/dublin/cd-rom');
cy.wait('@loggedIn');
cy.wait('@dojo');
cy.get(page.name).should('have.text', 'Dublin Ninja Kids');
cy.get(page.column.time.content).should('contain.text', 'Third Thursday of the month, 10am - 11:30am');
cy.get(page.column.location.content).should('contain.text', 'CHQ Building,1 Custom House Quay, North Dock');
cy.get(page.column.email.content).should('contain.text', 'dublinninjakids@gmail.com');
cy.get(page.column.website.content).should('contain.text', 'www.dublinninjakids.com');
cy.get(page.column.social.facebook).invoke('attr', 'href').should('equal', 'https://www.facebook.com/CoderDojo');
cy.get(page.column.social.twitter).invoke('attr', 'href').should('equal', 'https://twitter.com/CoderDojo');
cy.get(page.column.social.googleGroup).invoke('attr', 'href').should('equal', 'https://google.group.com/dublinninjakids');
cy.get(page.map).should('be.visible');
cy.get(page.details.heading).should('contain.text', 'Details');
cy.get(page.details.content).should('contain.text', 'This is the Dojo details section');
cy.get(page.sponsors.heading).should('contain.text', 'Dojo supported by');
cy.get(page.sponsors.content).should('be.visible');
});
describe('events', () => {
it('should show the dojos events', () => {
cy.route('/api/3.0/dojos/b850b40e-1e10-4e3a-8a46-d076c94946c6/events?**', 'fx:events').as('events')
cy.visit('/dojos/ie/dublin/cd-rom');
cy.wait('@dojo');
cy.wait('@loggedIn');
cy.wait('@events');
cy.get(page.events(1).name).should('contain.text', 'My First Amazing Event');
cy.get(page.events(1).sessions).should('contain.text', 'Sessions: Dojo');
cy.get(page.events(1).date).should('contain.text', 'July 12, 2019');
cy.get(page.events(1).time).should('contain.text', '10am - 12pm');
});
it('should show message if no events are scheduled and Dojo is public', () => {
cy.route('/api/3.0/dojos/b850b40e-1e10-4e3a-8a46-d076c94946c6/events?**', { results: [] }).as('events')
cy.visit('/dojos/ie/dublin/cd-rom');
cy.wait('@dojo');
cy.wait('@loggedIn');
cy.wait('@events');
cy.get(page.noEvents).first().should('contain.text', 'This Dojo may list their events on another website or they may encourage people to attend without booking.');
cy.get(page.noEvents).last().should('contain.text', 'Please join this Dojo for updates and email the Dojo on dublinninjakids@gmail.com to find out about their upcoming events.');
});

it('should show message if no events are scheduled and Dojo is private', () => {
cy.route('POST', '/api/2.0/dojos/find', '@privateDojo').as('dojo');
cy.route('/api/3.0/dojos/b850b40e-1e10-4e3a-8a46-d076c94946c6/events?**', { results: [] }).as('events')
cy.visit('/dojos/ie/dublin/cd-rom');
cy.wait('@dojo');
cy.wait('@loggedIn');
cy.wait('@events');
cy.get(page.noEvents).first().should('contain.text', 'This Dojo may list their events on another website or they may encourage people to attend without booking.');
cy.get(page.noEvents).last().should('contain.text', 'Please email the Dojo on dublinninjakids@gmail.com to find out about their upcoming events.');
});
});
it('should display the calendar', () => {
cy.visit('/dojos/ie/dublin/dublin-ninja-kids');
cy.wait('@loggedIn');
Expand Down
37 changes: 37 additions & 0 deletions cypress/pages/dojo-details.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,46 @@

function section(index) {
return {
label: `.cd-dojo-details__left-column>div:nth-child(${index}) .cd-info-column-section__header .cd-info-column-section__header-text`,
content: `.cd-dojo-details__left-column>div:nth-child(${index}) .cd-info-column-section__content`,
};
}

export default {
name: '.cd-dojo-details__name',
column: {
// Calendar
calendarLink: '.cd-info-column-section.cd-dojo-details__left-column-section .cd-ics-link summary',
calendarInput: '.cd-info-column-section.cd-dojo-details__left-column-section .cd-ics-link input',
calendarCopyBtn: '.cd-info-column-section.cd-dojo-details__left-column-section .cd-ics-link button',
calendarOpenBtn: '.cd-info-column-section.cd-dojo-details__left-column-section .cd-ics-link a',
time: section(1),
location: section(2),
email: section(3),
website: section(4),
social: {
facebook: '.cd-dojo-details__social-media-icon.cd-dojo-details__facebook',
twitter: '.cd-dojo-details__social-media-icon.cd-dojo-details__twitter',
googleGroup: '.cd-dojo-details__social-media-icon.cd-dojo-details__google-group',
},
},
map: 'img.cd-dojo-details__static-map',
details: {
heading: '.cd-dojo-details__section .cd-dojo-details__heading',
content: '.cd-dojo-details__section .cd-dojo-details__details',
},
sponsors: {
heading: '.cd-dojo-details__section .cd-dojo-details__heading',
content: '.cd-dojo-details__section .cd-dojo-details__sponsor-image',
},
noEvents: '.cd-event-list__no-events-content',
events: function (index) {
const prefix = `.cd-event-list__events > div:nth-child(${index})`;
return {
name: `${prefix} .cd-event-list-item__name`,
sessions: `${prefix} .cd-event-list-item__sessions`,
date: `${prefix} .cd-event-list-item__date-timestamp`,
time: `${prefix} .cd-event-list-item__times-timestamp`,
};
},
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"copy-webpack-plugin": "^4.0.1",
"cross-env": "^4.0.0",
"css-loader": "^0.28.0",
"cypress": "^3.1.5",
"cypress": "3.4.1",
"eslint": "^3.19.0",
"eslint-config-airbnb-base": "^11.1.3",
"eslint-friendly-formatter": "^2.0.7",
Expand Down
Loading