Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set relativeLinkPrefix before setting titlePageURI
* Fixes the inconsistency reported in T155070 where internal cite links were missing the "./" prefix. * Since parser tests cannot easily verify this expectation (which is how we couldn't catch this in the first place), added a mocha test as a regression spec to ensure that internal cite links continue to use "./" prefixed urls. Change-Id: Id028ebcd496563fc77b85700780c572b3cc267f2
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
/*global describe, it*/ | ||
|
||
require('../../core-upgrade.js'); | ||
require("chai").should(); | ||
var ParsoidConfig = require('../../lib/config/ParsoidConfig.js').ParsoidConfig; | ||
var helpers = require('./test.helpers.js'); | ||
|
||
// FIXME: MWParserEnvironment.getParserEnv and switchToConfig both require | ||
// mwApiMap to be setup. This forces us to load WMF config. Fixing this | ||
// will require some changes to ParsoidConfig and MWParserEnvironment. | ||
var parsoidConfig = new ParsoidConfig(null, { loadWMF: true, defaultWiki: 'enwiki' }); | ||
var parse = function(src, options) { | ||
return helpers.parse(parsoidConfig, src, options).then(function(ret) { | ||
return ret.doc; | ||
}); | ||
}; | ||
|
||
// These are regression specs for when we fix bugs that cannot be easily | ||
// verified with the parser tests framework | ||
describe('Regression Specs', function() { | ||
|
||
// Wikilinks use ./ prefixed urls. For reasons of consistency, | ||
// we should use a similar format for internal cite urls. | ||
// This spec ensures that we don't inadvertently break that requirement. | ||
it('should use ./ prefixed urls for cite links', function() { | ||
return parse('a [[Foo]] <ref>b</ref>').then(function(result) { | ||
result.body.querySelector(".mw-ref a").getAttribute('href'). | ||
should.equal('./Main_Page#cite_note-1'); | ||
result.body.querySelector("#cite_note-1 a").getAttribute('href'). | ||
should.equal('./Main_Page#cite_ref-1'); | ||
}); | ||
}); | ||
|
||
}); |