Skip to content

Commit

Permalink
cleanup and additional config for specs
Browse files Browse the repository at this point in the history
  • Loading branch information
alishaevn committed Feb 14, 2024
1 parent dfb706c commit 857867d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
10 changes: 6 additions & 4 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
chromeWebSecurity: false,
defaultCommandTimeout: 10000,
setupNodeEvents(on, config) {
config = dotenvFlowPlugin(config)
config.env = {
Expand All @@ -21,12 +22,13 @@ module.exports = defineConfig({
},
},
env: {
TEST_SCIENTIST_USER: '[email protected]',
TEST_SCIENTIST_PW: '!test1234',
NEXT_PUBLIC_PROVIDER_NAME: process.env.NEXT_PUBLIC_PROVIDER_NAME,
CYPRESS_SEARCH_QUERY: 'test',
NEXT_PUBLIC_PROVIDER_ID: process.env.NEXT_PUBLIC_PROVIDER_ID,
NEXT_PUBLIC_PROVIDER_NAME: process.env.NEXT_PUBLIC_PROVIDER_NAME,
NEXT_PUBLIC_TOKEN: process.env.NEXT_PUBLIC_TOKEN,
CYPRESS_SEARCH_QUERY: 'test',
TEST_SCIENTIST_PW: '!test1234',
TEST_SCIENTIST_USER: '[email protected]',
TEST_SESSION_COOKIE: process.env.TEST_SESSION_COOKIE,
},
reporter: 'junit',
reporterOptions: {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/request.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ describe('Viewing one request', () => {
before(() => {
apiCalls['useOneRequest'] = {
...apiCalls['useOneRequest'],
data: undefined,
error: {
body: {
message: 'Quote Group Not Found',
},
statusCode: 404,
},
requestURL: '/quote_groups/fake-uuid.json'
}
})

Expand Down
11 changes: 6 additions & 5 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { scientistApiBaseURL } from './e2e'
// source: https://github.com/nextauthjs/next-auth/discussions/2053#discussioncomment-1191016
Cypress.Commands.add('login', (username, password) => {
cy.session([username, password], () => {
cy.intercept('/api/auth/session', { fixture: 'session.json' }).as('session')
cy.intercept('/api/auth/session', { fixture: 'session.json' }).as('session')

// Set the cookie for cypress.
// It has to be a valid cookie so next-auth can decrypt it and confirm its validity.
// This cookie also may need to be refreshed intermittently if it expires
cy.setCookie('next-auth.session-token', Cypress.env('TEST_SESSION_COOKIE'))
// Set the cookie for cypress.
// It has to be a valid cookie so next-auth can decrypt it and confirm its validity.
// This cookie also may need to be refreshed intermittently if it expires
// TODO(alishaevn): https://github.com/scientist-softserv/webstore/issues/375
cy.setCookie('next-auth.session-token', Cypress.env('TEST_SESSION_COOKIE'))
})
})

Expand Down

0 comments on commit 857867d

Please sign in to comment.