|
| 1 | +import { getRoute } from '@app-builder/utils/routes'; |
| 2 | +import { expect, test } from 'tests/fixtures'; |
| 3 | +import { SignInPage } from 'tests/page-object-models/auth-pages'; |
| 4 | + |
| 5 | +const user = { |
| 6 | + |
| 7 | + password: 'password', |
| 8 | +}; |
| 9 | +// Since we do use the same user email for all tests, we need to run them serially. |
| 10 | +test.describe.configure({ mode: 'serial' }); |
| 11 | + |
| 12 | +test.afterEach(async ({ firebase }) => { |
| 13 | + await firebase.deleteUser(user.email); |
| 14 | +}); |
| 15 | + |
| 16 | +test('Users can sign in with Google', async ({ page, firebase }) => { |
| 17 | + const signInPage = new SignInPage(page); |
| 18 | + await signInPage.goto(); |
| 19 | + const firebasePopup = firebase.popup(page); |
| 20 | + await signInPage.signInWithGoogle(); |
| 21 | + await firebasePopup.signUpWithSSO(user.email); |
| 22 | + |
| 23 | + // Ensure signed in user is redirected to the scenarios page |
| 24 | + await page.waitForURL(getRoute('/scenarios/')); |
| 25 | + await page.getByRole('button').first().click(); |
| 26 | + await expect(page.getByText(user.email)).toBeVisible(); |
| 27 | +}); |
| 28 | + |
| 29 | +test('Users can sign in with Microsoft', async ({ page, firebase }) => { |
| 30 | + const signInPage = new SignInPage(page); |
| 31 | + await signInPage.goto(); |
| 32 | + const firebasePopup = firebase.popup(page); |
| 33 | + await signInPage.signInWithMicrosoft(); |
| 34 | + await firebasePopup.signUpWithSSO(user.email); |
| 35 | + |
| 36 | + // Ensure signed in user is redirected to the scenarios page |
| 37 | + await page.waitForURL(getRoute('/scenarios/')); |
| 38 | + await page.getByRole('button').first().click(); |
| 39 | + await expect(page.getByText(user.email)).toBeVisible(); |
| 40 | +}); |
| 41 | + |
| 42 | +test('Users can sign up with email and password', async ({ |
| 43 | + page, |
| 44 | + firebase, |
| 45 | +}) => { |
| 46 | + const signInPage = new SignInPage(page); |
| 47 | + await signInPage.goto(); |
| 48 | + await page.getByRole('link', { name: 'Sign up' }).click(); |
| 49 | + await page.waitForURL(getRoute('/sign-up')); |
| 50 | + |
| 51 | + await page.getByLabel('Email').fill(user.email); |
| 52 | + await page.getByLabel('Password').fill(user.password); |
| 53 | + await page.getByRole('button', { name: 'Sign up' }).click(); |
| 54 | + |
| 55 | + await page.waitForURL(getRoute('/email-verification')); |
| 56 | + await firebase.verifyUser(user.email); |
| 57 | + await page.getByRole('link', { name: 'Sign in' }).click(); |
| 58 | + await page.waitForURL(getRoute('/sign-in')); |
| 59 | + |
| 60 | + await signInPage.signInWithEmail(user); |
| 61 | + |
| 62 | + // Ensure signed in user is redirected to the scenarios page |
| 63 | + await page.waitForURL(getRoute('/scenarios/')); |
| 64 | + await page.getByRole('button').first().click(); |
| 65 | + await expect(page.getByText(user.email)).toBeVisible(); |
| 66 | +}); |
0 commit comments