sfbrigade / bats-server

Routed is an app to help ambulances direct non-critical patients to hospital emergency rooms with the most availability.
https://routedapp.org/
GNU Affero General Public License v3.0
18 stars 11 forks source link

Write E2E tests for 2FA #304

Closed ap247 closed 11 months ago

Code4Dopamine commented 12 months ago

Source: https://stackoverflow.com/questions/68000771/run-grouped-tests-sequentially-using-playwright image

Seems like the method above allows Playwright to test "sequentially", which should avoid the race timing issue when testing 2FA via email.

ddrosario commented 12 months ago

Just to add the tests work after adding the following to home.spec.js

test.describe('home', () => {
  test.describe.configure({ mode: 'serial' });
  test('shows the Routed logo and sign in form', async ({ page }) => {
    await page.goto('/');

and twoFA.spec.js

test.describe('home', () => { // Must be run as last test so that last email contains correct authorization code
    test.describe.configure({ mode: 'serial' });
    test('logs in as EMS user with 2FA', async ({ context }) => {
        const appPage = await context.newPage();