Skip to content

Commit

Permalink
Merge pull request #78 from viqueen/issue/upgrade-deps-wdio
Browse files Browse the repository at this point in the history
[noissue] fix up the visual regression tests
  • Loading branch information
viqueen authored Feb 3, 2024
2 parents 61441d2 + 37fed8d commit f3752e3
Show file tree
Hide file tree
Showing 18 changed files with 2,194 additions and 1,324 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: "yarn"
- run: yarn
- run: yarn build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
registry-url: https://registry.npmjs.org/
cache: "yarn"
- run: yarn
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ module.exports = {
trailingComma: 'none',
},
},
{
files: '*.json',
options: {
trailingComma: 'none',
},
},
],
};
2 changes: 1 addition & 1 deletion local/templates/public/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
18 changes: 12 additions & 6 deletions modules/cli/commands/extract/extract-space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,18 @@ export const extractSpace = async (
title: identifier.title,
createdYear
}))
.reduce((prev, current) => {
const byYear = prev[current.createdYear] || [];
byYear.push(current);
prev[current.createdYear] = byYear;
return prev;
}, {} as Record<number, { href: string; title: string; createdYear: number }[]>);
.reduce(
(prev, current) => {
const byYear = prev[current.createdYear] || [];
byYear.push(current);
prev[current.createdYear] = byYear;
return prev;
},
{} as Record<
number,
{ href: string; title: string; createdYear: number }[]
>
);

const navigation = {
notes,
Expand Down
1 change: 1 addition & 0 deletions modules/external/confluence-api/adf-processor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
/**
* Copyright 2023 Hasnae Rehioui
*
Expand Down
1 change: 1 addition & 0 deletions modules/external/confluence-api/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
/**
* Copyright 2023 Hasnae Rehioui
*
Expand Down
1 change: 1 addition & 0 deletions modules/external/confluence-api/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
/**
* Copyright 2023 Hasnae Rehioui
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const unescapeExcerpt = (excerpt: string) => {
'&amp;': '&',
'&#39;': "'",
'&quot;': '"'
}[element] || element)
})[element] || element
);
};

Expand Down Expand Up @@ -92,6 +92,7 @@ const BlogPostItem = ({ content }: { content: Content }) => {

export const BlogPostsMacro = () => {
const [loading, setLoading] = useState(true);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const [articles, setArticles]: any = useState({});

useEffect(() => {
Expand Down
1 change: 1 addition & 0 deletions modules/site/content/media-viewer-provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React, { useCallback, useState } from 'react';

import noop from 'lodash/noop';
// eslint-disable-next-line import/no-named-as-default
import Lightbox from 'yet-another-react-lightbox';
import Fullscreen from 'yet-another-react-lightbox/plugins/fullscreen';
import Zoom from 'yet-another-react-lightbox/plugins/zoom';
Expand Down
51 changes: 25 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lint": "eslint modules/ --ext .ts,.tsx,.js",
"format:check": "prettier --check .",
"format": "prettier --check --write .",
"wdio": "wdio run wdio.conf.ts"
"wdio": "TS_NODE_PROJECT=test/tsconfig.json wdio run wdio.conf.ts"
},
"repository": {
"type": "git",
Expand All @@ -34,25 +34,24 @@
},
"homepage": "https://github.com/viqueen/confluence-static-site#readme",
"devDependencies": {
"@types/lodash": "^4.14.194",
"@types/prompt": "^1.1.5",
"@types/lodash": "^4.14.202",
"@types/prompt": "^1.1.8",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^5.59.6",
"@typescript-eslint/parser": "^5.59.6",
"@wdio/cli": "^8.6.5",
"@wdio/local-runner": "^8.6.3",
"@wdio/mocha-framework": "^8.6.1",
"@wdio/selenium-standalone-service": "^8.6.2",
"@wdio/spec-reporter": "^8.4.0",
"eslint": "^8.40.0",
"eslint-plugin-import": "^2.27.5",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"@wdio/cli": "^8.29.7",
"@wdio/local-runner": "^8.29.7",
"@wdio/mocha-framework": "^8.29.3",
"@wdio/spec-reporter": "^8.29.7",
"eslint": "^8.56.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-license-notice": "^1.0.0",
"eslint-plugin-react": "^7.32.2",
"prettier": "^2.8.4",
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"typescript": "^5.0.2",
"eslint-plugin-react": "^7.33.2",
"prettier": "^3.2.4",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"wdio-image-comparison-service": "^5.0.2"
},
"dependencies": {
Expand All @@ -65,12 +64,12 @@
"@atlaskit/page-layout": "^1.3.10",
"@atlaskit/renderer": "^107.0.0",
"@labset/fs-directory": "^1.1.0",
"axios": "^1.3.4",
"copy-webpack-plugin": "^11.0.0",
"axios": "^1.6.7",
"copy-webpack-plugin": "^12.0.2",
"crypto-browserify": "^3.12.0",
"css-loader": "^6.7.3",
"dotenv": "^16.0.3",
"html-webpack-plugin": "^5.5.0",
"css-loader": "^6.10.0",
"dotenv": "^16.4.1",
"html-webpack-plugin": "^5.6.0",
"lodash": "^4.17.21",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
Expand All @@ -79,10 +78,10 @@
"react-dom": "^18.2.0",
"sharp": "^0.32.1",
"stream-browserify": "^3.0.0",
"style-loader": "^3.3.2",
"url": "^0.11.0",
"style-loader": "^3.3.4",
"url": "^0.11.3",
"webpack": "^5.85.1",
"webpack-dev-server": "^4.13.1",
"yet-another-react-lightbox": "^2.6.2"
"webpack-dev-server": "^4.15.1",
"yet-another-react-lightbox": "^3.16.0"
}
}
Binary file modified test/baseline/desktop_chrome/home-page-ci-1600x1200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/baseline/desktop_chrome/home-page-local-1600x1200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions test/specs/confluence-static-site.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
describe('Confluence Static Site', () => {
beforeEach(async () => {
const setup = async () => {
await browser.setWindowSize(1600, 1200);
await browser.url('http://localhost:9000/');
await browser.waitUntil(
Expand All @@ -24,13 +24,15 @@ describe('Confluence Static Site', () => {
timeoutMsg: 'expected title to be different after 5s'
}
);
});
};

it('should save some screenshots', async () => {
await setup();
await browser.saveScreen('home-page');
});

it('should compare successfully with a baseline', async () => {
await setup();
const result = await browser.checkScreen('home-page');
expect(result).toEqual(0);
});
Expand Down
3 changes: 1 addition & 2 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"moduleResolution": "node",
"module": "ESNext",
"types": [
"node",
"@wdio/globals/types",
"expect-webdriverio",
"@wdio/mocha-framework",
"@wdio/selenium-standalone-service",
"wdio-image-comparison-service"
],
"target": "es2022"
Expand Down
27 changes: 19 additions & 8 deletions wdio.conf.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright 2023 Hasnae Rehioui
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ChildProcess, spawn } from 'child_process';
import * as path from 'path';

Expand All @@ -7,13 +22,9 @@ const testEnvironment = process.env.TEST_ENVIRONMENT ?? 'local';

let testServerProcess: ChildProcess;

// noinspection JSUnusedGlobalSymbols
export const config: Options.Testrunner = {
runner: 'local',
autoCompileOpts: {
tsNodeOpts: {
project: './test/tsconfig.json'
}
},
specs: ['./test/specs/**/*.e2e.ts'],
exclude: [],
maxInstances: 10,
Expand All @@ -35,7 +46,6 @@ export const config: Options.Testrunner = {
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
services: [
'selenium-standalone',
[
'image-comparison',
{
Expand All @@ -59,8 +69,8 @@ export const config: Options.Testrunner = {
},
/**
* Gets executed once before all workers get launched.
* @param {Object} config wdio configuration object
* @param {Array.<Object>} capabilities list of capabilities details
* @param _config
* @param _capabilities
*/
onPrepare: function (_config, _capabilities) {
testServerProcess = spawn(
Expand All @@ -83,6 +93,7 @@ export const config: Options.Testrunner = {
_exitCode: number,
_config: Omit<Options.Testrunner, 'capabilities'>,
_capabilities,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
_results: any
): unknown | Promise<unknown> {
return testServerProcess.kill();
Expand Down
Loading

0 comments on commit f3752e3

Please sign in to comment.