Skip to content

Commit

Permalink
test: prepare post-deploy test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
yld-weng committed Nov 25, 2021
1 parent a53c2a9 commit 07f5be2
Show file tree
Hide file tree
Showing 12 changed files with 1,843 additions and 1,517 deletions.
Empty file.
8 changes: 7 additions & 1 deletion jest-playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ module.exports = {
timeout: 60000
},
contextOptions: {
baseURL: "http://localhost:9000",
baseURL: process.env.LIVE_ENV
? [
process.env.QA_ENV
? "https://researchdata-sheffield.github.io/dataviz-hub2-qa"
: "https://dataviz.shef.ac.uk"
]
: "http://localhost:9000",
viewport: {
// default: 1280 x 720
width: 1280,
Expand Down
3,111 changes: 1,702 additions & 1,409 deletions package-lock.json

Large diffs are not rendered by default.

65 changes: 33 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "datavizhub-tuos",
"private": true,
"description": "Promoting and building community around data visualisation at the University of Sheffield",
"version": "1.4.0",
"version": "1.5.0",
"author": "Yu Liang Weng <y.weng@sheffield.ac.uk>",
"scripts": {
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
Expand All @@ -18,6 +18,7 @@
"test:watch": "npm run test -- --watchAll",
"test:update": "npm run test -- --updateSnapshot",
"test:e2e": "jest --testPathPattern=\".*/.+(e2e).+(ts|js)\"",
"test:e2e:post-deploy": "cross-env LIVE_ENV=true jest --testPathPattern=\".*/.+(e2e).+(ts|js)\"",
"test:e2e:ci": "npm run test:e2e -- --ci --coverage",
"start": "npm run develop",
"serve": "gatsby serve",
Expand Down Expand Up @@ -46,11 +47,11 @@
"canvas": "^2.8.0",
"cross-env": "^7.0.3",
"debug": "^4.3.2",
"gatsby": "^3.14.3",
"gatsby": "^3.14.6",
"gatsby-plugin-feed": "^3.14.0",
"gatsby-plugin-flexsearch": "^1.0.3",
"gatsby-plugin-google-analytics": "^3.14.0",
"gatsby-plugin-image": "^1.14.1",
"gatsby-plugin-image": "^1.14.2",
"gatsby-plugin-instagram-embed": "^3.0.0",
"gatsby-plugin-layout": "^2.14.0",
"gatsby-plugin-manifest": "^3.14.0",
Expand All @@ -61,7 +62,7 @@
"gatsby-plugin-postcss": "^4.14.0",
"gatsby-plugin-react-helmet": "^4.14.0",
"gatsby-plugin-sass": "^4.14.0",
"gatsby-plugin-sharp": "^3.14.1",
"gatsby-plugin-sharp": "^3.14.3",
"gatsby-plugin-sitemap": "^4.10.0",
"gatsby-plugin-smoothscroll": "^1.2.0",
"gatsby-plugin-styled-components": "^4.14.0",
Expand All @@ -80,78 +81,78 @@
"gitalk": "^1.7.2",
"html-to-image": "^1.9.0",
"intersection-observer": "^0.12.0",
"katex": "^0.13.18",
"katex": "^0.13.24",
"lodash.debounce": "^4.0.8",
"lodash.kebabcase": "^4.1.1",
"moment": "^2.29.1",
"moment-timezone": "^0.5.33",
"moment-timezone": "^0.5.34",
"node-polyfill-webpack-plugin": "^1.1.4",
"node-sass": "^6.0.1",
"postcss": "^8.3.10",
"postcss": "^8.4.0",
"prismjs": "^1.25.0",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-accessible-accordion": "^4.0.0",
"react-dom": "^17.0.2",
"react-flow-renderer": "^9.6.9",
"react-flow-renderer": "^9.6.11",
"react-helmet": "^6.1.0",
"react-highlight-words": "^0.17.0",
"react-icons": "^4.3.1",
"react-markdown": "^7.0.1",
"react-markdown": "^7.1.0",
"react-modal-image": "^2.5.0",
"react-reveal": "^1.2.2",
"react-scrollspy": "^3.4.3",
"react-slick": "^0.28.1",
"react-social-sharing": "^3.3.0",
"react-spring": "^9.3.0",
"react-syntax-highlighter": "^15.4.4",
"react-tabs": "^3.2.2",
"react-spring": "^9.3.2",
"react-syntax-highlighter": "^15.4.5",
"react-tabs": "^3.2.3",
"react-tooltip": "^4.2.21",
"reading-time": "^1.5.0",
"remark-math": "^3.0.1",
"rewire": "^5.0.0",
"sanitize-html": "^2.5.2",
"sanitize-html": "^2.6.0",
"slick-carousel": "^1.8.1",
"styled-components": "^5.3.3",
"trianglify": "^4.1.1"
},
"devDependencies": {
"@babel/core": "^7.15.8",
"@babel/eslint-parser": "^7.15.8",
"@babel/preset-react": "^7.14.5",
"@emotion/react": "^11.5.0",
"@emotion/styled": "^11.3.0",
"@testing-library/jest-dom": "^5.14.1",
"@babel/core": "^7.16.0",
"@babel/eslint-parser": "^7.16.3",
"@babel/preset-react": "^7.16.0",
"@emotion/react": "^11.6.0",
"@emotion/styled": "^11.6.0",
"@testing-library/jest-dom": "^5.15.1",
"@testing-library/react": "^12.1.2",
"@testing-library/react-hooks": "^7.0.2",
"autoprefixer": "^10.3.7",
"autoprefixer": "^10.4.0",
"babel-jest": "^27.3.1",
"babel-preset-gatsby": "^1.14.0",
"cssnano": "5.0.8",
"eslint": "^8.0.1",
"babel-preset-gatsby": "^2.2.0",
"cssnano": "5.0.11",
"eslint": "^8.3.0",
"eslint-loader": "4.0.2",
"eslint-plugin-import": "2.25.2",
"eslint-plugin-jest": "^25.2.2",
"eslint-plugin-import": "2.25.3",
"eslint-plugin-jest": "^25.3.0",
"eslint-plugin-playwright": "^0.6.0",
"eslint-plugin-react": "7.26.1",
"eslint-webpack-plugin": "^3.0.1",
"eslint-plugin-react": "7.27.1",
"eslint-webpack-plugin": "^3.1.1",
"expect-playwright": "^0.8.0",
"gatsby-plugin-emotion": "^6.14.0",
"gatsby-plugin-eslint": "^4.0.0",
"gatsby-plugin-eslint": "^4.0.2",
"gatsby-remark-code-titles": "^1.1.0",
"gh-pages": "^3.2.3",
"husky": "^7.0.4",
"identity-obj-proxy": "^3.0.0",
"jest": "^27.3.1",
"jest-image-snapshot": "^4.5.1",
"jest-playwright-preset": "^1.7.0",
"lint-staged": "^11.2.3",
"playwright": "^1.15.2",
"lint-staged": "^12.1.2",
"playwright": "^1.16.3",
"prettier": "2.4.1",
"react-test-renderer": "^17.0.2",
"start-server-and-test": "^1.14.0",
"tailwindcss": "^2.2.17",
"twin.macro": "^2.8.0"
"tailwindcss": "^2.2.19",
"twin.macro": "^2.8.1"
},
"keywords": [
"the university of sheffield",
Expand Down
10 changes: 8 additions & 2 deletions src/components/shared/__tests__/__snapshots__/tab.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Object {
<div
class="mt-16 undefined"
data="[object Object],[object Object],[object Object]"
data-tabs="true"
data-rttabs="true"
>
<ul
class="react-tabs__tab-list"
Expand All @@ -19,6 +19,7 @@ Object {
aria-disabled="false"
aria-selected="true"
class="react-tabs__tab react-tabs__tab--selected"
data-rttab="true"
id="react-tabs-0"
role="tab"
tabindex="0"
Expand All @@ -30,6 +31,7 @@ Object {
aria-disabled="false"
aria-selected="false"
class="react-tabs__tab"
data-rttab="true"
id="react-tabs-2"
role="tab"
>
Expand All @@ -40,6 +42,7 @@ Object {
aria-disabled="false"
aria-selected="false"
class="react-tabs__tab"
data-rttab="true"
id="react-tabs-4"
role="tab"
>
Expand Down Expand Up @@ -89,7 +92,7 @@ Object {
<div
class="mt-16 undefined"
data="[object Object],[object Object],[object Object]"
data-tabs="true"
data-rttabs="true"
>
<ul
class="react-tabs__tab-list"
Expand All @@ -100,6 +103,7 @@ Object {
aria-disabled="false"
aria-selected="true"
class="react-tabs__tab react-tabs__tab--selected"
data-rttab="true"
id="react-tabs-0"
role="tab"
tabindex="0"
Expand All @@ -111,6 +115,7 @@ Object {
aria-disabled="false"
aria-selected="false"
class="react-tabs__tab"
data-rttab="true"
id="react-tabs-2"
role="tab"
>
Expand All @@ -121,6 +126,7 @@ Object {
aria-disabled="false"
aria-selected="false"
class="react-tabs__tab"
data-rttab="true"
id="react-tabs-4"
role="tab"
>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 9 additions & 5 deletions src/templates/blog/__tests__/blogPost.e2e.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe("e2e | Blog page", () => {
beforeAll(async () => {
page.setDefaultNavigationTimeout(60000);
await page.goto("/blog/18/02/2021/Useful-Resources-for-R", {
await page.goto("/blog/02/05/2020/dataviz-stats-1", {
waitUntil: "load"
});
await page.waitForSelector("id=__loader", { state: "hidden" });
Expand All @@ -18,7 +18,9 @@ describe("e2e | Blog page", () => {
const elementHandle = await page.$(
'[aria-label="Blog post main content"]'
);
expect(await elementHandle.screenshot()).toMatchImageSnapshot();
expect(await elementHandle.screenshot()).toMatchImageSnapshot({
failureThreshold: 0.1
});
}
);

Expand All @@ -29,14 +31,16 @@ describe("e2e | Blog page", () => {
const elementHandle = await page.$(
'[aria-label="Blog post main content"]'
);
expect(await elementHandle.screenshot()).toMatchImageSnapshot();
expect(await elementHandle.screenshot()).toMatchImageSnapshot({
failureThreshold: 0.2
});
}
);

it("go to correct anchors", async () => {
await page.click('.TOC a[href="#tutorials"]');
await page.click('.TOC a[href="#mean"]');
await page.waitForFunction(() => window.scrollY != 0);

expect(page.url()).toContain("#tutorials");
expect(page.url()).toContain("#mean");
});
});
Loading

0 comments on commit 07f5be2

Please sign in to comment.