mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Moved locale testing out of casper fixture (#13850)
refs: https://github.com/TryGhost/Toolbox/issues/137#issuecomment-986829141 - Moving the weird customisation of Casper out of the test fixture - Created a standalone theme for testing locales instead - This should make it easier for us to update our Casper fixture
This commit is contained in:
parent
5d191e90b9
commit
40fee069c9
5 changed files with 32 additions and 13 deletions
|
@ -47,7 +47,7 @@ describe('Themes API', function () {
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
should.exist(jsonResponse.themes);
|
should.exist(jsonResponse.themes);
|
||||||
localUtils.API.checkResponse(jsonResponse, 'themes');
|
localUtils.API.checkResponse(jsonResponse, 'themes');
|
||||||
jsonResponse.themes.length.should.eql(6);
|
jsonResponse.themes.length.should.eql(7);
|
||||||
|
|
||||||
localUtils.API.checkResponse(jsonResponse.themes[0], 'theme');
|
localUtils.API.checkResponse(jsonResponse.themes[0], 'theme');
|
||||||
jsonResponse.themes[0].name.should.eql('broken-theme');
|
jsonResponse.themes[0].name.should.eql('broken-theme');
|
||||||
|
@ -65,19 +65,24 @@ describe('Themes API', function () {
|
||||||
jsonResponse.themes[2].active.should.be.false();
|
jsonResponse.themes[2].active.should.be.false();
|
||||||
|
|
||||||
localUtils.API.checkResponse(jsonResponse.themes[3], 'theme');
|
localUtils.API.checkResponse(jsonResponse.themes[3], 'theme');
|
||||||
jsonResponse.themes[3].name.should.eql('price-data-test-theme');
|
jsonResponse.themes[3].name.should.eql('locale-theme');
|
||||||
jsonResponse.themes[3].package.should.be.an.Object().with.properties('name', 'version');
|
jsonResponse.themes[3].package.should.be.an.Object().with.properties('name', 'version');
|
||||||
jsonResponse.themes[3].active.should.be.false();
|
jsonResponse.themes[3].active.should.be.false();
|
||||||
|
|
||||||
localUtils.API.checkResponse(jsonResponse.themes[4], 'theme');
|
localUtils.API.checkResponse(jsonResponse.themes[4], 'theme');
|
||||||
jsonResponse.themes[4].name.should.eql('test-theme');
|
jsonResponse.themes[4].name.should.eql('price-data-test-theme');
|
||||||
jsonResponse.themes[4].package.should.be.an.Object().with.properties('name', 'version');
|
jsonResponse.themes[4].package.should.be.an.Object().with.properties('name', 'version');
|
||||||
jsonResponse.themes[4].active.should.be.false();
|
jsonResponse.themes[4].active.should.be.false();
|
||||||
|
|
||||||
localUtils.API.checkResponse(jsonResponse.themes[5], 'theme');
|
localUtils.API.checkResponse(jsonResponse.themes[5], 'theme');
|
||||||
jsonResponse.themes[5].name.should.eql('test-theme-channels');
|
jsonResponse.themes[5].name.should.eql('test-theme');
|
||||||
jsonResponse.themes[5].package.should.be.false();
|
jsonResponse.themes[5].package.should.be.an.Object().with.properties('name', 'version');
|
||||||
jsonResponse.themes[5].active.should.be.false();
|
jsonResponse.themes[5].active.should.be.false();
|
||||||
|
|
||||||
|
localUtils.API.checkResponse(jsonResponse.themes[6], 'theme');
|
||||||
|
jsonResponse.themes[6].name.should.eql('test-theme-channels');
|
||||||
|
jsonResponse.themes[6].package.should.be.false();
|
||||||
|
jsonResponse.themes[6].active.should.be.false();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Can download a theme', async function () {
|
it('Can download a theme', async function () {
|
||||||
|
@ -124,7 +129,7 @@ describe('Themes API', function () {
|
||||||
|
|
||||||
should.exist(jsonResponse3.themes);
|
should.exist(jsonResponse3.themes);
|
||||||
localUtils.API.checkResponse(jsonResponse3, 'themes');
|
localUtils.API.checkResponse(jsonResponse3, 'themes');
|
||||||
jsonResponse3.themes.length.should.eql(7);
|
jsonResponse3.themes.length.should.eql(8);
|
||||||
|
|
||||||
// Casper should be present and still active
|
// Casper should be present and still active
|
||||||
const casperTheme = _.find(jsonResponse3.themes, {name: 'casper'});
|
const casperTheme = _.find(jsonResponse3.themes, {name: 'casper'});
|
||||||
|
@ -143,6 +148,7 @@ describe('Themes API', function () {
|
||||||
'broken-theme',
|
'broken-theme',
|
||||||
'casper',
|
'casper',
|
||||||
'casper-1.4',
|
'casper-1.4',
|
||||||
|
'locale-theme',
|
||||||
'price-data-test-theme',
|
'price-data-test-theme',
|
||||||
'test-theme',
|
'test-theme',
|
||||||
'test-theme-channels',
|
'test-theme-channels',
|
||||||
|
@ -167,7 +173,7 @@ describe('Themes API', function () {
|
||||||
tmpFolderContents.splice(i, 1);
|
tmpFolderContents.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmpFolderContents.should.be.an.Array().with.lengthOf(10);
|
tmpFolderContents.should.be.an.Array().with.lengthOf(11);
|
||||||
|
|
||||||
tmpFolderContents.should.eql([
|
tmpFolderContents.should.eql([
|
||||||
'broken-theme',
|
'broken-theme',
|
||||||
|
@ -175,6 +181,7 @@ describe('Themes API', function () {
|
||||||
'casper-1.4',
|
'casper-1.4',
|
||||||
'casper.zip',
|
'casper.zip',
|
||||||
'invalid.zip',
|
'invalid.zip',
|
||||||
|
'locale-theme',
|
||||||
'price-data-test-theme',
|
'price-data-test-theme',
|
||||||
'test-theme',
|
'test-theme',
|
||||||
'test-theme-channels',
|
'test-theme-channels',
|
||||||
|
@ -192,7 +199,7 @@ describe('Themes API', function () {
|
||||||
|
|
||||||
should.exist(jsonResponse2.themes);
|
should.exist(jsonResponse2.themes);
|
||||||
localUtils.API.checkResponse(jsonResponse2, 'themes');
|
localUtils.API.checkResponse(jsonResponse2, 'themes');
|
||||||
jsonResponse2.themes.length.should.eql(6);
|
jsonResponse2.themes.length.should.eql(7);
|
||||||
|
|
||||||
// Casper should be present and still active
|
// Casper should be present and still active
|
||||||
const casperTheme = _.find(jsonResponse2.themes, {name: 'casper'});
|
const casperTheme = _.find(jsonResponse2.themes, {name: 'casper'});
|
||||||
|
@ -234,7 +241,7 @@ describe('Themes API', function () {
|
||||||
|
|
||||||
should.exist(jsonResponse.themes);
|
should.exist(jsonResponse.themes);
|
||||||
localUtils.API.checkResponse(jsonResponse, 'themes');
|
localUtils.API.checkResponse(jsonResponse, 'themes');
|
||||||
jsonResponse.themes.length.should.eql(6);
|
jsonResponse.themes.length.should.eql(7);
|
||||||
|
|
||||||
const casperTheme = _.find(jsonResponse.themes, {name: 'casper'});
|
const casperTheme = _.find(jsonResponse.themes, {name: 'casper'});
|
||||||
should.exist(casperTheme);
|
should.exist(casperTheme);
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe('{{t}} helper', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('theme translation is DE', function () {
|
it('theme translation is DE', function () {
|
||||||
themeI18n.init({activeTheme: 'casper', locale: 'de'});
|
themeI18n.init({activeTheme: 'locale-theme', locale: 'de'});
|
||||||
|
|
||||||
let rendered = t.call({}, 'Top left Button', {
|
let rendered = t.call({}, 'Top left Button', {
|
||||||
hash: {}
|
hash: {}
|
||||||
|
@ -25,7 +25,7 @@ describe('{{t}} helper', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('theme translation is EN', function () {
|
it('theme translation is EN', function () {
|
||||||
themeI18n.init({activeTheme: 'casper', locale: 'en'});
|
themeI18n.init({activeTheme: 'locale-theme', locale: 'en'});
|
||||||
|
|
||||||
let rendered = t.call({}, 'Top left Button', {
|
let rendered = t.call({}, 'Top left Button', {
|
||||||
hash: {}
|
hash: {}
|
||||||
|
@ -35,7 +35,7 @@ describe('{{t}} helper', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('[fallback] no theme translation file found for FR', function () {
|
it('[fallback] no theme translation file found for FR', function () {
|
||||||
themeI18n.init({activeTheme: 'casper', locale: 'fr'});
|
themeI18n.init({activeTheme: 'locale-theme', locale: 'fr'});
|
||||||
|
|
||||||
let rendered = t.call({}, 'Top left Button', {
|
let rendered = t.call({}, 'Top left Button', {
|
||||||
hash: {}
|
hash: {}
|
||||||
|
@ -45,7 +45,7 @@ describe('{{t}} helper', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('[fallback] no theme files at all, use key as translation', function () {
|
it('[fallback] no theme files at all, use key as translation', function () {
|
||||||
themeI18n.init({activeTheme: 'casper-1.4', locale: 'de'});
|
themeI18n.init({activeTheme: 'locale-theme-1.4', locale: 'de'});
|
||||||
|
|
||||||
let rendered = t.call({}, 'Top left Button', {
|
let rendered = t.call({}, 'Top left Button', {
|
||||||
hash: {}
|
hash: {}
|
||||||
|
|
12
test/utils/fixtures/themes/locale-theme/package.json
Normal file
12
test/utils/fixtures/themes/locale-theme/package.json
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"name": "locale-theme",
|
||||||
|
"description": "A fake theme for testing locales.",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"engines": {
|
||||||
|
"ghost-api": "v4"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"config": {
|
||||||
|
"posts_per_page": 5
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue