Auto-seed when resetting and migrating dev (#1513)

* Auto-seed when resetting and migrating dev

* Fixes db-seed script

* Oauth e2e test fixes
pull/1516/head
Omar López 2022-01-14 11:36:53 -07:00 committed by GitHub
parent fac4de1144
commit 73f607f27a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 23 deletions

View File

@ -10,7 +10,7 @@
"db-up": "docker-compose up -d",
"db-migrate": "yarn prisma migrate dev",
"db-deploy": "yarn prisma migrate deploy",
"db-seed": "ts-node scripts/seed.ts",
"db-seed": "yarn prisma db seed",
"db-nuke": "docker-compose down --volumes --remove-orphans",
"db-setup": "run-s db-up db-migrate db-seed",
"db-reset": "run-s db-nuke db-setup",
@ -154,5 +154,8 @@
"./prisma/schema.prisma": [
"prisma format"
]
},
"prisma": {
"seed": "ts-node ./prisma/seed.ts"
}
}

View File

@ -1,28 +1,19 @@
import { test } from "@playwright/test";
import { expect, test } from "@playwright/test";
test("Test OAuth login buttons", async ({ page }) => {
await page.goto(`${process.env.PLAYWRIGHT_TEST_BASE_URL}/auth/login`);
import { IS_GOOGLE_LOGIN_ENABLED, IS_SAML_LOGIN_ENABLED } from "../server/lib/constants";
// 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"]');
test("Should display Google Login button", async ({ page }) => {
test.skip(!IS_GOOGLE_LOGIN_ENABLED, "It should only run if Google Login is installed");
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 expect(page.locator(`[data-testid=google]`)).toBeVisible();
});
await page.context().close();
test("Should display SAML Login button", async ({ page }) => {
test.skip(!IS_SAML_LOGIN_ENABLED, "It should only run if SAML Login is installed");
await page.goto(`${process.env.PLAYWRIGHT_TEST_BASE_URL}/auth/login`);
await expect(page.locator(`[data-testid=saml]`)).toBeVisible();
});

View File

@ -3,3 +3,4 @@ export const { client_id: GOOGLE_CLIENT_ID, client_secret: GOOGLE_CLIENT_SECRET
JSON.parse(GOOGLE_API_CREDENTIALS)?.web;
export const GOOGLE_LOGIN_ENABLED = process.env.GOOGLE_LOGIN_ENABLED === "true";
export const IS_GOOGLE_LOGIN_ENABLED = !!(GOOGLE_CLIENT_ID && GOOGLE_CLIENT_SECRET && GOOGLE_LOGIN_ENABLED);
export const IS_SAML_LOGIN_ENABLED = !!(process.env.SAML_DATABASE_URL && process.env.SAML_ADMINS);