@times-components/ssr 2.29.11 → 2.29.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/__tests__/cypress/plugins/index.js +11 -3
- package/__tests__/cypress/support/commands.js +8 -1
- package/__tests__/cypress/support/index.js +61 -0
- package/__tests__/helpers/article-helper.js +48 -1
- package/__tests__/helpers/author-profile-helper.js +10 -0
- package/__tests__/integration/article-indepth.js +9 -1
- package/__tests__/integration/article-magazinecomment.js +9 -1
- package/__tests__/integration/article-magazinestandard.js +9 -1
- package/__tests__/integration/article-maincomment.js +9 -1
- package/__tests__/integration/article-mainstandard-default.js +11 -1
- package/__tests__/integration/article-mainstandard-persisted-query.js +10 -1
- package/__tests__/integration/author-profile-default.js +1 -1
- package/__tests__/integration/author-profile-persisted-query.js +2 -1
- package/__tests__/integration/topic-default.js +1 -1
- package/__tests__/integration/topic-persisted-query.js +2 -1
- package/__tests__/snapshots/article-indepth.js/Article - indepth - Default -- should match snapshots.snap.png +0 -0
- package/__tests__/snapshots/article-magazinecomment.js/Article - magazinecomment - Default -- should match snapshots.snap.png +0 -0
- package/__tests__/snapshots/article-magazinestandard.js/Article - magazinestandard - Default -- should match snapshots.snap.png +0 -0
- package/__tests__/snapshots/article-maincomment.js/Article - maincomment - Default -- should match snapshots.snap.png +0 -0
- package/__tests__/snapshots/article-mainstandard-default.js/Article - mainstandard - Default -- should match snapshots.snap.png +0 -0
- package/__tests__/snapshots/article-mainstandard-persisted-query.js/Article - mainstandard - Persisted Query -- should match snapshots.snap.png +0 -0
- package/__tests__/snapshots/author-profile-default.js/Author Profile - Default -- should match snapshots.snap.png +0 -0
- package/__tests__/snapshots/author-profile-persisted-query.js/Author Profile - Persisted Query -- should match snapshots.snap.png +0 -0
- package/__tests__/snapshots/topic-default.js/Author Profile - Default -- should match snapshots.snap.png +0 -0
- package/cypress.json +2 -1
- package/dist/article.react.bundle.js +1 -1
- package/dist/article.react.bundle.js.map +1 -1
- package/dist/author-profile.react.bundle.js +1 -1
- package/dist/author-profile.react.bundle.js.map +1 -1
- package/dist/common.react.bundle.js +7 -7
- package/dist/common.react.bundle.js.map +1 -1
- package/dist/topic.react.bundle.js +1 -1
- package/dist/topic.react.bundle.js.map +1 -1
- package/package.json +19 -16
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.29.15](https://github.com/newsuk/times-components/compare/@times-components/ssr@2.29.14...@times-components/ssr@2.29.15) (2022-01-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @times-components/ssr
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.29.14](https://github.com/newsuk/times-components/compare/@times-components/ssr@2.29.13...@times-components/ssr@2.29.14) (2022-01-24)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @times-components/ssr
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [2.29.13](https://github.com/newsuk/times-components/compare/@times-components/ssr@2.29.12...@times-components/ssr@2.29.13) (2022-01-24)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @times-components/ssr
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [2.29.12](https://github.com/newsuk/times-components/compare/@times-components/ssr@2.29.11...@times-components/ssr@2.29.12) (2022-01-21)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @times-components/ssr
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## [2.29.11](https://github.com/newsuk/times-components/compare/@times-components/ssr@2.29.10...@times-components/ssr@2.29.11) (2022-01-21)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @times-components/ssr
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
const {
|
|
2
|
+
addMatchImageSnapshotPlugin
|
|
3
|
+
} = require("cypress-image-snapshot/plugin");
|
|
4
|
+
|
|
2
5
|
const mockTpa = require("@times-components/mock-tpa-server");
|
|
3
6
|
|
|
4
|
-
|
|
7
|
+
const failed = require("cypress-failed-log/src/failed");
|
|
8
|
+
|
|
9
|
+
module.exports = (on, config) => {
|
|
10
|
+
addMatchImageSnapshotPlugin(on, config);
|
|
5
11
|
on("task", {
|
|
6
12
|
startMockServerWith(mockData) {
|
|
7
13
|
return mockTpa.startWithMockData(mockData);
|
|
@@ -9,6 +15,8 @@ module.exports = on => {
|
|
|
9
15
|
stopMockServer() {
|
|
10
16
|
return mockTpa.stop();
|
|
11
17
|
},
|
|
12
|
-
failed:
|
|
18
|
+
failed: failed()
|
|
13
19
|
});
|
|
20
|
+
|
|
21
|
+
return config;
|
|
14
22
|
};
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { addMatchImageSnapshotCommand } from "cypress-image-snapshot/command";
|
|
2
|
+
|
|
3
|
+
addMatchImageSnapshotCommand({
|
|
4
|
+
failureThreshold: 0.05,
|
|
5
|
+
failureThresholdType: "percent",
|
|
6
|
+
timeout: "60000"
|
|
7
|
+
});
|
|
8
|
+
|
|
2
9
|
Cypress.Commands.add("goToNextArticle", () => {
|
|
3
10
|
cy.get('div[data-testid="pagination-button-next"]')
|
|
4
11
|
.first()
|
|
@@ -19,6 +19,7 @@ import "cypress-axe";
|
|
|
19
19
|
|
|
20
20
|
// Alternatively you can use CommonJS syntax:
|
|
21
21
|
require("cypress-failed-log");
|
|
22
|
+
require("cypress-wait-until");
|
|
22
23
|
|
|
23
24
|
Cypress.on("fail", error => {
|
|
24
25
|
// debugger;
|
|
@@ -33,3 +34,63 @@ Cypress.on("uncaught:exception", err => {
|
|
|
33
34
|
}
|
|
34
35
|
return true;
|
|
35
36
|
});
|
|
37
|
+
|
|
38
|
+
export const checkDropCapChanges = path => {
|
|
39
|
+
cy.waitUntil(
|
|
40
|
+
() =>
|
|
41
|
+
cy
|
|
42
|
+
.get(path)
|
|
43
|
+
.should("be.visible") // yields <nav>
|
|
44
|
+
.should("have.css", "font-family") // yields 'sans-serif'
|
|
45
|
+
.and("match", /TimesModern-Regular/),
|
|
46
|
+
{
|
|
47
|
+
errorMsg: "Element is not found even after waiting",
|
|
48
|
+
timeout: 10000,
|
|
49
|
+
interval: 500
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const checkShareBarLoaded = path => {
|
|
55
|
+
cy.waitUntil(
|
|
56
|
+
() =>
|
|
57
|
+
cy
|
|
58
|
+
.get(path)
|
|
59
|
+
.should("have.css", "justify-content") // yields 'sans-serif'
|
|
60
|
+
.and("match", /space-between/),
|
|
61
|
+
{
|
|
62
|
+
errorMsg: "Element is not found even after waiting",
|
|
63
|
+
timeout: 10000,
|
|
64
|
+
interval: 500
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const waitUntilSelectorExists = (
|
|
70
|
+
skipDropCapCheck,
|
|
71
|
+
remainingAttempts
|
|
72
|
+
) => {
|
|
73
|
+
let selector = '[class^="responsive__DropCap-sc-"]';
|
|
74
|
+
if (skipDropCapCheck) {
|
|
75
|
+
selector = '[data-testid="save-and-share-bar"]';
|
|
76
|
+
}
|
|
77
|
+
const $el = Cypress.$(selector);
|
|
78
|
+
if ($el.length) {
|
|
79
|
+
// At least one tag was found.
|
|
80
|
+
// Return a jQuery object.
|
|
81
|
+
return $el;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (remainingAttempts - 1) {
|
|
85
|
+
cy.log(`Selector not found yet. Remaining attempts: ${remainingAttempts}`);
|
|
86
|
+
|
|
87
|
+
// Requesting the page to reload (F5)
|
|
88
|
+
cy.reload(true);
|
|
89
|
+
|
|
90
|
+
// Wait a second for the server to respond and the DOM to be updated.
|
|
91
|
+
return cy
|
|
92
|
+
.wait(1000)
|
|
93
|
+
.then(waitUntilSelectorExists(skipDropCapCheck, remainingAttempts));
|
|
94
|
+
}
|
|
95
|
+
throw Error("Selector was not found.");
|
|
96
|
+
};
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { MockArticle, MockUser } from "@times-components/fixture-generator";
|
|
2
|
+
import {
|
|
3
|
+
checkDropCapChanges,
|
|
4
|
+
checkShareBarLoaded,
|
|
5
|
+
waitUntilSelectorExists
|
|
6
|
+
} from "../cypress/support";
|
|
2
7
|
|
|
3
8
|
const relatedArticleCount = 3;
|
|
4
9
|
|
|
@@ -18,7 +23,6 @@ const articleTemplateTest = (template, options = {}) => {
|
|
|
18
23
|
.setRelatedArticles(relatedArticleCount)
|
|
19
24
|
.setTemplate(template)
|
|
20
25
|
.get();
|
|
21
|
-
|
|
22
26
|
userWithBookmarks = new MockUser().setBookmarksTotal(3);
|
|
23
27
|
});
|
|
24
28
|
|
|
@@ -106,6 +110,49 @@ const articleTemplateTest = (template, options = {}) => {
|
|
|
106
110
|
cy.get("script[data-spotim-module]").should("not.exist");
|
|
107
111
|
});
|
|
108
112
|
|
|
113
|
+
it("should match snapshots", () => {
|
|
114
|
+
const {
|
|
115
|
+
stickyElements = [],
|
|
116
|
+
blackoutElements = [],
|
|
117
|
+
attachFlags = false,
|
|
118
|
+
skipDropCapCheck = false,
|
|
119
|
+
skipSnapshotTest = false
|
|
120
|
+
} = options;
|
|
121
|
+
if (skipSnapshotTest) return; // we need to add docker to execute the snapshot testing as viewport is
|
|
122
|
+
// is mismatching while running the test cases on local server. Here is the link to the ticket
|
|
123
|
+
// in which docker server will be used.: https://nidigitalsolutions.jira.com/browse/TDP-1249
|
|
124
|
+
const articleProps =
|
|
125
|
+
(attachFlags && {
|
|
126
|
+
...sundayTimesArticleWithThreeRelatedArticles,
|
|
127
|
+
dropcapsDisabled: false,
|
|
128
|
+
sharingEnabled: true,
|
|
129
|
+
savingEnabled: true
|
|
130
|
+
}) ||
|
|
131
|
+
sundayTimesArticleWithThreeRelatedArticles;
|
|
132
|
+
cy.task("startMockServerWith", {
|
|
133
|
+
Article: articleProps,
|
|
134
|
+
User: userWithBookmarks
|
|
135
|
+
})
|
|
136
|
+
.visit(pageUrl)
|
|
137
|
+
.then(() => {
|
|
138
|
+
if (attachFlags) {
|
|
139
|
+
waitUntilSelectorExists(skipDropCapCheck, 3);
|
|
140
|
+
if (!skipDropCapCheck)
|
|
141
|
+
checkDropCapChanges('[class^="responsive__DropCap-"]');
|
|
142
|
+
checkShareBarLoaded("[data-testid=save-and-share-bar]");
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// changed the position of navigation bar element to absolute, so we don't see
|
|
146
|
+
// duplicate elements floating
|
|
147
|
+
stickyElements.forEach(selector => {
|
|
148
|
+
cy.get(selector).then(el => el.css("position", "absolute"));
|
|
149
|
+
});
|
|
150
|
+
cy.get("body").matchImageSnapshot({
|
|
151
|
+
blackout: blackoutElements
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
109
156
|
it("should pass basic a11y test", () => {
|
|
110
157
|
cy.task("startMockServerWith", {
|
|
111
158
|
Article: sundayTimesArticleWithThreeRelatedArticles,
|
|
@@ -63,5 +63,15 @@ export default (options = {}) => {
|
|
|
63
63
|
});
|
|
64
64
|
cy.checkA11y();
|
|
65
65
|
});
|
|
66
|
+
|
|
67
|
+
it("should match snapshots", () => {
|
|
68
|
+
const { stickyElements = [] } = options;
|
|
69
|
+
// changed the position of navigation bar element to absolute, so we don't see
|
|
70
|
+
// duplicate elements floating
|
|
71
|
+
stickyElements.forEach(selector => {
|
|
72
|
+
cy.get(selector).then(el => el.css("position", "absolute"));
|
|
73
|
+
});
|
|
74
|
+
cy.matchImageSnapshot();
|
|
75
|
+
});
|
|
66
76
|
});
|
|
67
77
|
};
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import articleTests from "../helpers/article-helper";
|
|
2
2
|
|
|
3
|
-
articleTests("indepth"
|
|
3
|
+
articleTests("indepth", {
|
|
4
|
+
stickyElements: ["#nav"],
|
|
5
|
+
attachFlags: true,
|
|
6
|
+
blackoutElements: [
|
|
7
|
+
"[data-testid=save-and-share-bar]",
|
|
8
|
+
'[data-tc-sticky-container="true"]',
|
|
9
|
+
'[class^="sticky-save-and-share-bar__]'
|
|
10
|
+
]
|
|
11
|
+
});
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import articleTests from "../helpers/article-helper";
|
|
2
2
|
|
|
3
|
-
articleTests("magazinecomment"
|
|
3
|
+
articleTests("magazinecomment", {
|
|
4
|
+
stickyElements: ["#nav"],
|
|
5
|
+
attachFlags: true,
|
|
6
|
+
blackoutElements: [
|
|
7
|
+
"[data-testid=save-and-share-bar]",
|
|
8
|
+
'[data-tc-sticky-container="true"]',
|
|
9
|
+
'[class^="sticky-save-and-share-bar__]'
|
|
10
|
+
]
|
|
11
|
+
});
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import articleTests from "../helpers/article-helper";
|
|
2
2
|
|
|
3
|
-
articleTests("magazinestandard"
|
|
3
|
+
articleTests("magazinestandard", {
|
|
4
|
+
stickyElements: ["#nav"],
|
|
5
|
+
attachFlags: true,
|
|
6
|
+
blackoutElements: [
|
|
7
|
+
"[data-testid=save-and-share-bar]",
|
|
8
|
+
'[data-tc-sticky-container="true"]',
|
|
9
|
+
'[class^="sticky-save-and-share-bar__]'
|
|
10
|
+
]
|
|
11
|
+
});
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import articleTests from "../helpers/article-helper";
|
|
2
2
|
|
|
3
|
-
articleTests("maincomment"
|
|
3
|
+
articleTests("maincomment", {
|
|
4
|
+
stickyElements: ["#nav"],
|
|
5
|
+
attachFlags: true,
|
|
6
|
+
blackoutElements: [
|
|
7
|
+
"[data-testid=save-and-share-bar]",
|
|
8
|
+
'[data-tc-sticky-container="true"]',
|
|
9
|
+
'[class^="sticky-save-and-share-bar__]'
|
|
10
|
+
]
|
|
11
|
+
});
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import articleTests from "../helpers/article-helper";
|
|
2
2
|
|
|
3
|
-
articleTests("mainstandard"
|
|
3
|
+
articleTests("mainstandard", {
|
|
4
|
+
stickyElements: ["#nav"],
|
|
5
|
+
attachFlags: true,
|
|
6
|
+
skipDropCapCheck: true,
|
|
7
|
+
skipSnapshotTest: true,
|
|
8
|
+
blackoutElements: [
|
|
9
|
+
"[data-testid=save-and-share-bar]",
|
|
10
|
+
'[data-tc-sticky-container="true"]',
|
|
11
|
+
'[class^="sticky-save-and-share-bar__]'
|
|
12
|
+
]
|
|
13
|
+
});
|
|
@@ -2,5 +2,14 @@ import articleTests from "../helpers/article-helper";
|
|
|
2
2
|
|
|
3
3
|
articleTests("mainstandard", {
|
|
4
4
|
qs: "?pq=1",
|
|
5
|
-
variant: "Persisted Query"
|
|
5
|
+
variant: "Persisted Query",
|
|
6
|
+
stickyElements: ["#nav"],
|
|
7
|
+
skipSnapshotTest: true,
|
|
8
|
+
blackoutElements: [
|
|
9
|
+
"[data-testid=save-and-share-bar]",
|
|
10
|
+
'[data-tc-sticky-container="true"]',
|
|
11
|
+
'[class^="sticky-save-and-share-bar__]'
|
|
12
|
+
],
|
|
13
|
+
attachFlags: true,
|
|
14
|
+
skipDropCapCheck: true
|
|
6
15
|
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|