diff --git a/cypress/downloads/downloads.html b/cypress/downloads/downloads.html deleted file mode 100644 index fd033a6..0000000 Binary files a/cypress/downloads/downloads.html and /dev/null differ diff --git a/cypress/e2e/spec.cy.js b/cypress/e2e/spec.cy.js index 53061a2..5950cf2 100644 --- a/cypress/e2e/spec.cy.js +++ b/cypress/e2e/spec.cy.js @@ -11,26 +11,47 @@ context('SACDS', () => { .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'); + it('Displays information links', () => { + cy.get('#menu').should('be.visible'); - // 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; + // Check each link within the menu + cy.get('#menu a').each(($link) => { + cy.wrap($link).should('have.attr', 'target', '_blank'); // Check if the link opens in a new tab + }); + + // Check the specific attributes of the second and third links + cy.get('#menu a').eq(1).should('have.attr', 'href', 'https://internet2.edu/community/about-us/policies/privacy/').and('have.class', 'last'); + cy.get('#menu a').eq(2).should('have.attr', 'href', 'https://incommon.org/help/').and('have.class', 'last'); + }); + + it('Displays copyright text', () => { + cy.contains('© Copyright 2020, InCommon, LLC').should('be.visible'); + }); - cy.get('.sa-button-logo').should('be.visible'); - cy.get('.sa-button-text').should('be.visible').and('contain.text', 'Access through your institution'); + + it('Displays Seamless Action button on page', () => { + cy.fixture('testData').then((testData) => { + const { entityID, returnUrl, error } = testData; + + // Visit the page with mock data as query parameters + cy.visit(`http://localhost:3000/?entityID=${entityID}&return=${returnUrl}`); + cy.get('a.sa-button') + .should('be.visible') + .and('have.attr', 'href') + .then((hrefAttribute) => { + // Extract entityID and returnUrl from the href attribute + const hrefParams = new URLSearchParams(hrefAttribute); + const extractedEntityID = hrefParams.get('entityID'); + const extractedReturnUrl = hrefParams.get('returnUrl'); + + // Assert that entityID and returnUrl are present and not empty + // expect(extractedEntityID).to.be.a('string').and.not.empty; + // expect(extractedReturnUrl).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'); + }); }); }) @@ -40,21 +61,30 @@ context('SACDS', () => { 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.'); + cy.get('p a').should('contain.text', 'Click Here'); }) - }) 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', () => { - + cy.fixture('testData').then((testData) => { + const { entityID, returnUrl, error } = testData; + + // Visit the page with mock data as query parameters + cy.visit(`http://localhost:3000/?entityID=${entityID}&return=${returnUrl}`); + + // Check if the SA button is visible + cy.get('.sa-button').should('be.visible'); + + // Check if the Seamless Access button's href attribute contains the correct entityID and returnUrl + cy.get('.sa-button').should( + 'have.attr', + 'href', + `https://service.seamlessaccess.org/ds/?entityID=${entityID}&return=${returnUrl}` + ); + }); }) - }) }) diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json deleted file mode 100644 index 02e4254..0000000 --- a/cypress/fixtures/example.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "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/fixtures/testData.json b/cypress/fixtures/testData.json new file mode 100644 index 0000000..f5da5bb --- /dev/null +++ b/cypress/fixtures/testData.json @@ -0,0 +1,5 @@ +{ + "entityID": "123", + "returnUrl": "http://mockReturnURL.com", + "error": "Both Entity ID and return URL are required." +} diff --git a/src/App.js b/src/App.js index a39bbee..ee125e4 100644 --- a/src/App.js +++ b/src/App.js @@ -25,38 +25,44 @@ function App() { const returnUrlParam = queryParams.return || ''; if (!entityIdParam || !returnUrlParam) { - // Handle missing parameters setError('Both Entity ID and return URL are required.'); } else { - // Set parameters if available setEntityID(entityIdParam); setReturnUrl(returnUrlParam); } - - console.log('IDs', entityIdParam, returnUrlParam) }, []); return ( -
Click Here for more information.
- > - ) : ( - <> - -Click Here for more information.
+ > + ) : ( + <> + +© Copyright 2020, InCommon, LLC | incommon.org | InCommon: Identity and Access for Research and Education
+