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

Feat: create github issue on new add feed form #768

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/web-app-deployer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ on:
description: 1Password Slack webhook URL secret reference for add feed channel
type: string
required: false
OP_ADD_FEED_FORM_GITHUB_TOKEN:
description: 1Password GitHub token secret reference
type: string
required: false
outputs:
hosting_url:
description: "The URL of the deployed web app"
Expand Down Expand Up @@ -148,6 +152,7 @@ jobs:
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
SLACK_WEBHOOK_URL: ${{inputs.OP_SLACK_WEBHOOK_URL}}
ADD_FEED_FORM_GITHUB_TOKEN: ${{inputs.OP_ADD_FEED_FORM_GITHUB_TOKEN}}

- name: Authenticate to Google Cloud DEV
if: ${{ inputs.FIREBASE_PROJECT == 'dev' }}
Expand Down Expand Up @@ -255,6 +260,7 @@ jobs:
run: |
echo "FEED_SUBMIT_GOOGLE_SHEET_ID=${{ inputs.FEED_SUBMIT_GOOGLE_SHEET_ID }}" > .env
echo "SLACK_WEBHOOK_URL=${{ env.SLACK_WEBHOOK_URL }}" >> .env
echo "GITHUB_TOKEN=${{ env.ADD_FEED_FORM_GITHUB_TOKEN }}" >> .env

- name: Deploy Firebase Functions
working-directory: functions
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/web-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ jobs:
REACT_APP_GOOGLE_ANALYTICS_ID: ${{ vars.PROD_REACT_APP_GOOGLE_ANALYTICS_ID }}
FEED_SUBMIT_GOOGLE_SHEET_ID: "10eIUxWVtLmc2EATiwivgXBf4bOMErOnq7GFIoRedXHU"
OP_SLACK_WEBHOOK_URL: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/Slack webhook URLs/rdpfgrmnbxqaelgi5oky3lryz4/internal-add-feeds"
OP_ADD_FEED_FORM_GITHUB_TOKEN: "op://lijd6lj7lyw7dajea6x3zgf53m/lwob5snb7kgpgekv4zha2jld44/credential"
secrets: inherit
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
import {buildGithubIssueBody} from "../impl/feed-form-impl";
import {FeedSubmissionFormRequestBody} from "../impl/types";

describe("buildGithubIssueBody", () => {
const spreadsheetId = "testSpreadsheetId";

it("should generate content for basic form data with GTFS feed", () => {
const formData: FeedSubmissionFormRequestBody = {
isOfficialProducer: "yes",
dataType: "gtfs",
transitProviderName: "Test Agency",
name: "Test Agency",
country: "US",
region: "CA",
municipality: "San Francisco",
isUpdatingFeed: "yes",
oldFeedLink: "https://old-feed-link.com",
feedLink: "https://new-feed-link.com",
authType: "API key - 1",
authSignupLink: "https://auth-signup-link.com",
authParameterName: "apiKey",
isInterestedInQualityAudit: "no",
hasLogoPermission: "yes",
};

const expectedContent = `
# Agency name/Transit Provider: Test Agency

### Location
US, CA, San Francisco

## Details

#### Data type
gtfs

#### Issue type
Feed update

#### Name
Test Agency

## URLs
| Current URL on OpenMobilityData.org | Updated/new feed URL |
|---|---|
| https://old-feed-link.com | https://new-feed-link.com |

## Authentication
#### Authentication type
API key - 1

#### Link to how to sign up for authentication credentials (API KEY)
https://auth-signup-link.com

#### HTTP header or API key parameter name
apiKey

## View more details
https://docs.google.com/spreadsheets/d/testSpreadsheetId/edit`;

expect(buildGithubIssueBody(formData, spreadsheetId)).toBe(expectedContent);
});

it("should handle optional location fields gracefully", () => {
const formData: FeedSubmissionFormRequestBody = {
isOfficialProducer: "no",
dataType: "gtfs",
transitProviderName: "Test Agency",
name: "Test Agency",
country: "US",
isUpdatingFeed: "no",
oldFeedLink: "https://old-feed-link.com",
feedLink: "https://new-feed-link.com",
authType: "HTTP header - 2",
isInterestedInQualityAudit: "",
hasLogoPermission: "no",
};

const expectedContent = `
# Agency name/Transit Provider: Test Agency

### Location
US

## Details

#### Data type
gtfs

#### Issue type
New feed

#### Name
Test Agency

## URLs
| Current URL on OpenMobilityData.org | Updated/new feed URL |
|---|---|
| https://old-feed-link.com | https://new-feed-link.com |

## Authentication
#### Authentication type
HTTP header - 2

## View more details
https://docs.google.com/spreadsheets/d/testSpreadsheetId/edit`;

expect(buildGithubIssueBody(formData, spreadsheetId)).toBe(expectedContent);
});

it("should handle non-GTFS data types (tu, vp, sa)", () => {
const formData: FeedSubmissionFormRequestBody = {
isOfficialProducer: "yes",
dataType: "gtfs_rt",
transitProviderName: "Test Agency",
name: "Test Agency",
isUpdatingFeed: "yes",
oldTripUpdates: "https://old-trip-updates.com",
tripUpdates: "https://new-trip-updates.com",
oldVehiclePositions: "https://old-vehicle-positions.com",
vehiclePositions: "https://new-vehicle-positions.com",
oldServiceAlerts: "https://old-service-alerts.com",
serviceAlerts: "https://new-service-alerts.com",
authType: "None - 0",
isInterestedInQualityAudit: "yes",
hasLogoPermission: "no",
};

const expectedContent = `
# Agency name/Transit Provider: Test Agency

## Details

#### Data type
gtfs_rt

#### Issue type
Feed update

#### Name
Test Agency

## URLs
| Current URL on OpenMobilityData.org | Updated/new feed URL |
|---|---|
| https://old-trip-updates.com | https://new-trip-updates.com |
| https://old-vehicle-positions.com | https://new-vehicle-positions.com |
| https://old-service-alerts.com | https://new-service-alerts.com |

## Authentication
#### Authentication type
None - 0

## View more details
https://docs.google.com/spreadsheets/d/testSpreadsheetId/edit`;
expect(buildGithubIssueBody(formData, spreadsheetId)).toBe(expectedContent);
});

it("should handle missing authentication details", () => {
const formData: FeedSubmissionFormRequestBody = {
isOfficialProducer: "",
dataType: "gtfs",
transitProviderName: "Test Agency",
name: "Test Agency",
isUpdatingFeed: "no",
oldFeedLink: "https://old-feed-link.com",
feedLink: "https://new-feed-link.com",
authType: "None - 0",
isInterestedInQualityAudit: "",
hasLogoPermission: "",
};

const expectedContent = `
# Agency name/Transit Provider: Test Agency

## Details

#### Data type
gtfs

#### Issue type
New feed

#### Name
Test Agency

## URLs
| Current URL on OpenMobilityData.org | Updated/new feed URL |
|---|---|
| https://old-feed-link.com | https://new-feed-link.com |

## Authentication
#### Authentication type
None - 0

## View more details
https://docs.google.com/spreadsheets/d/testSpreadsheetId/edit`;

expect(buildGithubIssueBody(formData, spreadsheetId)).toBe(expectedContent);
});
});
Loading