diff --git a/compose/neurosynth-frontend/cypress/e2e/pages/AuthenticatedLandingPage.cy.tsx b/compose/neurosynth-frontend/cypress/e2e/pages/AuthenticatedLandingPage.cy.tsx
deleted file mode 100644
index 8cf127438..000000000
--- a/compose/neurosynth-frontend/cypress/e2e/pages/AuthenticatedLandingPage.cy.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-///
-
-export {};
-
-const PATH = '/';
-const PAGE_NAME = 'AuthenticatedLandingPage';
-
-describe(PAGE_NAME, () => {
- beforeEach(() => {
- cy.clearLocalStorage().clearSessionStorage();
- cy.intercept('GET', 'https://api.appzi.io/**', { fixture: 'appzi' }).as('appziFixture');
- });
-
- it('should load successfully', () => {
- cy.login('real');
- });
-
- // describe('Tour ', () => {
- // it('should open immediately if it is the users first time logging in', () => {
- // cy.login('mocked', { 'https://neurosynth-compose/loginsCount': 1 })
- // .get('.reactour__popover')
- // .should('exist')
- // .and('be.visible');
- // });
-
- // it('should not open immediately if not authenticated', () => {
- // cy.visit(PATH).get('.reactour__popover').should('not.exist');
- // });
-
- // it('should not open immediately if it is not the first time logging in', () => {
- // cy.login('mocked', { 'https://neurosynth-compose/loginsCount': 2 })
- // .get('.reactour__popover')
- // .should('not.exist');
- // });
-
- // it('should open when the button is clicked', () => {
- // cy.login('mocked', { 'https://neurosynth-compose/loginsCount': 2 })
- // .get('[data-testid="HelpIcon"]')
- // .click()
- // .get('.reactour__popover')
- // .should('exist')
- // .and('be.visible');
- // });
-
- // it('should not open if its the first time logging in but the page has been seen already', () => {
- // cy.login('mocked', { 'https://neurosynth-compose/loginsCount': 1 })
- // .get('body')
- // .click(0, 0)
- // .then((_res) => {
- // localStorage.setItem(`hasSeen${PAGE_NAME}`, 'true');
- // })
- // .visit('/')
- // .get('.reactour__popover')
- // .should('not.exist');
- // });
-
- // it('should close when clicked out', () => {
- // // 1. ARRANGE
- // cy.login('mocked', { 'https://neurosynth-compose/loginsCount': 2 })
- // .get('[data-testid="HelpIcon"]')
- // .click()
- // .get('body')
- // .click(0, 0)
- // .get('.reactour__popover')
- // .should('not.exist');
- // });
-
- // it('should close when the close button is clicked', () => {
- // cy.login('mocked', { 'https://neurosynth-compose/loginsCount': 2 })
- // .get('[data-testid="HelpIcon"]')
- // .click()
- // .get('[aria-label="Close Tour"]')
- // .click()
- // .get('.reactour__popover')
- // .should('not.exist');
- // });
- // });
-});
diff --git a/compose/neurosynth-frontend/cypress/e2e/pages/LandingPage.cy.tsx b/compose/neurosynth-frontend/cypress/e2e/pages/LandingPage.cy.tsx
index 0d4ccdb5a..ecaf748a0 100644
--- a/compose/neurosynth-frontend/cypress/e2e/pages/LandingPage.cy.tsx
+++ b/compose/neurosynth-frontend/cypress/e2e/pages/LandingPage.cy.tsx
@@ -7,10 +7,24 @@ const PAGE_NAME = 'LandingPage';
describe(PAGE_NAME, () => {
beforeEach(() => {
cy.intercept('GET', 'https://api.appzi.io/**', { fixture: 'appzi' }).as('appziFixture');
+ cy.intercept('GET', `**/api/base-studies/**`, { fixture: 'baseStudies' }).as(
+ 'baseStudiesFixture'
+ );
+ cy.intercept('GET', `**/api/points/**`, { fixture: 'points' }).as('pointsFixture');
});
it('should load successfully', () => {
- cy.visit('/');
+ cy.visit('/').wait('@baseStudiesFixture').wait('@pointsFixture');
+ });
+
+ it('should authenticate for real and redirect to projects page', () => {
+ cy.login('real').visit('/');
+ cy.contains('Projects');
+ });
+
+ it('should authenticate and redirect to the projects page', () => {
+ cy.login('mocked').visit('/');
+ cy.contains('Projects');
});
it('should change the viewport property', () => {
diff --git a/compose/neurosynth-frontend/cypress/e2e/pages/NotFound.cy.tsx b/compose/neurosynth-frontend/cypress/e2e/pages/NotFound.cy.tsx
index a66db92d4..7d77b2426 100644
--- a/compose/neurosynth-frontend/cypress/e2e/pages/NotFound.cy.tsx
+++ b/compose/neurosynth-frontend/cypress/e2e/pages/NotFound.cy.tsx
@@ -9,38 +9,4 @@ describe('NotFoundPage', () => {
cy.visit('/page-that-doesnt-exist');
cy.contains('Requested resource not found');
});
-
- // it('should route the non existent studyset resource to the not found page', () => {
- // cy.intercept('GET', '**/api/studysets/*', { statusCode: 404 }).as('studysetsRequestError');
- // cy.intercept('GET', '**/api/annotations/*', { statusCode: 404 }).as(
- // 'annotationsRequestError'
- // );
-
- // cy.visit('/studysets/studyset-that-doesnt-exist')
- // .wait(['@studysetsRequestError', '@annotationsRequestError'])
- // .get('body')
- // .contains('Requested resource not found');
- // });
-
- // it('should route the non existent meta-analysis resource to the not found page', () => {
- // cy.intercept('GET', '**/api/meta-analyses/**', { statusCode: 404 }).as(
- // 'metaAnalysisRequestError'
- // );
-
- // cy.visit('/meta-analyses/meta-analysis-that-doesnt-exist')
- // .wait(['@metaAnalysisRequestError'])
- // .get('body')
- // .contains('Requested resource not found');
- // });
-
- // it('should route the non existent annotation resource to the not found page', () => {
- // cy.intercept('GET', '**/api/annotations/*', {
- // statusCode: 404,
- // }).as('annotationRequestError');
-
- // cy.visit('/annotations/annotation-doesnt-exist')
- // .wait(['@annotationRequestError'])
- // .get('body')
- // .contains('Requested resource not found');
- // });
});
diff --git a/compose/neurosynth-frontend/cypress/fixtures/baseStudies.json b/compose/neurosynth-frontend/cypress/fixtures/baseStudies.json
new file mode 100644
index 000000000..7dfbd7db4
--- /dev/null
+++ b/compose/neurosynth-frontend/cypress/fixtures/baseStudies.json
@@ -0,0 +1,5 @@
+{
+ "metadata": {
+ "total_count": 100
+ }
+}
\ No newline at end of file
diff --git a/compose/neurosynth-frontend/cypress/fixtures/points.json b/compose/neurosynth-frontend/cypress/fixtures/points.json
new file mode 100644
index 000000000..7dfbd7db4
--- /dev/null
+++ b/compose/neurosynth-frontend/cypress/fixtures/points.json
@@ -0,0 +1,5 @@
+{
+ "metadata": {
+ "total_count": 100
+ }
+}
\ No newline at end of file
diff --git a/compose/neurosynth-frontend/cypress/support/commands.ts b/compose/neurosynth-frontend/cypress/support/commands.ts
index 44d445bea..5270630cc 100644
--- a/compose/neurosynth-frontend/cypress/support/commands.ts
+++ b/compose/neurosynth-frontend/cypress/support/commands.ts
@@ -10,34 +10,6 @@ import * as jose from 'jose';
// 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) => { ... })
-//
-// declare global {
-// namespace Cypress {
-// interface Chainable {
-// login(email: string, password: string): Chainable
-// drag(subject: string, options?: Partial): Chainable
-// dismiss(subject: string, options?: Partial): Chainable
-// visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable
-// }
-// }
-// }
-
const constructMockAuthJWT = async (jwtPayload = {}): Promise => {
const jwt = await new jose.SignJWT({ ...jwtPayload })
.setProtectedHeader({ alg: 'HS256' })
@@ -51,6 +23,7 @@ const createMockRequest = async (
audience: string,
client_id: string,
domain: string,
+ scope: string,
extraClaims = {}
) => {
const access_token = await constructMockAuthJWT({
@@ -60,7 +33,7 @@ const createMockRequest = async (
iat: 1659719697,
exp: 1659806097,
azp: 'EmcOFhu0XAINM4EyslaKpZ3u09QlBvef',
- scope: 'openid profile email',
+ scope: scope,
});
const id_token = await constructMockAuthJWT({
@@ -85,7 +58,7 @@ const createMockRequest = async (
access_token: access_token,
expires_in: 86400,
id_token: id_token,
- scope: 'openid profile email read:current_user update:current_user_metadata delete:current_user_metadata create:current_user_metadata create:current_user_device_credentials delete:current_user_device_credentials update:current_user_identities',
+ scope: scope,
token_type: 'Bearer',
},
};
@@ -99,12 +72,14 @@ Cypress.Commands.add('login', (loginMode = 'mocked', extraClaims = {}) => {
const password = Cypress.env('auth0Password');
const domain = Cypress.env('auth0Domain');
+ const scope = 'openid profile email offline_access';
+
/**
* To prevent rate limiting errors form auth0, we stub our own request func and return a mocked response
*/
if (loginMode === 'mocked') {
cy.stub(cy, 'request').callsFake(() =>
- cy.wrap(createMockRequest(audience, client_id, domain, extraClaims))
+ cy.wrap(createMockRequest(audience, client_id, domain, scope, extraClaims))
);
}
@@ -121,7 +96,7 @@ Cypress.Commands.add('login', (loginMode = 'mocked', extraClaims = {}) => {
username,
password,
audience,
- scope: 'openid profile email',
+ scope,
client_id,
client_secret,
},
@@ -153,7 +128,7 @@ Cypress.Commands.add('login', (loginMode = 'mocked', extraClaims = {}) => {
},
expires_in,
id_token,
- scope: 'openid profile email read:current_user update:current_user_metadata delete:current_user_metadata create:current_user_metadata create:current_user_device_credentials delete:current_user_device_credentials update:current_user_identities',
+ scope,
token_type: 'Bearer',
},
expiresAt: Math.floor(Date.now() / 1000) + expires_in,
@@ -165,13 +140,10 @@ Cypress.Commands.add('login', (loginMode = 'mocked', extraClaims = {}) => {
* the isAuthenticated state. This code is in tandem with setting the auth0 provider cacheLocation=localstorage.
*/
cy.addToLocalStorage(
- `@@auth0spajs@@::${client_id}::${audience}::openid profile email`,
+ `@@auth0spajs@@::${client_id}::${audience}::${scope}`,
JSON.stringify(session)
);
});
-
- // this will always run after the previous commands are complete
- cy.visit('/');
});
Cypress.Commands.add('clearSessionStorage', () => {
@@ -192,7 +164,6 @@ declare global {
namespace Cypress {
interface Chainable {
login(loginMode: 'real' | 'mocked', extraClaims?: any): Chainable;
- mockLogin(extraClaims?: any): Chainable;
clearSessionStorage(): Chainable;
addToLocalStorage(key: string, value: string): Chainable;
}
diff --git a/compose/neurosynth-frontend/package.json b/compose/neurosynth-frontend/package.json
index 931295693..8f7ae6624 100644
--- a/compose/neurosynth-frontend/package.json
+++ b/compose/neurosynth-frontend/package.json
@@ -59,7 +59,7 @@
"test-with-coverage": "npm run test -- --coverage --watchAll=false",
"cy:e2e-headless": "cypress run",
"cy:e2e-headless-local": "env-cmd -f .env.dev cypress run",
- "cy:e2e-browser": "env-cmd -f .env.dev cypress open -b chrome --e2e",
+ "cy:e2e-browser": "env-cmd -f .env.staging cypress open -b chrome --e2e",
"cy:install": "cypress install",
"cy:ci": "start-server-and-test start-ci:dev 3000 cy:e2e-headless",
"eject": "react-scripts eject"
diff --git a/compose/neurosynth-frontend/src/components/Dialogs/ConfirmationDialog/ConfirmationDialog.tsx b/compose/neurosynth-frontend/src/components/Dialogs/ConfirmationDialog/ConfirmationDialog.tsx
index e72ac7c93..3978f7861 100644
--- a/compose/neurosynth-frontend/src/components/Dialogs/ConfirmationDialog/ConfirmationDialog.tsx
+++ b/compose/neurosynth-frontend/src/components/Dialogs/ConfirmationDialog/ConfirmationDialog.tsx
@@ -46,7 +46,7 @@ const ConfirmationDialog: React.FC = (props) => {
{props.dialogMessage && dialogContent}
-
+