Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more robust e2e setup #610

Open
Tracked by #468
Andreasgdp opened this issue Aug 5, 2024 · 0 comments · May be fixed by #647
Open
Tracked by #468

Add more robust e2e setup #610

Andreasgdp opened this issue Aug 5, 2024 · 0 comments · May be fixed by #647
Assignees

Comments

@Andreasgdp
Copy link
Member

Andreasgdp commented Aug 5, 2024

As mentioned in #608 we need to have a database ready to use for the e2e tests. And integration for that matter, but that's another story.
This means in order to do more real e2e we need to add a dockerized postgres database (preferably using the docker-compose.yml file in the root). Or if what we already have is usable for CI setup have that startup as part of the e2e github action, so it's ready for use when the e2e starts running. We should also add tooling to seed and reset the database as needed in the tests; however for this issue it would be fine to have a simpler setup, just to get started.

We also need to setup clerk so we can use it when running the test suite (https://clerk.com/docs/testing/playwright). Here are some example files for how to make use of clerk with playwright (https://github.com/clerk/clerk-playwright-nextjs/tree/main):

https://github.com/clerk/clerk-playwright-nextjs/blob/main/e2e/global.setup.ts

import { clerkSetup } from "@clerk/testing/playwright";
import { test as setup } from "@playwright/test";

setup("global setup", async ({}) => {
  await clerkSetup();

  if (
    !process.env.E2E_CLERK_USER_USERNAME ||
    !process.env.E2E_CLERK_USER_PASSWORD
  ) {
    throw new Error(
      "Please provide E2E_CLERK_USER_USERNAME and E2E_CLERK_USER_PASSWORD environment variables."
    );
  }
});

https://github.com/clerk/clerk-playwright-nextjs/blob/main/e2e/app.spec.ts

import { setupClerkTestingToken } from "@clerk/testing/playwright";
import { test, expect } from "@playwright/test";

test.describe('app', () => {
  test("sign in", async ({ page }) => {
    await setupClerkTestingToken({ page });
  
    await page.goto("/protected");
    await expect(page.locator("h1")).toContainText("Sign In");
    await page.waitForSelector('.cl-signIn-root', { state: 'attached' });
    await page.locator('input[name=identifier]').fill(process.env.E2E_CLERK_USER_USERNAME!);
    await page.getByRole('button', { name: 'Continue', exact: true }).click();
    await page.locator('input[name=password]').fill(process.env.E2E_CLERK_USER_PASSWORD!);
    await page.getByRole('button', { name: 'Continue', exact: true }).click();
    await page.waitForURL('**/protected');
  });
  
  
  test("sign up", async ({ page }) => {
    await setupClerkTestingToken({ page });
  
    await page.goto("/sign-up");
    await expect(page.locator("h1")).toContainText("Sign Up");
    await page.waitForSelector('.cl-signUp-root', { state: 'attached' });
    await page.locator('input[name=username]').fill('user' + Date.now());
    await page.locator('input[name=password]').fill('Pass!@' + Date.now());
    await page.getByRole('button', { name: 'Continue', exact: true }).click();
    await page.waitForURL('**/protected');
  });
});
@github-project-automation github-project-automation bot moved this to Needs Refinement in MomentMeal Board Aug 5, 2024
@Andreasgdp Andreasgdp mentioned this issue Aug 8, 2024
1 task
@Andreasgdp Andreasgdp moved this from Needs Refinement to Product Backlog in MomentMeal Board Aug 11, 2024
Andreasgdp added a commit that referenced this issue Sep 26, 2024
Fixes #610

Add a more robust e2e setup with Dockerized Postgres and Clerk integration.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/BHelpful/MomentMeal/issues/610?shareId=XXXX-XXXX-XXXX-XXXX).
@Andreasgdp Andreasgdp linked a pull request Sep 26, 2024 that will close this issue
@Andreasgdp Andreasgdp moved this from Product Backlog to In Progress in MomentMeal Board Sep 26, 2024
@Andreasgdp Andreasgdp self-assigned this Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

1 participant