-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
2,328 additions
and
1,448 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const { recurse } = require('cypress-recurse') | ||
import { failedAccountMetadata } from '/cypress/mocks/handlers' | ||
|
||
describe('Measurement Page Tests', () => { | ||
|
||
|
@@ -315,40 +315,25 @@ describe('Measurement Page Tests', () => { | |
}) | ||
|
||
describe('User Feedback', () => { | ||
let userEmail | ||
|
||
before(() => { | ||
cy.clearLocalStorage() | ||
cy.intercept('GET', 'https://ams-pg-test.ooni.org/api/v1/user_login*').as('userLogin') | ||
// get and check the test email only once before the tests | ||
cy.task('getUserEmail').then((email) => { | ||
expect(email).to.be.a('string') | ||
userEmail = email | ||
}) | ||
}) | ||
|
||
it('can login and submit feedback', () => { | ||
it('can login', () => { | ||
cy.interceptRequest(failedAccountMetadata) | ||
|
||
const measurementUrl = '/m/20230307142542.625294_US_webconnectivity_9215f30cf2412f49' | ||
cy.visit(measurementUrl) | ||
cy.findByText('VERIFY').click() | ||
|
||
cy.findByRole('textbox').click().type(userEmail) | ||
cy.findByRole('textbox').click().type('[email protected]') | ||
cy.findByText('Login').click() | ||
cy.findByText('Login link sent') | ||
}) | ||
|
||
|
||
recurse( | ||
() => cy.task('getLastEmail'), // Cypress commands to retry | ||
Cypress._.isObject, // keep retrying until the task returns an object | ||
{ | ||
timeout: 60000, // retry up to 1 minute | ||
delay: 5000, // wait 5 seconds between attempts | ||
}, | ||
).then(({ loginLink }) => { | ||
cy.visit(loginLink) | ||
}) | ||
|
||
cy.url().should('contain', '/login') | ||
cy.wait('@userLogin') | ||
it('can submit feedback', () => { | ||
const measurementUrl = '/m/20230307142542.625294_US_webconnectivity_9215f30cf2412f49' | ||
|
||
cy.visit(measurementUrl) | ||
cy.findByText('VERIFY').click() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { rest } from 'msw' | ||
|
||
const apiBase = Cypress.env('apiUrl') | ||
|
||
export const handlers = [ | ||
rest.get(`${apiBase}/api/_/account_metadata`, (req, res, ctx) => { | ||
return res( | ||
ctx.status(200), | ||
ctx.json({ | ||
logged_in: true, | ||
role: 'admin', | ||
}), | ||
) | ||
}), | ||
|
||
rest.post(`${apiBase}/api/v1/user_register`, (req, res, ctx) => { | ||
return res( | ||
ctx.status(200), | ||
ctx.json({ | ||
role: 'admin', | ||
}), | ||
) | ||
}), | ||
|
||
rest.get(`${apiBase}/api/v1/user_login`, (req, res, ctx) => { | ||
return res( | ||
ctx.status(200), | ||
ctx.json({ | ||
bearer: 'abc123', | ||
redirect_to: 'https://explorer.org/' | ||
}), | ||
) | ||
}), | ||
|
||
rest.post(`${apiBase}/api/_/measurement_feedback`, (req, res, ctx) => { | ||
return res( | ||
ctx.status(200), | ||
ctx.json({ | ||
}), | ||
) | ||
}), | ||
] | ||
|
||
export const failedAccountMetadata = rest.get('https://ams-pg-test.ooni.org/api/_/account_metadata', (req, res, ctx) => { | ||
return res( | ||
ctx.status(401), | ||
) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
import { setupWorker, rest} from 'msw' | ||
import { handlers } from '/cypress/mocks/handlers' | ||
|
||
let worker | ||
|
||
before(() => { | ||
worker = setupWorker(...handlers) | ||
cy.wrap(worker.start({ onUnhandledRequest: 'bypass' }), { log: false }) | ||
}) | ||
Cypress.on('test:before:run', () => { | ||
if (!worker) return | ||
worker.resetHandlers() | ||
}) | ||
|
||
Cypress.Commands.add('interceptRequest', (...params) => { | ||
worker.use(...params) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
4f94cc2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
explorer – ./
explorer-one.vercel.app
explorer-ooni1.vercel.app
explorer-git-master-ooni1.vercel.app