Skip to content

Commit da6f92b

Browse files
committed
fix e2e tests that failed on the added deprecation messages
1 parent 585b7d3 commit da6f92b

File tree

3 files changed

+50
-16
lines changed

3 files changed

+50
-16
lines changed

src/core/config.js

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ const defaultDocsifyConfig = () => ({
6464

6565
// Deprecations //////////////////
6666

67-
/** @deprecated */
68-
topMargin: 0,
69-
7067
/** @deprecated */
7168
get themeColor() {
7269
return this.__themeColor;
@@ -78,17 +75,40 @@ const defaultDocsifyConfig = () => ({
7875
// eslint-disable-next-line no-console
7976
console.warn(
8077
stripIndent(`
81-
$docsify.themeColor is deprecated. Use the "--theme-color" theme property to set your theme color.
82-
<style>
83-
:root {
84-
--theme-color: deeppink;
85-
}
86-
</style>
87-
`).trim(),
78+
$docsify.themeColor is deprecated as of v5. Use the "--theme-color" CSS property to customize your theme color.
79+
<style>
80+
:root {
81+
--theme-color: deeppink;
82+
}
83+
</style>
84+
`).trim(),
8885
);
8986
}
9087
},
9188
__themeColor: '',
89+
90+
/** @deprecated */
91+
get topMargin() {
92+
return this.__topMargin;
93+
},
94+
set topMargin(value) {
95+
if (value) {
96+
this.__topMargin = value;
97+
98+
// eslint-disable-next-line no-console
99+
console.warn(
100+
stripIndent(`
101+
$docsify.topMargin is deprecated as of v5. Use the "--scroll-padding-top" CSS property to specify a scroll margin when using a sticky navbar.
102+
<style>
103+
:root {
104+
--scroll-padding-top: 10px;
105+
}
106+
</style>
107+
`).trim(),
108+
);
109+
}
110+
},
111+
__topMargin: 0,
92112
});
93113

94114
/** @typedef {ReturnType<typeof defaultDocsifyConfig>} DocsifyConfig */
@@ -100,14 +120,13 @@ const defaultDocsifyConfig = () => ({
100120
*/
101121
export default function (vm, config = {}) {
102122
if (window.$docsify) {
123+
// eslint-disable-next-line no-console
103124
console.warn(
104125
'DEPRECATION: The global $docsify config variable is deprecated. See the latest getting started docs. https://docsify.js.org/#/quickstart',
105126
);
106127
}
107128

108129
config = Object.assign(
109-
{},
110-
111130
defaultDocsifyConfig(),
112131

113132
// Handle non-function configs no matter what (f.e. plugins assign options onto it)
@@ -156,6 +175,7 @@ export default function (vm, config = {}) {
156175
const val = script.getAttribute('data-' + hyphenate(prop));
157176

158177
if (isPrimitive(val)) {
178+
// eslint-disable-next-line no-console
159179
console.warn(
160180
`DEPRECATION: data-* attributes on the docsify global script (f.e. ${
161181
'data-' + hyphenate(prop)

test/e2e/configuration.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ test.describe('Configuration options', () => {
4141
test('false (throws uncaught errors)', async ({ page }) => {
4242
let consoleMsg, errorMsg;
4343

44-
page.on('console', msg => (consoleMsg = msg.text()));
44+
page.on('console', msg => {
45+
const text = msg.text();
46+
if (text.startsWith('DEPRECATION:')) {return;} // ignore expected deprecation warnings
47+
consoleMsg = text;
48+
});
4549
page.on('pageerror', err => (errorMsg = err.message));
4650

4751
await docsifyInit({

test/e2e/plugins.test.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ test.describe('Plugins', () => {
1616
'ready',
1717
];
1818

19-
page.on('console', msg => consoleMsgs.push(msg.text()));
19+
page.on('console', msg => {
20+
const text = msg.text();
21+
if (text.startsWith('DEPRECATION:')) {return;} // ignore expected deprecation warnings
22+
consoleMsgs.push(text);
23+
});
2024

2125
await docsifyInit({
2226
config: {
@@ -166,8 +170,14 @@ test.describe('Plugins', () => {
166170
page.on('console', async msg => {
167171
for (const arg of msg.args()) {
168172
const val = await arg.jsonValue();
169-
const obj = JSON.parse(val);
170-
obj.response && (routeData = obj);
173+
if (typeof val === 'string' && val.startsWith('DEPRECATION:'))
174+
{continue;}
175+
try {
176+
const obj = typeof val === 'string' ? JSON.parse(val) : val;
177+
obj && obj.response && (routeData = obj);
178+
} catch {
179+
// ignore non-JSON console messages
180+
}
171181
}
172182
});
173183
});

0 commit comments

Comments
 (0)