Skip to content

Commit

Permalink
wip: setup tests with playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
d-koppenhagen committed Sep 13, 2023
1 parent 3756fbb commit 9cb6352
Show file tree
Hide file tree
Showing 39 changed files with 903 additions and 90 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ coverage

# generate types
components/*.d.ts
/test-results/
/playwright-report/
/playwright/.cache/
8 changes: 5 additions & 3 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "vitepress";
import { defineConfig, SiteConfig, UserConfig } from "vitepress";

// https://vitepress.vuejs.org/reference/site-config
export default defineConfig({
export const config: UserConfig = {
// https://MelihAltintas.github.com/vue3-openlayers
// base: '/vue3-openlayers/',
title: "vue3-openlayers",
Expand Down Expand Up @@ -410,4 +410,6 @@ export default defineConfig({
provider: "local",
},
},
});
};

export default defineConfig(config);
49 changes: 49 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
"release:pre": "npm run release -- --preRelease",
"release:rc": "npm run release -- --preRelease",
"test": "vitest",
"test:e2e": "playwright test",
"test:e2e:ui": "npm run test:e2e -- --ui",
"coverage": "vitest run --coverage"
},
"dependencies": {
Expand All @@ -83,6 +85,7 @@
],
"devDependencies": {
"@babel/eslint-parser": "^7.22.9",
"@playwright/test": "^1.37.1",
"@release-it/conventional-changelog": "^7.0.0",
"@types/file-saver": "^2.0.5",
"@types/node": "^18.17.1",
Expand Down
81 changes: 81 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { defineConfig, devices } from "@playwright/test";

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: "./tests",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: "http://localhost:5173",

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",

/* Give the permission to access the geoloaction API and define the location */
permissions: ["geolocation"],
geolocation: { latitude: 50.8551729, longitude: 4.340312 }, // Brussels
},

/* Configure projects for major browsers */
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},

// {
// name: "firefox",
// use: { ...devices["Desktop Firefox"] },
// },

// {
// name: "webkit",
// use: { ...devices["Desktop Safari"] },
// },

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
webServer: {
command: "npm run docs:dev",
url: "http://localhost:5173",
reuseExistingServer: !process.env.CI,
},
});
12 changes: 4 additions & 8 deletions src/demos/AnimatedClusterDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
<ol-source-vector ref="vectorsource">
<ol-feature v-for="index in 500" :key="index">
<ol-geom-point
:coordinates="[
getRandomInRange(24, 45, 3),
getRandomInRange(35, 41, 3),
]"
:coordinates="arrayWith500Points[index - 1]"
></ol-geom-point>
</ol-feature>
</ol-source-vector>
Expand Down Expand Up @@ -64,6 +61,9 @@
<script setup>
import { ref } from "vue";
import { Style, Stroke, Circle, Fill } from "ol/style";
import { arrayWith500Points } from "./points";
console.log(arrayWith500Points);
import markerIcon from "@/assets/marker.png";
Expand Down Expand Up @@ -120,10 +120,6 @@ const overrideStyleFunction = (feature, style) => {
style.getText().setText(size.toString());
};
const getRandomInRange = (from, to, fixed) => {
return (Math.random() * (to - from) + from).toFixed(fixed) * 1;
};
const featureSelected = (event) => {
console.log(event);
};
Expand Down
10 changes: 2 additions & 8 deletions src/demos/AnimatedClusterDemo2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import { computed, ref } from "vue";
import { Point } from "ol/geom";
import Feature from "ol/Feature";
import markerIcon from "@/assets/marker.png";
import { arrayWith500Points } from "./points";
const center = ref([40, 40]);
const projection = ref("EPSG:4326");
Expand All @@ -73,10 +74,7 @@ const count = ref(5000);
const features = computed(() => {
return Array.from({ length: count.value }, (_, i) => {
return new Feature({
geometry: new Point([
getRandomInRange(24, 45, 3),
getRandomInRange(35, 41, 3),
]),
geometry: new Point(arrayWith500Points[index - 1]),
index: i,
});
});
Expand Down Expand Up @@ -107,10 +105,6 @@ const overrideStyleFunction = (feature, style) => {
style.getText().setText(size.toString());
};
const getRandomInRange = (from, to, fixed) => {
return (Math.random() * (to - from) + from).toFixed(fixed) * 1;
};
const featureSelected = (event) => {
console.log(event);
};
Expand Down
15 changes: 3 additions & 12 deletions src/demos/AppDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@
<ol-animation-shake :duration="2000" :repeat="5">
<ol-feature v-for="index in 20" :key="index">
<ol-geom-point
:coordinates="[
getRandomInRange(24, 45, 3),
getRandomInRange(35, 41, 3),
]"
:coordinates="arrayWith500Points[index - 1]"
></ol-geom-point>

<ol-style>
Expand All @@ -187,10 +184,7 @@
<ol-source-vector ref="vectorsource">
<ol-feature v-for="index in 500" :key="index">
<ol-geom-point
:coordinates="[
getRandomInRange(24, 45, 3),
getRandomInRange(35, 41, 3),
]"
:coordinates="arrayWith500Points[index - 1]"
></ol-geom-point>
</ol-feature>
</ol-source-vector>
Expand Down Expand Up @@ -271,6 +265,7 @@ import { ref, inject, onMounted } from "vue";
import markerIcon from "@/assets/marker.png";
import starIcon from "@/assets/star.png";
import { arrayWith500Points } from "./points";
const center = ref([34, 39.13]);
const projection = ref("EPSG:4326");
Expand Down Expand Up @@ -369,10 +364,6 @@ const selectInteactionFilter = (feature) => {
return feature.values_.name != undefined;
};
const getRandomInRange = (from, to, fixed) => {
return (Math.random() * (to - from) + from).toFixed(fixed) * 1;
};
const drawstart = (event) => {
console.log(event);
};
Expand Down
10 changes: 2 additions & 8 deletions src/demos/ClusterDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
<ol-source-vector>
<ol-feature v-for="index in 300" :key="index">
<ol-geom-point
:coordinates="[
getRandomInRange(24, 45, 3),
getRandomInRange(35, 41, 3),
]"
:coordinates="arrayWith500Points[index - 1]"
></ol-geom-point>
</ol-feature>
</ol-source-vector>
Expand All @@ -49,6 +46,7 @@

<script setup>
import { ref } from "vue";
import { arrayWith500Points } from "./points";
const center = ref([34, 39.13]);
const projection = ref("EPSG:4326");
Expand All @@ -61,10 +59,6 @@ const overrideStyleFunction = (feature, style, resolution) => {
const size = clusteredFeatures.length;
style.getText().setText(size.toString());
};
const getRandomInRange = (from, to, fixed) => {
return (Math.random() * (to - from) + from).toFixed(fixed) * 1;
};
</script>

<style>
Expand Down
9 changes: 2 additions & 7 deletions src/demos/DropAnimation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
<ol-animation-drop :duration="2000" :repeat="3">
<ol-feature v-for="index in 20" :key="index">
<ol-geom-point
:coordinates="[
getRandomInRange(24, 45, 3),
getRandomInRange(35, 41, 3),
]"
:coordinates="arrayWith500Points[index - 1]"
></ol-geom-point>

<ol-style>
Expand All @@ -43,12 +40,10 @@
<script setup>
import { ref } from "vue";
import starIcon from "@/assets/star.png";
import { arrayWith500Points } from "./points";
const center = ref([40, 40]);
const projection = ref("EPSG:4326");
const zoom = ref(6);
const rotation = ref(0);
const getRandomInRange = (from, to, fixed) => {
return (Math.random() * (to - from) + from).toFixed(fixed) * 1;
};
</script>
Loading

0 comments on commit 9cb6352

Please sign in to comment.