-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1978df6
commit ae9bb71
Showing
3 changed files
with
94 additions
and
2 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
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,38 @@ | ||
import { expect } from 'chai'; | ||
|
||
describe('Global translations', () => { | ||
beforeEach(() => { | ||
cy.intercept('GET', '/api/config', { fixture: 'config.json' }).as('getConfig'); | ||
cy.intercept('GET', '/api/forms-api/global-translations', { fixture: 'formsApiGlobalTranslations.json' }).as( | ||
'getGlobalTranslations', | ||
); | ||
}); | ||
|
||
describe('Skjematekster', () => { | ||
beforeEach(() => { | ||
cy.visit('/oversettelser'); | ||
cy.wait('@getGlobalTranslations'); | ||
}); | ||
|
||
it('Adds new translation', () => { | ||
cy.intercept('POST', '/api/forms-api/global-translations', (req) => { | ||
expect(req.body).to.deep.equal({ | ||
key: 'Ny tekst', | ||
nb: 'Ny tekst', | ||
nn: 'Ny tekst (nynorsk)', | ||
en: 'New text', | ||
tag: 'skjematekster', | ||
}); | ||
req.reply(200, req.body); | ||
}).as('postGlobalTranslation'); | ||
cy.findByRole('textbox', { name: 'Bokmål' }).type('Ny tekst'); | ||
cy.findByRole('textbox', { name: 'Nynorsk' }).type('Ny tekst (nynorsk)'); | ||
cy.findByRole('textbox', { name: 'Engelsk' }).type('New text'); | ||
cy.findByRole('button', { name: 'Lagre' }).click(); | ||
cy.wait('@postGlobalTranslation'); | ||
cy.findByRole('textbox', { name: 'Bokmål' }).should('have.value', ''); | ||
cy.findByRole('textbox', { name: 'Nynorsk' }).should('have.value', ''); | ||
cy.findByRole('textbox', { name: 'Engelsk' }).should('have.value', ''); | ||
}); | ||
}); | ||
}); |
54 changes: 54 additions & 0 deletions
54
packages/bygger/cypress/fixtures/formsApiGlobalTranslations.json
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,54 @@ | ||
[ | ||
{ | ||
"id": 1, | ||
"key": "Ny", | ||
"tag": "skjematekster", | ||
"changedAt": "2024-12-05T14:39:27.512821+01:00", | ||
"changedBy": "Testesen, Test", | ||
"revision": 4, | ||
"nb": "Ny", | ||
"nn": "Ny", | ||
"en": "New", | ||
"publishedAt": null, | ||
"publishedBy": null | ||
}, | ||
{ | ||
"id": 2, | ||
"key": "Nyere", | ||
"tag": "skjematekster", | ||
"changedAt": "2024-12-05T14:39:27.498692+01:00", | ||
"changedBy": "Testesen, Test", | ||
"revision": 3, | ||
"nb": "Nyere", | ||
"nn": "Nyare", | ||
"en": "Newer", | ||
"publishedAt": null, | ||
"publishedBy": null | ||
}, | ||
{ | ||
"id": 3, | ||
"key": "Abc", | ||
"tag": "skjematekster", | ||
"changedAt": "2024-12-05T14:39:27.489663+01:00", | ||
"changedBy": "Testesen, Test", | ||
"revision": 4, | ||
"nb": "Abc", | ||
"nn": "Def", | ||
"en": "Xyz", | ||
"publishedAt": null, | ||
"publishedBy": null | ||
}, | ||
{ | ||
"id": 4, | ||
"key": "Hei", | ||
"tag": "skjematekster", | ||
"changedAt": "2024-12-05T14:39:27.493745+01:00", | ||
"changedBy": "Testesen, Test", | ||
"revision": 6, | ||
"nb": "Hei", | ||
"nn": "", | ||
"en": "Hello", | ||
"publishedAt": null, | ||
"publishedBy": null | ||
} | ||
] |