-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Translations falling back to english after refreshing the page (#…
…32348) Co-authored-by: Guilherme Gazzo <5263975+ggazzo@users.noreply.github.com>
- Loading branch information
1 parent
cb97723
commit 73c17dc
Showing
3 changed files
with
66 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rocket.chat/meteor": patch | ||
--- | ||
|
||
Fixed an issue where translations would fallback to english some of the times. |
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,55 @@ | ||
import { Users } from './fixtures/userStates'; | ||
import { setSettingValueById } from './utils/setSettingValueById'; | ||
import { setUserPreferences } from './utils/setUserPreferences'; | ||
import { test, expect } from './utils/test'; | ||
|
||
test.use({ storageState: Users.admin.state }); | ||
|
||
test.describe('Translations', () => { | ||
test.beforeAll(async ({ api }) => { | ||
expect((await setUserPreferences(api, { language: '' })).status()).toBe(200); | ||
expect((await setSettingValueById(api, 'Language', 'en')).status()).toBe(200); | ||
expect((await setSettingValueById(api, 'Site_Name', 'Rocket.Chat')).status()).toBe(200); | ||
}); | ||
|
||
test.afterAll(async ({ api }) => { | ||
expect((await setUserPreferences(api, { language: '' })).status()).toBe(200); | ||
expect((await setSettingValueById(api, 'Language', 'en')).status()).toBe(200); | ||
}); | ||
|
||
test("expect to display text in the user's preference language", async ({ page, api }) => { | ||
await page.goto('/home'); | ||
await page.waitForTimeout(5000); | ||
await expect(page.locator('h2')).toHaveText('Welcome to Rocket.Chat'); | ||
|
||
const response = page.waitForResponse('**/i18n/pt-BR.json'); | ||
expect((await setUserPreferences(api, { language: 'pt-BR' })).status()).toBe(200); | ||
await response; | ||
await expect(page.locator('h2')).toHaveText('Bem-vindo ao Rocket.Chat'); | ||
expect((await setUserPreferences(api, { language: '' })).status()).toBe(200); | ||
}); | ||
|
||
test('expect to keep chosen language after refresh', async ({ page, api }) => { | ||
await page.goto('/home'); | ||
await expect(page.locator('h2')).toHaveText('Welcome to Rocket.Chat'); | ||
|
||
const response = page.waitForResponse('**/i18n/pt-BR.json'); | ||
expect((await setUserPreferences(api, { language: 'pt-BR' })).status()).toBe(200); | ||
await response; | ||
await expect(page.locator('h2')).toHaveText('Bem-vindo ao Rocket.Chat'); | ||
|
||
// Test if selected language remaing after refresh | ||
await page.goto('/home'); | ||
await expect(page.locator('h2')).toHaveText('Bem-vindo ao Rocket.Chat'); | ||
|
||
expect((await setUserPreferences(api, { language: '' })).status()).toBe(200); | ||
}); | ||
|
||
test.describe('Browser', async () => { | ||
test.use({ locale: 'pt-BR' }); | ||
test("expect to display text in the browser's language", async ({ page }) => { | ||
await page.goto('/home'); | ||
await expect(page.locator('h2')).toHaveText('Bem-vindo ao Rocket.Chat'); | ||
}); | ||
}); | ||
}); |