Skip to content

Commit

Permalink
updating envs & trying to figure out CI issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Hurly77 committed Oct 23, 2023
1 parent 1e948c2 commit 9a86f9c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 34 deletions.
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CI=true
GraphQL_1URL="http://localhost:54321/graphql/v1"
SUPBASE_DB_URL="postgresql://postgres:postgres@localhost:54322/postgres"
STUDIO_URL="http://localhost:54323"
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ on:
branches: [main, master]
pull_request:
branches: [main, master]
env:
NODE_ENV: "development"
BASE_URL: "http://localhost:3000"
TEST_USER_EMAIL: "camrbo@gmail.com"
TEST_USER_PASSWORD: "pass123"
SUPABASE_DB_URL: "postgresql://postgres:postgres@localhost:54322/postgres"
NEXT_PUBLIC_SUPABASE_URL: "http://localhost:54321"
NEXT_PUBLIC_SUPABASE_ANON_KEY: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0"

jobs:
test:
timeout-minutes: 60
Expand Down
8 changes: 4 additions & 4 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import dotenv from "dotenv";
import path from "path";

dotenv.config();
dotenv.config({ path: path.resolve(__dirname, "..", ".env.development") });
dotenv.config({ path: path.resolve(__dirname, "..", ".env.development.*") });
export default defineConfig({
testDir: "./tests",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
retries: process.env.CI ? 3 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
workers: process.env.CI ? 6 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
Expand Down Expand Up @@ -79,7 +79,7 @@ export default defineConfig({

/* Run your local dev server before starting the tests */
webServer: {
command: "yarn dev",
command: "yarn build && yarn start",
url: "http://localhost:3000",
reuseExistingServer: true,
},
Expand Down
10 changes: 10 additions & 0 deletions tests/auth.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ import { supabase } from "../src/lib/sdk/utilities/supabase";

const authFile = "playwright/.auth/session.json";

setup("expect env vars to be set", async ({}) => {
expect(process.env.CI).toBeDefined();
expect(process.env.TEST_USER_EMAIL).toBeDefined();
expect(process.env.TEST_USER_PASSWORD).toBeDefined();
expect(process.env.TEST_USER_EMAIL).toBeDefined();
expect(process.env.BASE_URL).toBeDefined();
expect(process.env.NEXT_PUBLIC_SUPABASE_URL).toBeDefined();
expect(process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY).toBeDefined();
});

setup("supabase auth working", async ({}) => {
const { data, error } = await supabase.auth.signInWithPassword({
email: process.env.TEST_USER_EMAIL ?? "",
Expand Down
2 changes: 1 addition & 1 deletion tests/get-started.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from "@playwright/test";

test("Can navigate to Index Page", async ({ page, baseURL }) => {
await page.goto(baseURL || "http://localhost:3000");
await page.goto(baseURL ?? "");

await expect(page.getByText("Get Started")).toBeVisible();
});
21 changes: 1 addition & 20 deletions tests/titles.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import { test, expect } from "@playwright/test";

test("Tasks /* titles", async ({ page, baseURL }) => {
await page.goto((baseURL || "http://localhost:3000") + "/tasks");

const storage = await page.context().storageState();
console.log("STORAGE", storage.origins[0].localStorage);

const session = await page.evaluate(async () => {
return localStorage;
});

console.log("SESSION", session);
await page.goto((baseURL ?? "") + "/tasks");

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Today - Toduit/);
Expand All @@ -21,13 +12,3 @@ test("Tasks /* titles", async ({ page, baseURL }) => {
await page.getByLabel("All Tasks").click();
await expect(page).toHaveTitle(/Tasks - Toduit/);
});

test("get started link", async ({ page }) => {
await page.goto("https://playwright.dev/");

// Click the get started link.
await page.getByRole("link", { name: "Get started" }).click();

// Expects page to have a heading with the name of Installation.
await expect(page.getByRole("heading", { name: "Installation" })).toBeVisible();
});

0 comments on commit 9a86f9c

Please sign in to comment.