From 636f9da11c6f71ceb1d7e8c35206eef40aef6c8e Mon Sep 17 00:00:00 2001 From: Pierre Date: Tue, 2 Jan 2024 17:16:00 -0300 Subject: [PATCH] added test for oauth button --- .../tests/e2e/fixtures/inject-initial-data.ts | 4 +++ apps/meteor/tests/e2e/oauth.spec.ts | 26 +++++++++++++++++++ apps/meteor/tests/e2e/page-objects/auth.ts | 4 +++ 3 files changed, 34 insertions(+) create mode 100644 apps/meteor/tests/e2e/oauth.spec.ts diff --git a/apps/meteor/tests/e2e/fixtures/inject-initial-data.ts b/apps/meteor/tests/e2e/fixtures/inject-initial-data.ts index a0590106dfd9..e7e68790cf3d 100644 --- a/apps/meteor/tests/e2e/fixtures/inject-initial-data.ts +++ b/apps/meteor/tests/e2e/fixtures/inject-initial-data.ts @@ -73,6 +73,10 @@ export default async function injectInitialData() { _id: 'SAML_Custom_Default_idp_slo_redirect_url', value: 'http://localhost:8080/simplesaml/saml2/idp/SingleLogoutService.php', }, + { + _id: 'Accounts_OAuth_Google', + value: false, + }, ].map((setting) => connection .db() diff --git a/apps/meteor/tests/e2e/oauth.spec.ts b/apps/meteor/tests/e2e/oauth.spec.ts new file mode 100644 index 000000000000..86fe98759d75 --- /dev/null +++ b/apps/meteor/tests/e2e/oauth.spec.ts @@ -0,0 +1,26 @@ +import { Registration } from './page-objects'; +import { setSettingValueById } from './utils/setSettingValueById'; +import { test, expect } from './utils/test'; + +test.describe('OAuth', () => { + let poRegistration: Registration; + + test.beforeEach(async ({ page }) => { + poRegistration = new Registration(page); + + await page.goto('/home'); + }); + + test('Login Page', async ({ api }) => { + await test.step('expect OAuth button to be visible', async () => { + await expect((await setSettingValueById(api, 'Accounts_OAuth_Google', true)).status()).toBe(200); + await expect(poRegistration.btnLoginWithGoogle).toBeVisible({ timeout: 10000 }); + }); + + // await test.step('expect OAuth button to not be visible', async () => { + // await expect((await setSettingValueById(api, 'Accounts_OAuth_Google', false)).status()).toBe(200); + + // await expect(poRegistration.btnLoginWithGoogle).not.toBeVisible(); + // }); + }); +}); diff --git a/apps/meteor/tests/e2e/page-objects/auth.ts b/apps/meteor/tests/e2e/page-objects/auth.ts index ce80c1795e05..98421f6461ab 100644 --- a/apps/meteor/tests/e2e/page-objects/auth.ts +++ b/apps/meteor/tests/e2e/page-objects/auth.ts @@ -24,6 +24,10 @@ export class Registration { return this.page.locator('role=button[name="SAML"]'); } + get btnLoginWithGoogle(): Locator { + return this.page.locator('role=button[name="Sign in with Google"]'); + } + get goToRegister(): Locator { return this.page.locator('role=link[name="Create an account"]'); }