test for OAuth login buttons (Google and SAML)

feature/saml-login
Deepak Prabhakara 2022-01-07 19:05:11 +00:00
parent 5fe5bebc27
commit b50f44e441
4 changed files with 30 additions and 37 deletions

View File

@ -23,7 +23,7 @@ GOOGLE_CLIENT_SECRET=
# Enable SAML login using https://github.com/boxyhq/jackson
# SAML_DATABASE_URL="postgresql://postgres:@localhost:5450/cal-saml"
# SAML_ADMINS='onboarding@example.com'
# SAML_ADMINS='pro@example.com'
# @see: https://github.com/calendso/calendso/issues/263
# Required for Vercel hosting - set NEXTAUTH_URL to equal your BASE_URL

View File

@ -21,8 +21,7 @@ jobs:
PAYMENT_FEE_FIXED: 10
GOOGLE_CLIENT_ID: ${{ secrets.CI_GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.CI_GOOGLE_CLIENT_SECRET }}
CI_GOOGLE_TEST_USERNAME: ${{ secrets.CI_GOOGLE_TEST_USERNAME }}
CI_GOOGLE_TEST_PASSWORD: ${{ secrets.CI_GOOGLE_TEST_PASSWORD }}
SAML_ADMINS: pro@example.com
# NEXTAUTH_URL: xxx
# EMAIL_FROM: xxx
# EMAIL_SERVER_HOST: xxx

View File

@ -1,34 +0,0 @@
import { test } from "@playwright/test";
test("login with Google", async ({ page }) => {
if (!process.env.CI_GOOGLE_TEST_USERNAME || !process.env.CI_GOOGLE_TEST_PASSWORD) {
throw new Error("Please set a test username and password for Google login");
}
const username = process.env.CI_GOOGLE_TEST_USERNAME;
const password = process.env.CI_GOOGLE_TEST_PASSWORD;
await page.goto(`${process.env.PLAYWRIGHT_TEST_BASE_URL}/auth/login`);
await page.click("[data-testid=google]");
await page.waitForNavigation({
waitUntil: "domcontentloaded",
});
await page.waitForSelector('input[type="email"]');
await page.type('input[type="email"]', username);
await page.click("#identifierNext");
await page.waitForSelector('input[type="password"]', { state: "visible" });
await page.type('input[type="password"]', password);
await page.waitForSelector("#passwordNext", { state: "visible" });
await page.click("#passwordNext");
await page.waitForNavigation({
waitUntil: "domcontentloaded",
});
await page.waitForSelector("[data-testid=onboarding]");
// Save signed-in state to 'googleStorageState.json'.
await page.context().storageState({ path: `playwright/artifacts/googleStorageState.json` });
await page.context().close();
});

View File

@ -0,0 +1,28 @@
import { test } from "@playwright/test";
test("Test OAuth login buttons", async ({ page }) => {
await page.goto(`${process.env.PLAYWRIGHT_TEST_BASE_URL}/auth/login`);
// Check for Google login button, then click through and check for email field
await page.waitForSelector("[data-testid=google]");
await page.click("[data-testid=google]");
await page.waitForNavigation({
waitUntil: "domcontentloaded",
});
await page.waitForSelector('input[type="email"]');
await page.goto(`${process.env.PLAYWRIGHT_TEST_BASE_URL}/auth/login`);
await page.waitForSelector("[data-testid=saml]");
// Check for SAML login button, then click through
await page.click("[data-testid=saml]");
await page.waitForNavigation({
waitUntil: "domcontentloaded",
});
await page.context().close();
});