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

ci(PPDSC-2017): newskit integration test #183

Merged
merged 26 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
eb7f87f
docs(PPDSC-0000): testing permissions
Vanals Apr 11, 2022
20cf719
docs(PPDSC-0000): removing test changed from readme
Vanals Apr 11, 2022
dc4bd3c
docs(PPDSC-0000): removing test changed from readme
Vanals Apr 11, 2022
aecea28
chore(PPDSC-2007): rolling back release
Vanals Apr 11, 2022
53afa86
Merge branch 'main' of github.com:newscorp-ghfb/newskit into main
Vanals Apr 25, 2022
d6359db
ci(PPDSC-2017): created job and script for integr test
Vanals Apr 29, 2022
eac4f43
ci(PPDSC-2017): added job in pr workflow
Vanals Apr 29, 2022
ab2434b
ci(PPDSC-2017): removed yarn build and imrpoved requires
Vanals Apr 29, 2022
01b9875
ci(PPDSC-2017): improved comments in template, added back yarn build
Vanals Apr 29, 2022
5d943cd
ci(PPDSC-2017): updated template
Vanals Apr 29, 2022
021583c
chore(PPDSC-2007): test git set identity
Vanals Apr 29, 2022
65ca481
ci(PPDSC-2017): removed index.js
Vanals May 3, 2022
896e555
ci(PPDSC-2017): added -p flag in mkdir command
Vanals May 3, 2022
4d103e8
ci(PPDSC-2017): adding caching and fixing last run
Vanals May 3, 2022
893ec38
ci(PPDSC-2017): fixed chaching and increased v
Vanals May 3, 2022
9a2ef8c
ci(PPDSC-2017): changing executor and how install cy
Vanals May 3, 2022
e5e931b
ci(PPDSC-2017): added note in MakeFile, updated Cy installation
Vanals May 3, 2022
6ba447b
ci(PPDSC-2017): testing speed with no cache
Vanals May 3, 2022
839812e
ci(PPDSC-2017): improved cy config and tests
Vanals May 3, 2022
87e2b56
ci(PPDSC-2017): improve comment in makefile, yalc publish and spec fix
Vanals May 3, 2022
6f3b194
ci(PPDSC-2017): adding test job in workflows
Vanals May 3, 2022
93d80d5
ci(PPDSC-2017): improved naming step
Vanals May 3, 2022
a869324
Merge branch 'main' into ci/PPDSC-2017-newskit-integration-test
Vanals May 3, 2022
2e3c6df
Update Makefile
Vanals May 9, 2022
b73524b
Update scripts/templates-integration-test/index.txt
Vanals May 10, 2022
dda146a
Merge branch 'main' into ci/PPDSC-2017-newskit-integration-test
Vanals May 10, 2022
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
64 changes: 61 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,55 @@ jobs:
- slack/status:
<<: *slack_status

test_newskit_in_nextjs_app:
executor: cypress
steps:
- checkout
- attach_workspace:
at: ~/project
- run:
name: Install yalc and create-next-app
command: |
yarn global add yalc && yarn add create-next-app@latest
- run:
name: Yalc publish and run create-nextjs-app
command: |
cd dist
yalc publish
cd ..
npx create-next-app@latest newskit-integration-test
- run:
name: Prepare the NextJs app
command: |
echo "Adding nedded files into the NextJs app"

cp ./scripts/templates-integration-test/index.txt ./newskit-integration-test/pages/index.js
cp ./scripts/templates-integration-test/cypress.json ./newskit-integration-test/
mkdir -p ./newskit-integration-test/cypress/integration
cp ./scripts/templates-integration-test/theme-checker.spec.js ./newskit-integration-test/cypress/integration


echo "Installing needed packages into the NextJS app"

cd newskit-integration-test
yalc add newskit
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. It seems that with yalc add my-package, we don't need yarn link anymore. I assume any local changes in newskit will be reflected in this react app automatically?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was having some issues when using yarn link. facebook/react#14257.
Only yalc helped me. Not sure if at the end worked cos react needed to be downgraded. Anyway, overall, yalc seem to be better thank yarn link!

yarn add start-server-and-test
# Temp downgrading React. Needed for avoiding Hydration error with React v18 https://github.com/vercel/next.js/discussions/35773
yarn add react@17.0.1
yarn add react-dom@17.0.1
yarn add -D cypress@9.1.0;
- run:
name: Serve and test app with Cypress
command: |
cd newskit-integration-test
yarn build
yarn start-test start 3000 'yarn cypress run'
- slack/status:
<<: *slack_status




# ========== FILTERS START ==========

only_on_trigger_release_tag: &only_on_trigger_release_tag
Expand Down Expand Up @@ -912,6 +961,9 @@ workflows:
- test_unit_docs:
requires:
- build_icons
- test_newskit_in_nextjs_app:
requires:
- build_components
- test_e2e_comps:
context: ncu-product-platforms-context
requires:
Expand Down Expand Up @@ -949,7 +1001,7 @@ workflows:
- approve_publish_npm_pr:
type: approval
requires:
- build_components
- test_newskit_in_nextjs_app
- lint
- test_unit_comps
- test_unit_docs
Expand Down Expand Up @@ -1086,12 +1138,15 @@ workflows:
requires:
- build_docs_dev
- install_cypress
- test_newskit_in_nextjs_app:
requires:
- build_components

# Jobs for deploying unstable NewsKit version
- approve_publish_npm_dev:
type: approval
requires:
- build_components
- test_newskit_in_nextjs_app
- lint
- test_unit_comps
- test_unit_docs
Expand Down Expand Up @@ -1270,6 +1325,9 @@ workflows:
- test_unit_docs
- test_e2e_comps
- test_e2e_docs_prod
- test_newskit_in_nextjs_app:
requires:
- build_components

- publish_npm:
<<: *only_on_version_tag
Expand All @@ -1280,7 +1338,7 @@ workflows:
- test_unit_docs
- test_e2e_comps
- test_e2e_docs_prod
- build_components
- test_newskit_in_nextjs_app

# Deploying newskit.co.uk and storybook to Staging then to Prod environment.
- eks_flux_deploy:
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ BASE_URI = ${SITE_BASE_URL}${BASE_PATH}/
install:
yarn install --frozen-lockfile

# When changing the version, make sure it matches the one used in the `test_newskit_in_nextjs_app` CircleCI's job.
install_cypress:
yarn add -D cypress@9.1.0;

Expand Down
4 changes: 4 additions & 0 deletions scripts/templates-integration-test/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"baseUrl": "http://localhost:3000",
"video": false
}
12 changes: 12 additions & 0 deletions scripts/templates-integration-test/index.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Template for populating the index.js file in the NextJS app;
// built from the `test_newskit_in_nextjs_app` CircleCi job.

import {ThemeChecker, newskitLightTheme, ThemeProvider} from 'newskit';

export default function Home() {
return (
<ThemeProvider theme={newskitLightTheme}>
<ThemeChecker />
</ThemeProvider>
);
}
6 changes: 6 additions & 0 deletions scripts/templates-integration-test/theme-checker.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
describe('Theme Checker', () => {
it('Visits the home page and expect to find a play pause button', () => {
cy.visit('/');
cy.get('[data-testid="audio-player-play-button"]');
});
});