Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy #4699

Merged
merged 16 commits into from
Oct 3, 2023
Merged

Deploy #4699

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion components/widget/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ class Widget extends PureComponent {
}}
onClick={() => onClickWidget(this.props)}
>
{showPlaceholder && <img src={placeholderImageURL} alt="widget" />}
{showPlaceholder && (
<img data-cy="indonesia-img" src={placeholderImageURL} alt="widget" />
)}
{!showPlaceholder && (
<>
<WidgetHeader
Expand Down
8 changes: 5 additions & 3 deletions components/widgets/fires/burned-area-cumulative/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const defaultConfig = {
fires: 3,
},
settings: {
dataset: 'modis',
dataset: 'modis_burned_area',
firesThreshold: 0,
},
sentences: {
Expand Down Expand Up @@ -151,10 +151,12 @@ export default {
refetchKeys: ['dataset'],
getWidget: (widgetSettings) => {
// called when settings changes
if (widgetSettings?.dataset !== 'modis_burned_area') {
if (!widgetSettings || !widgetSettings.dataset) {
return defaultConfig;
}
if (widgetSettings.dataset !== 'modis_burned_area') {
return firesAlertsCumulative;
}

return defaultConfig;
},
};
8 changes: 5 additions & 3 deletions components/widgets/fires/burned-area-ranked/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const defaultConfig = {
page: 0,
period: 'week',
weeks: 4,
dataset: 'modis',
dataset: 'modis_burned_area',
layerStartDate: null,
layerEndDate: null,
firesThreshold: 0,
Expand Down Expand Up @@ -163,10 +163,12 @@ export default {
refetchKeys: ['dataset'],
getWidget: (widgetSettings) => {
// called when settings changes
if (widgetSettings?.dataset !== 'modis_burned_area') {
if (!widgetSettings || !widgetSettings.dataset) {
return defaultConfig;
}
if (widgetSettings.dataset !== 'modis_burned_area') {
return firesRanked;
}

return defaultConfig;
},
};
2 changes: 1 addition & 1 deletion components/widgets/fires/burned-area/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default {
fires: 1,
},
settings: {
dataset: 'modis',
dataset: 'modis_burned_area',
firesThreshold: 0,
},
sentences: {
Expand Down
2 changes: 1 addition & 1 deletion components/widgets/fires/fire-alerts-simple/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default {
},
// initial settings
settings: {
dataset: 'modis',
dataset: 'viirs',
},
getData: async (params) => {
const { VIIRS } = await handleGfwParamsMeta(params);
Expand Down
2 changes: 1 addition & 1 deletion components/widgets/fires/fires-alerts-cumulative/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default {
fires: 2,
},
settings: {
dataset: 'modis',
dataset: 'viirs',
confidence: 'h',
},
sentences: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
colors: 'fires',
metaKey: 'widget_fire_alert_location',
settings: {
dataset: 'modis',
dataset: 'viirs',
},
datasets: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default {
colors: 'fires',
metaKey: 'widget_fire_alert_location',
settings: {
dataset: 'modis',
dataset: 'viirs',
minDate: '2000-01-01',
confidence: '',
},
Expand Down
2 changes: 1 addition & 1 deletion components/widgets/fires/fires-alerts-historical/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default {
colors: 'fires',
metaKey: 'widget_fire_alert_location',
settings: {
dataset: 'modis',
dataset: 'viirs',
minDate: '2000-01-01',
confidence: '',
},
Expand Down
2 changes: 1 addition & 1 deletion components/widgets/fires/fires-alerts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const defaultConfig = {
fires: 1,
},
settings: {
dataset: 'modis',
dataset: 'viirs',
confidence: 'h',
},
sentences: {
Expand Down
2 changes: 1 addition & 1 deletion components/widgets/fires/fires-ranked/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default {
page: 0,
period: 'week',
weeks: 4,
dataset: 'modis',
dataset: 'viirs',
layerStartDate: null,
layerEndDate: null,
},
Expand Down
2 changes: 1 addition & 1 deletion components/widgets/fires/fires-within/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default {
settings: {
period: 'week',
weeks: 13,
dataset: 'modis',
dataset: 'viirs',
confidence: 'h',
},
settingsBtnConfig: {
Expand Down
37 changes: 37 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { defineConfig } = require('cypress');
const createBundler = require('@bahmutov/cypress-esbuild-preprocessor');
const preprocessor = require('@badeball/cypress-cucumber-preprocessor');
const createEsbuildPlugin = require('@badeball/cypress-cucumber-preprocessor/esbuild');

async function setupNodeEvents(on, config) {
await preprocessor.addCucumberPreprocessorPlugin(on, config);

config.env = {
...process.env,
...config.env,
};

on(
'file:preprocessor',
createBundler({
plugins: [createEsbuildPlugin.default(config)],
})
);

// Make sure to return the config object as it might have been modified by the plugin.
return config;
}

module.exports = defineConfig({
defaultCommandTimeout: 100000,
viewportWidth: 1200,
responseTimeout: 100000,
video: false,
e2e: {
specPattern: '**/*.feature',
supportFile: 'cypress/support/e2e.js',
setupNodeEvents,
baseUrl: 'http://localhost:3000',
scrollBehavior: 'center',
},
});
22 changes: 0 additions & 22 deletions cypress.json

This file was deleted.

12 changes: 12 additions & 0 deletions cypress/api/navigation-api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const goToDashboardFromHome = () => {
cy.visit('/');
cy.get('a.nav-link').contains('Dashboard').click();
};

const selectCountryOnDashboard = (countryName) => {
cy.get('button.arrow-btn').click();
cy.get('input#dropdown-input').type(countryName);
cy.get('#dropdown-item-0').click();
};

export { goToDashboardFromHome, selectCountryOnDashboard };
4 changes: 4 additions & 0 deletions cypress/e2e/features/_example.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Feature: duckduckgo.com
Scenario: visiting the frontpage
When I visit duckduckgo.com
Then I should see a search bar
13 changes: 13 additions & 0 deletions cypress/e2e/features/_example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { When, Then } from '@badeball/cypress-cucumber-preprocessor';

When('I visit duckduckgo.com', () => {
cy.visit('https://www.duckduckgo.com');
});

Then('I should see a search bar', () => {
cy.get('input#searchbox_input').should(
'have.attr',
'placeholder',
'Search the web without being tracked'
);
});
5 changes: 5 additions & 0 deletions cypress/e2e/features/treeCoverLossIndonesia.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Feature: Showing Primary Forest Loss image for Indonesia instead the real widget
Scenario: An user tries to see Indonesia Primary Forest Loss widget
When I visit Dashboard
And I select Indonesia
Then I should see an image of Indonesia Primary Forest Loss
17 changes: 17 additions & 0 deletions cypress/e2e/features/treeCoverLossIndonesia.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { When, Then } from '@badeball/cypress-cucumber-preprocessor';
import {
goToDashboardFromHome,
selectCountryOnDashboard,
} from '../../api/navigation-api';

When('I visit Dashboard', () => {
goToDashboardFromHome();
});

When('I select Indonesia', () => {
selectCountryOnDashboard('Indonesia');
});

Then('I should see an image of Indonesia Primary Forest Loss', () => {
cy.get('[data-cy="indonesia-img"').should('exist');
});
Loading
Loading