mirror of
				https://github.com/discourse/discourse.git
				synced 2025-02-25 18:55:32 -06:00 
			
		
		
		
	FIX: Handle deprecations correctly in server-side pretty-text (#25059)
`window.deprecationWorkflow` does not exist in the server-side pretty-text environment. This commit fixes the check and adds a general spec for deprecations triggered inside pretty-text
This commit is contained in:
		| @@ -52,7 +52,7 @@ export default function deprecated(msg, options = {}) { | ||||
|   if ( | ||||
|     raiseError || | ||||
|     matchedWorkflow?.handler === "throw" || | ||||
|     (!matchedWorkflow && deprecationWorkflow.throwOnUnhandled) | ||||
|     (!matchedWorkflow && deprecationWorkflow?.throwOnUnhandled) | ||||
|   ) { | ||||
|     throw msg; | ||||
|   } | ||||
|   | ||||
| @@ -2681,4 +2681,16 @@ HTML | ||||
|  | ||||
|     expect(cooked.strip).to eq(html.strip) | ||||
|   end | ||||
|  | ||||
|   it "handles deprecations correctly" do | ||||
|     Rails | ||||
|       .logger | ||||
|       .expects(:warn) | ||||
|       .once | ||||
|       .with("[PrettyText] Deprecation notice: Some deprecation message") | ||||
|  | ||||
|     PrettyText.v8.eval <<~JS | ||||
|       require("discourse-common/lib/deprecated").default("Some deprecation message"); | ||||
|     JS | ||||
|   end | ||||
| end | ||||
|   | ||||
		Reference in New Issue
	
	Block a user