Skip to content

Commit

Permalink
Get the github action working
Browse files Browse the repository at this point in the history
  • Loading branch information
WillNilges committed Jul 29, 2024
1 parent e4b2647 commit d8a391b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ jobs:
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
env:
NEXT_PUBLIC_MESHDB_URL: ${{ secrets.BETA_MESHDB_URL }}
#S3_REGION: ${{ secrets.S3_REGION }}
#S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
S3_BASE_NAME: ${{ secrets.TEST_S3_BASE_NAME }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_NAME }}
S3_SECRET_KEY: ${{ secrets.S3_BASE_NAME }}
JOIN_FORM_LOG: /tmp/join.csv
- uses: actions/upload-artifact@v4
if: always()
with:
Expand Down
31 changes: 10 additions & 21 deletions app/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const JOIN_FORM_LOG = process.env.JOIN_FORM_LOG as string;
const S3_REGION = process.env.S3_REGION as string;
const S3_ENDPOINT = process.env.S3_ENDPOINT as string;
const S3_BUCKET_NAME = process.env.S3_BUCKET_NAME as string;
const S3_BASE_NAME = process.env.S3_BASE_NAME as string;
const S3_ACCESS_KEY = process.env.S3_ACCESS_KEY as string;
const S3_SECRET_KEY = process.env.S3_SECRET_KEY as string;

Expand All @@ -29,33 +30,21 @@ export async function recordJoinFormSubmissionToCSV(submission: JoinFormInput) {

// Records the submission we just got as a JSON object in an S3 bucket.
export async function recordJoinFormSubmissionToS3(submission: JoinFormInput) {
// Don't define endpoint if one is not passed
let s3Client;
if (S3_ENDPOINT != "" && S3_ENDPOINT != null) {
s3Client = new S3Client({
region: S3_REGION,
endpoint: S3_ENDPOINT,
credentials: {
accessKeyId: S3_ACCESS_KEY,
secretAccessKey: S3_SECRET_KEY,
},
});
} else {
s3Client = new S3Client({
region: S3_REGION,
credentials: {
accessKeyId: S3_ACCESS_KEY,
secretAccessKey: S3_SECRET_KEY,
},
});
}
const s3Client = new S3Client({
region: S3_REGION != undefined ? S3_REGION : "us-east-1",
endpoint: S3_ENDPOINT != undefined ? S3_ENDPOINT : "https://s3.us-east-1.amazonaws.com",
credentials: {
accessKeyId: S3_ACCESS_KEY,
secretAccessKey: S3_SECRET_KEY,
},
});

// Thanks ChatGPT, eww...
const submissionKey = new Date().toISOString().replace(/[-:T]/g, '/').slice(0, 19);

const command = new PutObjectCommand({
Bucket: S3_BUCKET_NAME,
Key: `join-form-submissions/${submissionKey}.json`,
Key: `${S3_BASE_NAME}/${submissionKey}.json`,
Body: JSON.stringify(submission),
});

Expand Down
2 changes: 1 addition & 1 deletion components/JoinForm/JoinForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const JoinForm = () => {
let parsedForm = parseForm(event);
if (parsedForm === undefined) return;
// If we were able to glean the form, then save it.
recordJoinFormSubmissionToS3(parsedForm);
//recordJoinFormSubmissionToS3(parsedForm);
let j: JoinFormInput = parsedForm;
console.log(j);
await submitJoinForm(j);
Expand Down
10 changes: 6 additions & 4 deletions tests/join_form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { test, expect } from '@playwright/test';

import { sampleData, fillOutJoinForm, submitSuccessExpected, submitFailureExpected } from '@/tests/util';

const joinFormTimeout = 20000;

// Integration tests for the Join Form.
//
// These tests can hit either a self-hosted dev instance of MeshDB
Expand All @@ -21,7 +23,7 @@ import { sampleData, fillOutJoinForm, submitSuccessExpected, submitFailureExpect
// Can we mirror what meshdb does?

test('happy join form', async ({ page }) => {
test.setTimeout(10000)
test.setTimeout(joinFormTimeout);
await page.goto('/join');

// Is the page title correct?
Expand All @@ -35,7 +37,7 @@ test('happy join form', async ({ page }) => {

// Tests missing both first and last name
test('missing name', async ({ page }) => {
test.setTimeout(10000)
test.setTimeout(joinFormTimeout);
await page.goto('/join');

// Is the page title correct?
Expand All @@ -61,7 +63,7 @@ test('missing name', async ({ page }) => {


test('missing address', async ({ page }) => {
test.setTimeout(10000)
test.setTimeout(joinFormTimeout);
await page.goto('/join');

// Is the page title correct?
Expand All @@ -83,7 +85,7 @@ test('missing address', async ({ page }) => {

// This one should pass
test('missing unit number should pass', async ({ page }) => {
test.setTimeout(10000)
test.setTimeout(joinFormTimeout);
await page.goto('/join');

// Is the page title correct?
Expand Down
2 changes: 1 addition & 1 deletion tests/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export async function submitSuccessExpected(page: Page) {
.click();

// Make sure that the submit button says "Thanks!"
await page.waitForTimeout(3000);
await page.waitForTimeout(10000);
await expect(
page.locator("[name='submit_join_form']")
).toHaveText('Thanks!');
Expand Down

0 comments on commit d8a391b

Please sign in to comment.