Skip to content

Commit

Permalink
Merge pull request #663 from fmidev/feature/611-hide-warnings-panel-f…
Browse files Browse the repository at this point in the history
…or-foreign-locations

issue-611: Hide warning panel for foreign locations
  • Loading branch information
AnttiRumpunen authored Nov 7, 2024
2 parents 7af33e8 + a58b349 commit 54f0bb3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
22 changes: 21 additions & 1 deletion e2e/warnings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ describe('Warnings', () => {
const infoButton = getByID('warnings_info_button');
const infoBottomSheet = getByID('warnings_info_bottom_sheet');
const infoCloseButton = getByID('warnings_info_bottom_sheet_close_button');
const searchButton = getByID('search_header_button');
const searchView = getByID('search_view');
const searchInput = getByID('search_input');
const searchText = 'Berliini';
const searchResultText = 'Berliini, Saksa';
const timeout = 5000;

beforeAll(async () => {
await device.launchApp({
Expand All @@ -23,7 +29,7 @@ describe('Warnings', () => {
await expect(warningsView).toBeVisible();
});

it('should have daily view and webview for Smartmet Alert Client', async () => {
it('should have warnings panel and webview for Smartmet Alert Client', async () => {
await expect(warningsPanel).toBeVisible();
await warningsScrollView.scrollTo('bottom');
await expect(warningsWebView).toBeVisible(50);
Expand All @@ -36,4 +42,18 @@ describe('Warnings', () => {
await infoCloseButton.tap();
await expect(infoBottomSheet).not.toBeVisible();
});

it('should not show warnings panel for foreign locations', async () => {
await searchButton.tap();
await expect(searchView).toBeVisible();
await searchInput.typeText(searchText);
const result = element(by.id('search_result_text').and(by.text(searchResultText)))
await waitFor(result).toBeVisible().withTimeout(timeout)
await result.tap();
await expect(warningsView).toBeVisible();
await expect(warningsPanel).not.toBeVisible();
await warningsScrollView.scrollTo('bottom');
await expect(warningsWebView).toBeVisible(50);
});

});
6 changes: 4 additions & 2 deletions src/screens/WarningsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ const WarningsScreen: React.FC<WarningsScreenProps> = ({
const [warningsUpdated, setWarningsUpdated] = useState<number>(Date.now());

const warningsConfig = Config.get('warnings');
const { useCapView } = warningsConfig;
const { useCapView, apiUrl } = warningsConfig;
const showWarningsPanel =
apiUrl && Object.keys(apiUrl).includes(location.country);

const updateWarnings = useCallback(() => {
if (warningsConfig.enabled) {
Expand Down Expand Up @@ -92,7 +94,7 @@ const WarningsScreen: React.FC<WarningsScreenProps> = ({
<CapWarningsView />
) : (
<>
<WarningsPanel />
{showWarningsPanel && <WarningsPanel />}
<WarningsWebViewPanel
updateInterval={(warningsConfig.updateInterval ?? 5) * 60 * 1000}
/>
Expand Down

0 comments on commit 54f0bb3

Please sign in to comment.