From 6c86ce70c0223f48e664d1eb29f105416c24a552 Mon Sep 17 00:00:00 2001 From: mansisampat Date: Tue, 29 Oct 2024 11:51:05 +0530 Subject: [PATCH] Add afterEach method and apply formatting to the hosting links integration test --- .../integration/flows/hosting_link.test.ts | 99 +++++++++---------- 1 file changed, 45 insertions(+), 54 deletions(-) diff --git a/packages/auth/test/integration/flows/hosting_link.test.ts b/packages/auth/test/integration/flows/hosting_link.test.ts index 6d3c0ac3dcd..0c2d69402e4 100644 --- a/packages/auth/test/integration/flows/hosting_link.test.ts +++ b/packages/auth/test/integration/flows/hosting_link.test.ts @@ -16,9 +16,14 @@ */ // eslint-disable-next-line import/no-extraneous-dependencies -import { ActionCodeSettings, Auth, sendSignInLinkToEmail } from '@firebase/auth'; +import { + ActionCodeSettings, + Auth, + sendSignInLinkToEmail +} from '@firebase/auth'; import { expect, use } from 'chai'; import { + cleanUpTestInstance, getTestInstance, randomEmail } from '../../helpers/integration/helpers'; @@ -33,16 +38,16 @@ describe('Integration test: hosting link validation', () => { let auth: Auth; let email: string; - const AUTHORIZED_CUSTOM_DOMAIN = "localhost/action_code_return"; - const ANDROID_PACKAGE_NAME = "com.google.firebase.test.thin"; + const AUTHORIZED_CUSTOM_DOMAIN = 'localhost/action_code_return'; + const ANDROID_PACKAGE_NAME = 'com.google.firebase.test.thin'; const BASE_SETTINGS: ActionCodeSettings = { url: 'http://' + AUTHORIZED_CUSTOM_DOMAIN, handleCodeInApp: true, - android: {packageName: ANDROID_PACKAGE_NAME}, + android: { packageName: ANDROID_PACKAGE_NAME } }; - const VALID_LINK_DOMAIN = "jscore-sandbox.testdomaindonotuse.com"; - const INVALID_LINK_DOMAIN = "invalid.testdomaindonotuse.com"; - const INVALID_LINK_DOMAIN_ERROR = "auth/invalid-hosting-link-domain"; + const VALID_LINK_DOMAIN = 'jscore-sandbox.testdomaindonotuse.com'; + const INVALID_LINK_DOMAIN = 'invalid.testdomaindonotuse.com'; + const INVALID_LINK_DOMAIN_ERROR = 'auth/invalid-hosting-link-domain'; const TEST_TENANT_ID = 'passpol-tenant-d7hha'; beforeEach(function () { @@ -53,63 +58,49 @@ describe('Integration test: hosting link validation', () => { this.skip(); } }); - + + afterEach(async () => { + await cleanUpTestInstance(auth); + }); + it('allows user to sign in with default firebase hosting link', async () => { // Sends email link to user using default hosting link. - await sendSignInLinkToEmail( - auth, - email, - BASE_SETTINGS - ); + await sendSignInLinkToEmail(auth, email, BASE_SETTINGS); }); it('allows user to sign in to a tenant with default firebase hosting link', async () => { auth.tenantId = TEST_TENANT_ID; // Sends email link to user using default hosting link. - await sendSignInLinkToEmail( - auth, - email, - BASE_SETTINGS - ); + await sendSignInLinkToEmail(auth, email, BASE_SETTINGS); }); it('allows user to sign in with custom firebase hosting link', async () => { - // Sends email link to user using custom hosting link. - await sendSignInLinkToEmail( - auth, - email, - { - ...BASE_SETTINGS, - linkDomain: VALID_LINK_DOMAIN - - } - ); - }); + // Sends email link to user using custom hosting link. + await sendSignInLinkToEmail(auth, email, { + ...BASE_SETTINGS, + linkDomain: VALID_LINK_DOMAIN + }); + }); - it('allows user to sign in to a tenant with custom firebase hosting link', async () => { - // Sends email link to user using custom hosting link. - auth.tenantId = TEST_TENANT_ID; - await sendSignInLinkToEmail( - auth, - email, - { - ...BASE_SETTINGS, - linkDomain: VALID_LINK_DOMAIN - - } - ); - }); + it('allows user to sign in to a tenant with custom firebase hosting link', async () => { + // Sends email link to user using custom hosting link. + auth.tenantId = TEST_TENANT_ID; + await sendSignInLinkToEmail(auth, email, { + ...BASE_SETTINGS, + linkDomain: VALID_LINK_DOMAIN + }); + }); - it('sign in with invalid firebase hosting link throws exception', async () => { - // Throws an exception while sening email link to user using invalid hosting link. - await expect(sendSignInLinkToEmail( - auth, - email, - { - ...BASE_SETTINGS, - linkDomain: INVALID_LINK_DOMAIN - - } - )).to.be.rejectedWith(FirebaseError, new RegExp(".*" + INVALID_LINK_DOMAIN_ERROR + ".*")); - }); + it('sign in with invalid firebase hosting link throws exception', async () => { + // Throws an exception while sening email link to user using invalid hosting link. + await expect( + sendSignInLinkToEmail(auth, email, { + ...BASE_SETTINGS, + linkDomain: INVALID_LINK_DOMAIN + }) + ).to.be.rejectedWith( + FirebaseError, + new RegExp('.*' + INVALID_LINK_DOMAIN_ERROR + '.*') + ); + }); });