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

Fix playwright tests #205

Merged
merged 2 commits into from
Oct 29, 2024
Merged
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
2 changes: 1 addition & 1 deletion playwright/pages/components/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self, page: Page):

# Page locators
self.search_field = page.get_by_test_id('input-with-suggester')
self.search_button = self.get_button(text='Search')
self.search_button = page.get_by_test_id('searchbar-search-button')

def fill_search_text(self, search_text: str) -> None:
"""Fill up search text"""
Expand Down
36 changes: 25 additions & 11 deletions playwright/pages/js_scripts/map_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ function getMap() {
return getTestProps().getMap();
}

function getHeatmapLayer() {
return getTestProps().getHeatmapLayer();
function getMapLayer() {
if (getTestProps().getClusterLayer) {
return getTestProps().getClusterLayer();
} else if (getTestProps().getHeatmapLayer) {
return getTestProps().getHeatmapLayer();
} else {
throw new Error("No Map layer found");
}
}

function centerMap(lng, lat, zoom) {
Expand All @@ -23,24 +29,32 @@ function isMapLoaded() {

function getMapLayers() {
const map = getMap();
const layer = getHeatmapLayer();
const layer = getMapLayer();
return map.queryRenderedFeatures({ layers: [layer] }).length;
}

function getAUMarineParksLayer() {
return getTestProps().getAUMarineParksLayer
? getTestProps().getAUMarineParksLayer()
: "";
if (getTestProps().getAUMarineParksLayer) {
return getTestProps().getAUMarineParksLayer();
} else {
throw new Error("AU Marine Parks layer not found");
}
}

function getWorldBoundariesLayer() {
return getTestProps().getWorldBoundariesLayer
? getTestProps().getWorldBoundariesLayer()
: "";
if (getTestProps().getWorldBoundariesLayer) {
return getTestProps().getWorldBoundariesLayer();
} else {
throw new Error("World Boundaries layer not found");
}
}

function getSpiderLayer() {
return getTestProps().getSpiderLayer ? getTestProps().getSpiderLayer() : "";
if (getTestProps().getSpiderLayer) {
return getTestProps().getSpiderLayer();
} else {
throw new Error("Spider layer not found");
}
}

function isMapLayerVisible(layerId) {
Expand All @@ -59,7 +73,7 @@ function findAndClickCluster() {
[0, 0],
[width, height],
],
{ layers: ["cluster-count"] }
{ layers: [getMapLayer()] }
);

if (clusters.length > 0) {
Expand Down
6 changes: 4 additions & 2 deletions playwright/tests/detail_page/test_detail_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
('Integrated Marine Observing System (IMOS) - Location of assets'),
],
)

@pytest.mark.skip(reason="Skipping this test because sometimes there is no scroll button if enough space for displaying all tabs")
def test_tab_panel_scroll(page_mock: Page, title: str) -> None:
# Precondition: Tab panel should have scroll buttons
# Set a smaller browser window size to make the tabs scrollable
page_mock.set_viewport_size({'width': 1000, 'height': 800})

landing_page = LandingPage(page_mock)
search_page = SearchPage(page_mock)
detail_page = DetailPage(page_mock)
Expand Down
7 changes: 1 addition & 6 deletions playwright/tests/search_page/test_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pages.landing_page import LandingPage
from pages.search_page import SearchPage


def test_map_drag_updates_search_results(page_mock: Page) -> None:
api_router = ApiRouter(page=page_mock)
landing_page = LandingPage(page_mock)
Expand Down Expand Up @@ -69,8 +70,6 @@ def test_map_datapoint_hover_and_click(
('imos', 'plankton'),
],
)

@pytest.mark.skip(reason="Skipping this test because default layer changed to cluster layer")
def test_map_updates_on_search_change(
page_mock: Page, search_text: str, updated_search_text: str
) -> None:
Expand Down Expand Up @@ -111,8 +110,6 @@ def test_map_updates_on_search_change(
),
],
)

@pytest.mark.skip(reason="Skipping this test because of timeout issue")
def test_map_base_layers(
page_mock: Page, layer_text: str, layer_type: LayerType
) -> None:
Expand Down Expand Up @@ -147,8 +144,6 @@ def test_map_base_layers(
),
],
)

@pytest.mark.skip(reason="Skipping this test because default layer changed to cluster layer")
def test_map_spider(
page_mock: Page,
head_lng: str,
Expand Down
2 changes: 0 additions & 2 deletions playwright/tests/search_page/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ def test_basic_search(
'sort_type',
[SearchSortType.TITLE, SearchSortType.MODIFIED],
)

@pytest.mark.skip(reason="Skipping this test because of timeout issue")
def test_search_result_sort(page_mock: Page, sort_type: SearchSortType) -> None:
api_router = ApiRouter(page=page_mock)
landing_page = LandingPage(page_mock)
Expand Down
9 changes: 1 addition & 8 deletions playwright/tests/search_page/test_search_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pages.landing_page import LandingPage
from pages.search_page import SearchPage

@pytest.mark.skip(reason="Skipping this test because of timeout issue")

def test_map_expand_toggle(page_mock: Page) -> None:
landing_page = LandingPage(page_mock)
search_page = SearchPage(page_mock)
Expand All @@ -26,8 +26,6 @@ def test_map_expand_toggle(page_mock: Page) -> None:
'Grid and Map',
],
)

@pytest.mark.skip(reason="Skipping this test because of timeout issue")
def test_grid_and_map_view(page_mock: Page, view_type: str) -> None:
landing_page = LandingPage(page_mock)
search_page = SearchPage(page_mock)
Expand All @@ -47,8 +45,6 @@ def test_grid_and_map_view(page_mock: Page, view_type: str) -> None:
'Full Map View',
],
)

@pytest.mark.skip(reason="Skipping this test because of timeout issue")
def test_full_map_view(page_mock: Page, view_type: str) -> None:
landing_page = LandingPage(page_mock)
search_page = SearchPage(page_mock)
Expand All @@ -73,9 +69,6 @@ def test_full_map_view(page_mock: Page, view_type: str) -> None:
),
],
)


@pytest.mark.skip(reason="Skipping this test because of timeout issue")
def test_show_more_results(
page_mock: Page,
chunk_1_first_data: str,
Expand Down
1 change: 1 addition & 0 deletions src/components/common/test/helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { mergeWithDefaults } from "../../../utils/ObjectUtils";

interface TestProps {
getMap?: () => Map;
getClusterLayer?: () => string;
getHeatmapLayer?: () => string;
getAUMarineParksLayer?: () => string;
getWorldBoundariesLayer?: () => string;
Expand Down
2 changes: 2 additions & 0 deletions src/components/map/mapbox/layers/ClusterLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from "./Layers";
import SpatialExtents from "../component/SpatialExtents";
import SpiderDiagram from "../component/SpiderDiagram";
import { TestHelper } from "../../../common/test/helper";
import { FeatureCollection, Point } from "geojson";
import { MapDefaultConfig } from "../constants";
import { mergeWithDefaults } from "../../../../utils/ObjectUtils";
Expand Down Expand Up @@ -299,6 +300,7 @@ const ClusterLayer: FC<ClusterLayerProps> = ({
showFullMap={showFullMap}
tabNavigation={tabNavigation}
/>
<TestHelper getHeatmapLayer={() => clusterLayer} />
</>
);
};
Expand Down
1 change: 1 addition & 0 deletions src/components/search/SearchbarExpandableButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const SearchbarExpandableButton: FC<SearchbarExpandableButtonProps> = ({
}}
startIcon={icon}
onClick={onClick}
data-testid={`searchbar-${text.toLowerCase()}-button`}
>
{showText && text}
</Button>
Expand Down
Loading