Skip to content

Commit

Permalink
add og:site_name metadata on all pages + cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
osma committed Aug 21, 2024
1 parent 6b23407 commit 3f4d7b1
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/view/base-template.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<meta property="og:description" content="{{ block('description') }}">
{% endif %}
<meta name="twitter:card" content="summary">
<meta property="og:site_name" content="{{ GlobalConfig.serviceName }}">
<link href="node_modules/bootstrap/dist/css/bootstrap.min.css" media="screen, print" rel="stylesheet" type="text/css">
<link href="resource/css/fonts.css" media="screen, print" rel="stylesheet" type="text/css">
<link href="resource/css/skosmos.css" media="screen, print" rel="stylesheet" type="text/css">
Expand Down
8 changes: 8 additions & 0 deletions tests/cypress/template/about.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ describe('About page', () => {
cy.get('head meta[name="description"]').should('have.attr', 'content', expectedDescription);
cy.get('head meta[property="og:description"]').should('have.attr', 'content', expectedDescription);
})
it('Contains site name metadata', () => {
// go to the Skosmos about page
cy.visit('/en/about')

const expectedSiteName = 'Skosmos being tested'
// check that the page has site name metadata
cy.get('head meta[property="og:site_name"]').should('have.attr', 'content', expectedSiteName);
})
it('Contains version number information', () => {
// go to the Skosmos about page
cy.visit('/en/about')
Expand Down
7 changes: 7 additions & 0 deletions tests/cypress/template/concept.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ describe('Concept page', () => {
cy.get('head meta[name="title"]').should('have.attr', 'content', expectedTitle);
cy.get('head meta[property="og:title"]').should('have.attr', 'content', expectedTitle);
})
it('Contains site name metadata', () => {
cy.visit('/yso/en/page/p1265') // go to "archaeology" concept page

const expectedSiteName = 'Skosmos being tested'
// check that the page has site name metadata
cy.get('head meta[property="og:site_name"]').should('have.attr', 'content', expectedSiteName);
})
it("doesn't contain breadcrumbs for top concepts", () => {
cy.visit('/yso/en/page/p4762') // go to "objects" concept page

Expand Down
8 changes: 8 additions & 0 deletions tests/cypress/template/error.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ describe('Error page', () => {
cy.get('head meta[name="title"]').should('have.attr', 'content', expectedTitle);
cy.get('head meta[property="og:title"]').should('have.attr', 'content', expectedTitle);
})
it('Contains site name metadata', () => {
// go to a non-existing page
cy.visit('/404', {failOnStatusCode: false})

const expectedSiteName = 'Skosmos being tested'
// check that the page has site name metadata
cy.get('head meta[property="og:site_name"]').should('have.attr', 'content', expectedSiteName);
})
it('Contains 404 error code', () => {
// check that HTTP code is 404 when accessing a non-existing page
cy.request({url: '/404', failOnStatusCode: false}).its('status').should('equal', 404)
Expand Down
16 changes: 16 additions & 0 deletions tests/cypress/template/feedback.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ describe('Feedback page', () => {
cy.get('head meta[name="description"]').should('have.attr', 'content', expectedDescription);
cy.get('head meta[property="og:description"]').should('have.attr', 'content', expectedDescription);
})
it('Contains site name metadata', () => {
// go to the general feedback page
cy.visit('/en/feedback')

const expectedSiteName = 'Skosmos being tested'
// check that the page has site name metadata
cy.get('head meta[property="og:site_name"]').should('have.attr', 'content', expectedSiteName);
})
it('Sends feedback', () => {
// go to the general feedback page
cy.visit('/en/feedback')
Expand Down Expand Up @@ -75,6 +83,14 @@ describe('Vocab feedback page', () => {
cy.get('head meta[name="description"]').should('have.attr', 'content', expectedDescription);
cy.get('head meta[property="og:description"]').should('have.attr', 'content', expectedDescription);
})
it('Contains site name metadata', () => {
// go to test vocab feedback page
cy.visit('/test/en/feedback')

const expectedSiteName = 'Skosmos being tested'
// check that the page has site name metadata
cy.get('head meta[property="og:site_name"]').should('have.attr', 'content', expectedSiteName);
})
it('Displays correct vocab option', () => {
// go to test vocab feedback page
cy.visit('/test/en/feedback')
Expand Down
8 changes: 8 additions & 0 deletions tests/cypress/template/landing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ describe('Landing page', () => {
cy.get('head meta[name="description"]').should('have.attr', 'content', expectedDescription);
cy.get('head meta[property="og:description"]').should('have.attr', 'content', expectedDescription);
})
it('Contains site name metadata', () => {
// go to the Skosmos front page
cy.visit('/')

const expectedSiteName = 'Skosmos being tested'
// check that the page has site name metadata
cy.get('head meta[property="og:site_name"]').should('have.attr', 'content', expectedSiteName);
})
it('links to vocabulary home', () => {
// go to the Skosmos front page
cy.visit('/')
Expand Down
7 changes: 7 additions & 0 deletions tests/cypress/template/vocab-home.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ describe('Vocabulary home page', () => {
cy.get('head meta[name="description"]').should('have.attr', 'content', expectedDescription);
cy.get('head meta[property="og:description"]').should('have.attr', 'content', expectedDescription);
})
it('Contains site name metadata', () => {
cy.visit('/test/en') // go to the "Test ontology" home page

const expectedSiteName = 'Skosmos being tested'
// check that the page has site name metadata
cy.get('head meta[property="og:site_name"]').should('have.attr', 'content', expectedSiteName);
})
it('contains vocabulary title', () => {
cy.visit('/test/en') // go to the "Test ontology" home page

Expand Down
7 changes: 7 additions & 0 deletions tests/cypress/template/vocab-search.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ describe('Vocabulary search page', () => {
cy.get('head meta[name="title"]').should('have.attr', 'content', expectedTitle);
cy.get('head meta[property="og:title"]').should('have.attr', 'content', expectedTitle);
})
it('Contains site name metadata', () => {
cy.visit(`/${vocab}/en/search?clang=en&q=${term}`)

const expectedSiteName = 'Skosmos being tested'
// check that the page has site name metadata
cy.get('head meta[property="og:site_name"]').should('have.attr', 'content', expectedSiteName);
})
it('Contains correct amount of search results ', () => {
const count = 1;
const searchCountTitle = `${count} results for \'${term}\'`;
Expand Down

0 comments on commit 3f4d7b1

Please sign in to comment.