Skip to content

Commit 73f607f

Browse files
authored
Auto-seed when resetting and migrating dev (#1513)
* Auto-seed when resetting and migrating dev * Fixes db-seed script * Oauth e2e test fixes
1 parent fac4de1 commit 73f607f

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"db-up": "docker-compose up -d",
1111
"db-migrate": "yarn prisma migrate dev",
1212
"db-deploy": "yarn prisma migrate deploy",
13-
"db-seed": "ts-node scripts/seed.ts",
13+
"db-seed": "yarn prisma db seed",
1414
"db-nuke": "docker-compose down --volumes --remove-orphans",
1515
"db-setup": "run-s db-up db-migrate db-seed",
1616
"db-reset": "run-s db-nuke db-setup",
@@ -154,5 +154,8 @@
154154
"./prisma/schema.prisma": [
155155
"prisma format"
156156
]
157+
},
158+
"prisma": {
159+
"seed": "ts-node ./prisma/seed.ts"
157160
}
158161
}

playwright/login.oauth.test.ts

+10-19
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
1-
import { test } from "@playwright/test";
1+
import { expect, test } from "@playwright/test";
22

3-
test("Test OAuth login buttons", async ({ page }) => {
4-
await page.goto(`${process.env.PLAYWRIGHT_TEST_BASE_URL}/auth/login`);
5-
6-
// Check for Google login button, then click through and check for email field
7-
await page.waitForSelector("[data-testid=google]");
8-
9-
await page.click("[data-testid=google]");
3+
import { IS_GOOGLE_LOGIN_ENABLED, IS_SAML_LOGIN_ENABLED } from "../server/lib/constants";
104

11-
await page.waitForNavigation({
12-
waitUntil: "domcontentloaded",
13-
});
14-
await page.waitForSelector('input[type="email"]');
5+
test("Should display Google Login button", async ({ page }) => {
6+
test.skip(!IS_GOOGLE_LOGIN_ENABLED, "It should only run if Google Login is installed");
157

168
await page.goto(`${process.env.PLAYWRIGHT_TEST_BASE_URL}/auth/login`);
179

18-
await page.waitForSelector("[data-testid=saml]");
10+
await expect(page.locator(`[data-testid=google]`)).toBeVisible();
11+
});
1912

20-
// Check for SAML login button, then click through
21-
await page.click("[data-testid=saml]");
13+
test("Should display SAML Login button", async ({ page }) => {
14+
test.skip(!IS_SAML_LOGIN_ENABLED, "It should only run if SAML Login is installed");
2215

23-
await page.waitForNavigation({
24-
waitUntil: "domcontentloaded",
25-
});
16+
await page.goto(`${process.env.PLAYWRIGHT_TEST_BASE_URL}/auth/login`);
2617

27-
await page.context().close();
18+
await expect(page.locator(`[data-testid=saml]`)).toBeVisible();
2819
});

scripts/seed.ts prisma/seed.ts

File renamed without changes.

server/lib/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export const { client_id: GOOGLE_CLIENT_ID, client_secret: GOOGLE_CLIENT_SECRET
33
JSON.parse(GOOGLE_API_CREDENTIALS)?.web;
44
export const GOOGLE_LOGIN_ENABLED = process.env.GOOGLE_LOGIN_ENABLED === "true";
55
export const IS_GOOGLE_LOGIN_ENABLED = !!(GOOGLE_CLIENT_ID && GOOGLE_CLIENT_SECRET && GOOGLE_LOGIN_ENABLED);
6+
export const IS_SAML_LOGIN_ENABLED = !!(process.env.SAML_DATABASE_URL && process.env.SAML_ADMINS);

0 commit comments

Comments
 (0)