Skip to content

Commit

Permalink
test: update cypress tests to new budget format
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiphe committed Oct 20, 2020
1 parent 63e4819 commit 25ffaa3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
1 change: 0 additions & 1 deletion cypress/factories/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default function createSettings(
fractionDigits: 2,
startDate: 1562450400000,
startBalance: 0,
numberLocale: 'de-DE',
...settings,
};
}
1 change: 1 addition & 0 deletions cypress/integration/budget.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '../factories';

const COMMON_IGNORED_CHANNELS = [
'UPDATE_LOCALE_COUNTRY_CODE',
'FILE_EDITED',
'SAVE_CANCELED',
'UPDATE_COLOR_PREFERENCES',
Expand Down
8 changes: 3 additions & 5 deletions cypress/integration/new.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('Create New Budget', () => {
cy.open({
waitUntilLoaded: false,
ignoreChannels: [
'UPDATE_LOCALE_COUNTRY_CODE',
'FILE_EDITED',
'SAVE_CANCELED',
'UPDATE_COLOR_PREFERENCES',
Expand All @@ -29,9 +30,6 @@ describe('Create New Budget', () => {

cy.findByLabelText(/Name/i).type('My New Budget');
cy.findByText(accounts[0].name).click();
cy.findByLabelText(/Number format/i)
.type('{selectall}')
.type('de-DE');
cy.bb().then(({ electron: { ipcMain } }) => {
ipcMain.handleOnce('MM_EXPORT_TRANSACTIONS', () => []);
});
Expand All @@ -51,11 +49,10 @@ describe('Create New Budget', () => {
cy.readBudget('/my_new.budget')
.should('include', {
name: 'My New Budget',
version: '0.0.2',
version: '0.0.3',
})
.and('deep.nested.include', {
'settings.accounts': [accounts[0].uuid],
'settings.numberLocale': 'de-DE',
'settings.startDate': 1562457600000,
'settings.incomeCategories': [
{ id: categories[1].uuid, availableIn: 0 },
Expand All @@ -69,6 +66,7 @@ describe('Create New Budget', () => {
cy.open({
waitUntilLoaded: false,
ignoreChannels: [
'UPDATE_LOCALE_COUNTRY_CODE',
'FILE_EDITED',
'SAVE_CANCELED',
'UPDATE_COLOR_PREFERENCES',
Expand Down
6 changes: 3 additions & 3 deletions src/__mocks__/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type Menu<T> = {
getMenuItemById: (id: string) => { enabled: boolean };
};
type PartialRemote = {
app: Pick<Remote['app'], 'name' | 'getPath' | 'getLocale'>;
app: Pick<Remote['app'], 'name' | 'getPath' | 'getLocaleCountryCode'>;
systemPreferences: Pick<
Remote['systemPreferences'],
'getAccentColor' | 'getUserDefault'
Expand All @@ -29,8 +29,8 @@ const remote: PartialRemote = {
getPath(name: string) {
return `/_appPath/${name}`;
},
getLocale() {
return 'en-GB';
getLocaleCountryCode() {
return 'DE';
},
},
systemPreferences: {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/createNumberFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ export function useNumberFormatter(fractionDigits: number) {
const handler = () => {
setLocaleCC(remote.app.getLocaleCountryCode());
};
ipcRenderer.addListener('UPDATE_LOCALE_COUNTRY_CODE', handler);
ipcRenderer.on('UPDATE_LOCALE_COUNTRY_CODE', handler);
return () => {
ipcRenderer.removeListener('UPDATE_LOCALE_COUNTRY_CODE', handler);
ipcRenderer.off('UPDATE_LOCALE_COUNTRY_CODE', handler);
};
}, []);

Expand Down

0 comments on commit 25ffaa3

Please sign in to comment.