-
Notifications
You must be signed in to change notification settings - Fork 1
Remove custom domain from tenants collection #972
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
Merged
busbyk
merged 6 commits into
revert-926-revert-1.7.0
from
revert-926-revert-1.7.0-remove-custom-domain
Mar 16, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ddd9de4
Add test for getEmailDomain utility
busbyk ec98477
Remove customDomain from database, use AVALANCHE_CENTERS as single so…
busbyk 5cda597
Fix e2e tests: tenant cookie now stores slugs, not numeric IDs
busbyk b7d1dcb
updating type assertions log
busbyk d050031
removing unnecessary comments
busbyk 1aa41b4
adding tests for findCenterByDomain and for getEmailDomain when there…
busbyk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { findCenterByDomain } from '../../src/utilities/tenancy/avalancheCenters' | ||
|
|
||
| describe('findCenterByDomain', () => { | ||
| it('finds a center by exact domain match (no www)', () => { | ||
| expect(findCenterByDomain('nwac.us')).toBe('nwac') | ||
| expect(findCenterByDomain('alaskasnow.org')).toBe('aaic') | ||
| expect(findCenterByDomain('avalanche.state.co.us')).toBe('caic') | ||
| }) | ||
|
|
||
| it('finds a center when domain has www. prefix', () => { | ||
| expect(findCenterByDomain('www.nwac.us')).toBe('nwac') | ||
| expect(findCenterByDomain('www.cnfaic.org')).toBe('cnfaic') | ||
| expect(findCenterByDomain('www.sierraavalanchecenter.org')).toBe('sac') | ||
| }) | ||
|
|
||
| it('finds a center when stored domain has www. but input does not', () => { | ||
| expect(findCenterByDomain('cnfaic.org')).toBe('cnfaic') | ||
| expect(findCenterByDomain('sierraavalanchecenter.org')).toBe('sac') | ||
| }) | ||
|
|
||
| it('is case insensitive', () => { | ||
| expect(findCenterByDomain('NWAC.US')).toBe('nwac') | ||
| expect(findCenterByDomain('NwAc.Us')).toBe('nwac') | ||
| expect(findCenterByDomain('WWW.CNFAIC.ORG')).toBe('cnfaic') | ||
| expect(findCenterByDomain('www.SierrAAvAlAnchECentEr.Org')).toBe('sac') | ||
| }) | ||
|
|
||
| it('handles domains shared by multiple centers (returns first match)', () => { | ||
| // Multiple centers use 'alaskasnow.org': aaic, cac, earac, hac, vac | ||
| // Should return the first one found (aaic) | ||
| const result = findCenterByDomain('alaskasnow.org') | ||
| expect(result).toBe('aaic') | ||
| }) | ||
|
|
||
| it('returns undefined for non-existent domains', () => { | ||
| expect(findCenterByDomain('example.com')).toBeUndefined() | ||
| expect(findCenterByDomain('notarealcenter.org')).toBeUndefined() | ||
| expect(findCenterByDomain('www.doesnotexist.com')).toBeUndefined() | ||
| }) | ||
|
|
||
| it('returns undefined for empty string', () => { | ||
| expect(findCenterByDomain('')).toBeUndefined() | ||
| }) | ||
|
|
||
| it('handles domains with trailing/leading whitespace', () => { | ||
| expect(findCenterByDomain(' nwac.us')).toBe('nwac') | ||
| expect(findCenterByDomain('nwac.us ')).toBe('nwac') | ||
| expect(findCenterByDomain(' nwac.us ')).toBe('nwac') | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { AVALANCHE_CENTERS, getEmailDomain } from '../../src/utilities/tenancy/avalancheCenters' | ||
|
|
||
| describe('getEmailDomain', () => { | ||
| it('returns the domain as-is when there is no www. prefix', () => { | ||
| expect(getEmailDomain('nwac')).toBe('nwac.us') | ||
| }) | ||
|
|
||
| it('strips only the www. prefix, not other subdomains', () => { | ||
| expect(getEmailDomain('cnfaic')).toBe('cnfaic.org') | ||
|
|
||
| expect(getEmailDomain('aaic')).toBe('alaskasnow.org') | ||
| }) | ||
|
|
||
| it('strips port numbers from domains (for local development)', () => { | ||
| // Temporarily modify dvac's customDomain to include a port | ||
| const originalDomain = AVALANCHE_CENTERS.dvac.customDomain | ||
| AVALANCHE_CENTERS.dvac.customDomain = 'www.deathvalleyac.local:3000' | ||
|
|
||
| expect(getEmailDomain('dvac')).toBe('deathvalleyac.local') | ||
|
|
||
| // Restore original value | ||
| AVALANCHE_CENTERS.dvac.customDomain = originalDomain | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,7 +58,6 @@ export async function GET( | |
| populate: { | ||
| tenants: { | ||
| slug: true, | ||
| customDomain: true, | ||
| name: true, | ||
| }, | ||
| }, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I just realized how problematic this is. I don't think we should hold up this PR or #947 based on this because this is the same behavior we had before and we only need to solve for this when we onboard any of the alaskasnow.org centers. But I'll start a thread in Slack to discuss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine to side step for now.