Explorar o código

[ui-testing] Improve 2 unit tests

Björn Alm hai 1 ano
pai
achega
64dac7fc3d

+ 3 - 0
desktop/core/src/desktop/js/apps/storageBrowser/InputModal/InputModal.test.tsx

@@ -162,6 +162,9 @@ describe('InputModal', () => {
     const cancelButton = within(inputModal).getByRole('button', { name: 'Cancel' });
 
     await user.tab();
+    if (!closeIconButton.matches(':focus')) {
+      await user.tab(); // Tab again if the focus is on the sentinel
+    }
     expect(closeIconButton).toHaveFocus();
     await user.tab();
     expect(inputTextBox).toHaveFocus();

+ 4 - 2
desktop/core/src/desktop/js/components/Duration.test.ts

@@ -19,18 +19,20 @@ import Duration, { duration } from './Duration.vue';
 
 describe('Duration.vue', () => {
   it('should render', () => {
+    const fixedTimestamp = new Date('2024-01-01T00:00:00Z').getTime();
     const wrapper = shallowMount(Duration, {
       propsData: {
-        value: 1234567890
+        value: fixedTimestamp
       }
     });
     expect(wrapper.element).toMatchSnapshot();
   });
 
   it('should render short format', () => {
+    const fixedTimestamp = new Date('2024-01-01T00:00:00Z').getTime();
     const wrapper = shallowMount(Duration, {
       propsData: {
-        value: 1234567890,
+        value: fixedTimestamp,
         short: true
       }
     });

+ 2 - 2
desktop/core/src/desktop/js/components/__snapshots__/Duration.test.ts.snap

@@ -2,12 +2,12 @@
 
 exports[`Duration.vue should render 1`] = `
 <span>
-  342:56:07
+  473352:00:00
 </span>
 `;
 
 exports[`Duration.vue should render short format 1`] = `
 <span>
-  14days
+  54years
 </span>
 `;