diff --git a/cypress.config.js b/cypress.config.js new file mode 100644 index 0000000..97f47c4 --- /dev/null +++ b/cypress.config.js @@ -0,0 +1,9 @@ +const { defineConfig } = require("cypress"); + +module.exports = defineConfig({ + e2e: { + setupNodeEvents(on, config) { + // implement node event listeners here + }, + }, +}); diff --git a/cypress/downloads/downloads.html b/cypress/downloads/downloads.html new file mode 100644 index 0000000..fd033a6 Binary files /dev/null and b/cypress/downloads/downloads.html differ diff --git a/cypress/e2e/spec.cy.js b/cypress/e2e/spec.cy.js new file mode 100644 index 0000000..53061a2 --- /dev/null +++ b/cypress/e2e/spec.cy.js @@ -0,0 +1,62 @@ +context('SACDS', () => { + beforeEach(() => { + cy.visit('http://localhost:3000/') + }) + + describe('Page display', () => { + + it('Displays Incommon logo', () => { + cy.get('img') + .should('be.visible') + .should('have.class', 'logo') + }) + + it('Displays information text', () => { + + }) + + it('Displays Seamless Action button on page', () => { + cy.get('a.sa-button') + .should('be.visible') + .and('have.attr', 'href') + .then((hrefAttribute) => { + // Extract entityID and returnUrl from the href attribute + const urlParams = new URLSearchParams(hrefAttribute); + const entityID = urlParams.get('entityID'); + const returnUrl = urlParams.get('return'); + + // Assert that entityID and returnUrl are present and not empty + expect(entityID).to.be.a('string').and.not.empty; + expect(returnUrl).to.be.a('string').and.not.empty; + + cy.get('.sa-button-logo').should('be.visible'); + cy.get('.sa-button-text').should('be.visible').and('contain.text', 'Access through your institution'); + }); + }) + + it('Hides SA button and displays error message and wiki link if entityID or returnUrl are missing', () => { + cy.get('.sa-button').should('not.exist'); + cy.get('h1').should('be.visible').and('contain.text', 'Both Entity ID and return URL are required.'); + cy.get('p a') + .should('be.visible') + .and('have.attr', 'href', 'LINK_FROM_I2'); + cy.get('p a').should('contain.text', 'Click Here for more information.'); + }) + + }) + + describe('SA button functionality', () => { + + it('Takes in entityID and returnUrl from URL and feeds to SA button', () => { + + }) + + it('Routes user to their entity after clicking SA button', () => { + + }) + + }) +}) + + + diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json new file mode 100644 index 0000000..02e4254 --- /dev/null +++ b/cypress/fixtures/example.json @@ -0,0 +1,5 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io", + "body": "Fixtures are a great way to mock data for responses to routes" +} diff --git a/cypress/support/commands.js b/cypress/support/commands.js new file mode 100644 index 0000000..66ea16e --- /dev/null +++ b/cypress/support/commands.js @@ -0,0 +1,25 @@ +// *********************************************** +// This example commands.js shows you how to +// create various custom commands and overwrite +// existing commands. +// +// For more comprehensive examples of custom +// commands please read more here: +// https://on.cypress.io/custom-commands +// *********************************************** +// +// +// -- This is a parent command -- +// Cypress.Commands.add('login', (email, password) => { ... }) +// +// +// -- This is a child command -- +// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) +// +// +// -- This is a dual command -- +// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) +// +// +// -- This will overwrite an existing command -- +// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) \ No newline at end of file diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js new file mode 100644 index 0000000..0e7290a --- /dev/null +++ b/cypress/support/e2e.js @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/e2e.js is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.js using ES2015 syntax: +import './commands' + +// Alternatively you can use CommonJS syntax: +// require('./commands') \ No newline at end of file diff --git a/public/favicon.ico b/public/favicon.ico index a11777c..09ba2c3 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/src/App.js b/src/App.js index 4743900..a39bbee 100644 --- a/src/App.js +++ b/src/App.js @@ -33,17 +33,17 @@ function App() { setReturnUrl(returnUrlParam); } - console.log('IDs', entityID, returnUrl) + console.log('IDs', entityIdParam, returnUrlParam) }, []); return (
InCommon-Logo - {!error ? ( + {error ? ( <>

{error}

-

Click Here for more information.

+

Click Here for more information.

) : ( <>