Skip to content

Commit

Permalink
fix sub-header
Browse files Browse the repository at this point in the history
  • Loading branch information
ArminaAiren committed Jan 4, 2024
1 parent 91c4946 commit 600dc2f
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 19 deletions.
3 changes: 3 additions & 0 deletions playwright/utils/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export const featureEnvs = {
value: '[{"type":"omni","title":"OmniBridge","short_title":"OMNI"},{"type":"amb","title":"Arbitrary Message Bridge","short_title":"AMB"}]',
},
],
txInterpretation: [
{ name: 'NEXT_PUBLIC_TRANSACTION_INTERPRETATION_PROVIDER', value: 'blockscout' },
],
zkRollup: [
{ name: 'NEXT_PUBLIC_IS_ZKEVM_L2_NETWORK', value: 'true' },
{ name: 'NEXT_PUBLIC_L1_BASE_URL', value: 'https://localhost:3101' },
Expand Down
59 changes: 59 additions & 0 deletions ui/tx/TxSubHeading.pw.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { test, expect } from '@playwright/experimental-ct-react';
import React from 'react';

import { txInterpretation } from 'mocks/txs/txInterpretation';
import contextWithEnvs from 'playwright/fixtures/contextWithEnvs';
import TestApp from 'playwright/TestApp';
import buildApiUrl from 'playwright/utils/buildApiUrl';
import * as configs from 'playwright/utils/configs';

import TxSubHeading from './TxSubHeading';

const hash = '0x62d597ebcf3e8d60096dd0363bc2f0f5e2df27ba1dacd696c51aa7c9409f3193';

const TX_INTERPRETATION_API_URL = buildApiUrl('tx_interpretation', { hash });

test('no interpretation +@mobile', async({ mount }) => {
const component = await mount(
<TestApp>
<TxSubHeading hash={ hash } hasTag={ false }/>
</TestApp>,
);

await expect(component).toHaveScreenshot();
});

const bsInterpretationTest = test.extend({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
context: contextWithEnvs(configs.featureEnvs.txInterpretation) as any,
});

bsInterpretationTest('with interpretation +@mobile +@dark-mode', async({ mount, page }) => {
await page.route(TX_INTERPRETATION_API_URL, (route) => route.fulfill({
status: 200,
body: JSON.stringify(txInterpretation),
}));

const component = await mount(
<TestApp>
<TxSubHeading hash={ hash } hasTag={ false }/>
</TestApp>,
);

await expect(component).toHaveScreenshot();
});

bsInterpretationTest('no interpretation', async({ mount, page }) => {
await page.route(TX_INTERPRETATION_API_URL, (route) => route.fulfill({
status: 200,
body: JSON.stringify({ data: { summaries: [] } }),
}));

const component = await mount(
<TestApp>
<TxSubHeading hash={ hash } hasTag={ false }/>
</TestApp>,
);

await expect(component).toHaveScreenshot();
});
4 changes: 2 additions & 2 deletions ui/tx/TxSubHeading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ const TxSubHeading = ({ hash, hasTag }: Props) => {
});

const hasInterpretation = hasInterpretationFeature &&
(txInterpretationQuery.isPlaceholderData || txInterpretationQuery.data?.data.summaries.length);
(txInterpretationQuery.isPlaceholderData || Boolean(txInterpretationQuery.data?.data.summaries.length));

return (
<Box display={{ base: 'block', lg: 'flex' }} alignItems="center" w="100%">
{ hasInterpretationFeature && (
{ hasInterpretation && (
<Flex mr={{ base: 0, lg: 6 }} flexWrap="wrap" alignItems="center">
<TxInterpretation
summary={ txInterpretationQuery.data?.data.summaries[0] }
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 0 additions & 17 deletions ui/tx/interpretation/TxInterpretation.pw.tsx

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 600dc2f

Please sign in to comment.