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

fix(create-site): update scripts for creating site + publishing #991

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

seaerchin
Copy link
Contributor

NOTE: do not merge till release as this will go into effect IMMEDIATELY

Problem

https://opengovproducts.slack.com/archives/C06R4DX966P/p1736928912803439

  1. studio and components use different properties for siteName - which in turns impact the footer
  2. createSite.ts has a default siteName set, even though the script already gives a siteName

Solution

  1. remove the spread in property - the config object already has siteName
  2. use the passed in siteName for createSite

Tests

  1. create a site locally using createSite.ts
  2. verify that the site has a correct siteName and not the default of MTI
  3. point a staging site to this branch
  4. update teh staging db so that the site's site.name and site.config.siteName differ
  5. publish a change
  6. verify that the end site uses site.config.siteName

@seaerchin seaerchin requested a review from a team as a code owner January 15, 2025 08:28
@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Jan 15, 2025

Datadog Report

Branch report: fix/create-site
Commit report: 6fbda92
Test service: isomer-studio

❌ 3 Failed (0 Known Flaky), 189 Passed, 36 Skipped, 42.4s Total Time
⬆️ Test Sessions change in coverage: 1 increased (+7.29%)

❌ Failed Tests (3)

  • site.router list should include the Site if the user has any role permission for the site - apps/studio/src/server/modules/site/__tests__/site.router.test.ts - Details

    Expand for error
     expected [ { id: 1, config: { …(4) } } ] to deeply equal [ { id: 1, …(2) } ]
    
  • site.router list should only include sites that the user has any role permission for - apps/studio/src/server/modules/site/__tests__/site.router.test.ts - Details

    Expand for error
     expected [ { id: 2, config: { …(4) } } ] to deeply equal [ { id: 2, …(2) } ]
    
  • site.router list should only show a site once if there are multiple permissions for the same site and user - apps/studio/src/server/modules/site/__tests__/site.router.test.ts - Details

    Expand for error
     expected [ { id: 5, config: { …(4) } } ] to deeply equal [ { id: 5, …(2) } ]
    

@@ -485,7 +485,6 @@ async function fetchAndWriteSiteData(client: Client) {
const config = {
site: {
...configResult.rows[0].config,
siteName: configResult.rows[0].name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: I recall we did this so that we store the site name as a separate column inside the DB rather than inside the JSON column, as it is used under the sites dashboard. We couldn't remove the siteName prop inside the JSON blob because then the types would not match.

I think we should still stick to storing the site name in the separate column and have this set to say "Ignore this" (until we have a good solution for the typing mismatch).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: I recall we did this so that we store the site name as a separate column inside the DB rather than inside the JSON column, as it is used under the sites dashboard. We couldn't remove the siteName prop inside the JSON blob because then the types would not match.

can clarify this? not sure what the issue here is apart from the types - if it's just about the name that presents on the dashboard, we can also chagne it to read from site.config.siteName, which i thought is better because that's a "user level view" whereas the db one (site.name) is not tied under site.config

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah it would be perfect if we can read directly from site.config.siteName but not sure if there is any performance impact reading from JSON blobs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok then i'll just make the change to read directly from site.config.siteName HAHA

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, see video here. re: performance impact - it's close to 0 because we already read it at present lol

Screen.Recording.2025-01-15.at.5.33.02.PM.mov

@seaerchin seaerchin requested a review from dcshzj January 15, 2025 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants