department-of-veterans-affairs / va.gov-team

Public resources for building on and in support of VA.gov. Visit complete Knowledge Hub:
https://depo-platform-documentation.scrollhelp.site/index.html
284 stars 206 forks source link

Create an integration test for the CMS Preview Server #2704

Open ncksllvn opened 5 years ago

ncksllvn commented 5 years ago

We have an Express.js-based server in vets-website that allows content authors to preview their unpublished changes from Drupal. This server sits on the VA network (also accessible via SOCKS), queries Drupal using the nodeId, passes the response JSON through the build pipeline, then returns the resultant HTML to the user.

For example, visit this page in the CMS - https://prod.cms.va.gov/health-care Then, click the preview button to be navigated to - http://preview-prod.vfs.va.gov/preview?nodeId=67

The source for this server is here - https://github.com/department-of-veterans-affairs/vets-website/blob/master/script/preview.js

This all works just fine. However, we have no tests for our CMS Preview Server! This is an issue because the CMS Preview Server has its own build pipeline separate from the regular build pipeline, and sometimes changes must be made across both. When changes aren't, the Preview Server will break unbeknownst to anyone.

To fix, we should explore and implement an integration test for the CMS Preview Server. Nightwatch would probably work okay, but we need to start the CMS Preview Server first, and somehow mock the Drupal data it uses to generate the page.

ncksllvn commented 5 years ago

Hey @tlei123, would you be interested in exploring this at all?

tlei123 commented 5 years ago

Hey @tlei123, would you be interested in exploring this at all?

Sure, @ncksllvn ! I need to learn more about general CI/CD and this task is a great opportunity to get my hands dirty with CI.

I'll start digging into this tomorrow, and I'll ping you on Slack w/ any questions.

tlei123 commented 5 years ago

@ncksllvn , do I need to set up a local instance of Drupal CMS in order to run the Preview Server locally?

I'm getting a 404 trying http://localhost:3001/preview?nodeId=67, whether I used watch or preview script to start vets-website. The vagov-content README has no instructions either for running it locally.

Pls. let me know. Thanks much!

jcosta-gcio commented 5 years ago

@gstevenson-va Coordinate with @tlei123 between both of you I know you will be able to figure it out

tlei123 commented 5 years ago

@Karak888, would you mind getting Drupal access @gstevenson-va & me please?

I'm figuring we'd need access at least to dev & staging, but having prod access too would be great.

Thanks much!

Thanks much!

Karak888 commented 5 years ago

@tlei123 Most people on my team are still waiting (including myself). I would reach out to the CMS team directly or platform, we don't take care of that on our end.

tlei123 commented 5 years ago

@gstevenson-va , this & #2705 were the CI/CD tics Joe said to kick your way. I've just grabbed back #2540 -- sorry I mis-assigned that one to ya!

@ncksllvn is the VSA Global UX Sr. Front-End Developer who currently knows most about how the CMS Preview Server works. I've barely gotten started on this and only had questions for him, but feel free to ping me on Slack as needed.

Thanks much! :)

ncksllvn commented 5 years ago

Hey folks, I was OOO for a few days. @tlei123

I'm getting a 404 trying http://localhost:3001/preview?nodeId=67, whether I used watch or preview script to start vets-website. The vagov-content README has no instructions either for running it locally.

There's a little more documentation here, https://department-of-veterans-affairs.github.io/veteran-facing-services-tools/platform/architecture/cms/, maybe somewhere else too.

For your specific question about the 404, you need to do a build of the website first, because the Preview Server will reuse those previously-built assets. So -

npm run build
# turn on SOCKS proxy
npm run preview
# navigate to http://localhost:3001/preview?nodeId=67

I don't have strong feelings on which team member picks this up. We can also just leave it to someone doing work for the CMS. But this would all be work done in vets-website. Probably something like -

  1. Added a test script somewhere that starts the Preview Server with Drupal data being mocked with static JSON.
  2. Execute something like an E2E file that loads /preview?nodeId=67 and checks for the existence of some elements to make sure the page rendered okay.
  3. Add a few lines to the Jenkinsfile so that this test is executed during CI

That's just an idea though. We could do it in other ways, I'm sure.

Karak888 commented 5 years ago

removing the label for vsa-global or public websites

tlei123 commented 5 years ago

@gstevenson-va , for anything front-end-/vets-website-specific, please feel free to ping me for hands-on help or tech info. I used to be a front-end dev on the VSA apps team, along with Erik Hansen.