Skip to content
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
65 changes: 20 additions & 45 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,48 +30,23 @@ jobs:
password: ${{ secrets.TRANSITLOG_DOCKERHUB_TOKEN }}
buildargs: BUILD_ENV=dev
tags: dev
# test-dev:
# needs: deploy-dev
# runs-on: ubuntu-latest
# steps:
# - uses: actions/setup-node@v2
# with:
# node-version: "14"
# - uses: actions/checkout@v2
# with:
# ref: dev
# - name: Sleep for 5 minutes
# uses: jakejarvis/wait-action@master
# with:
# time: "5m"
# - name: Cypress tests
# uses: cypress-io/github-action@v2
# with:
# node-version: "14"
# env:
# CYPRESS_BASE_URL: https://dev.reittiloki.hsldev.com
# CYPRESS_CLIENT_ID: ${{ secrets.CYPRESS_CLIENT_ID }}
# CYPRESS_CLIENT_SECRET: ${{ secrets.CYPRESS_CLIENT_SECRET }}
# CYPRESS_HSL_TESTING_HSLID_USERNAME: ${{ secrets.CYPRESS_HSL_TESTING_HSLID_USERNAME }}
# CYPRESS_HSL_TESTING_HSLID_PASSWORD: ${{ secrets.CYPRESS_HSL_TESTING_HSLID_PASSWORD }}
# - name: Upload screenshot artifacts
# uses: actions/upload-artifact@v1
# if: failure()
# with:
# name: cypress-screenshots
# path: cypress/screenshots
# - name: Upload video artifacts
# uses: actions/upload-artifact@v1
# if: failure()
# with:
# name: cypress-videos
# path: cypress/videos
# - name: Notify of tests
# uses: 8398a7/action-slack@v2
# if: failure()
# with:
# status: ${{ job.status }}
# text: Reittiloki DEV E2E test status
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
test-dev:
runs-on: ubuntu-latest
steps:
- name: Check out PR code
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: "20"
cache: yarn
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run Cypress tests against dev
uses: cypress-io/github-action@v7
with:
install: false
env:
CYPRESS_BASE_URL: https://dev.reittiloki.hsldev.com
configFile: dev

38 changes: 38 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const { defineConfig } = require('cypress')

const envName = process.env.configFile || 'local'

const baseUrls = {
local: 'http://localhost:3000',
dev: 'https://dev.reittiloki.hsldev.com',
production: 'https://reittiloki.hsldev.com',
}

module.exports = defineConfig({

e2e: {
specPattern: 'cypress/e2e/**/*.js',
supportFile: 'cypress/support/e2e.js',
baseUrl: baseUrls[envName] || baseUrls.local,
setupNodeEvents(on, config) {
return config
},
},

retries: {
runMode: 2,
},
viewportWidth: 1366,
viewportHeight: 1200,
watchForFileChanges: false,
defaultCommandTimeout: 240000,
pageLoadTimeout: 180000,
numTestsKeptInMemory: 10,

env: {
AUTH_URI: 'https://hslid-dev.t5.fi/openid/token',
AUTH_SCOPE: 'email https://oneportal.trivore.com/scope/groups.readonly',
},

projectId: 'kz38w3',
})
3 changes: 0 additions & 3 deletions cypress.dev.json

This file was deleted.

14 changes: 0 additions & 14 deletions cypress.json

This file was deleted.

3 changes: 0 additions & 3 deletions cypress.local.json

This file was deleted.

3 changes: 0 additions & 3 deletions cypress.production.json

This file was deleted.

3 changes: 0 additions & 3 deletions cypress.stage.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import moment from "moment";

describe("App opening smoke tests", () => {
beforeEach(() => {
cy.visitAndSpy("/");
Expand All @@ -14,8 +16,10 @@ describe("App opening smoke tests", () => {
});

it("Has the date in the URL", () => {
const currentDate = Cypress.moment().format("YYYY-MM-DD");
cy.url().should((url) => expect(url).to.include(`date=${currentDate}`));
const currentDate = moment().format("YYYY-MM-DD");
cy.url().should((url) => {
expect(url).to.include(`date=${currentDate}`)
});
});

it("Can switch languages", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import moment from "moment";

describe("Area search", () => {
const yesterday = Cypress.moment()
const yesterday = moment()
.subtract(1, "day")
.format("YYYY-MM-DD");

Expand All @@ -8,7 +10,7 @@ describe("Area search", () => {
});

afterEach(() => {
cy.get("@consoleError", {timeout: 1000}).should((errorLog) =>
cy.get("@consoleError", {timeout: 5000}).should((errorLog) =>
expect(errorLog).to.have.callCount(0)
);
});
Expand All @@ -27,14 +29,22 @@ describe("Area search", () => {
cy.getTestElement("time-input").type("08:00");
cy.getTestElement("date-day-decrease").click();

cy.get(".leaflet-draw-draw-rectangle").click();
cy.getTestElement("hfp-area-button").click();

drawRectangle(drawStart, drawEnd);

cy.getTestElement("area-journeys-list").should("exist");
cy.getTestElement("cancel-area-search-button").should("exist");

cy.getTestElement("area-journey-item-journey")
.should("have.length.at.least", 1)
.first()
.should("be.visible")
.click({ force: true });
cy.getTestElement("hfp-area-cancel-button").should("exist");
});

// Bugged. Ticket number 78845
/*
it("Selects an area from URL bounds", () => {
cy.visitAndSpy(
// Select an area in front of Lasipalatsi in Helsinki at 8:00
Expand All @@ -43,18 +53,23 @@ describe("Area search", () => {

cy.getTestElement("area-journeys-list").should("exist");
cy.getTestElement("cancel-area-search-button").should("exist");
});
});*/

it("Selects a journey from the area results", () => {
cy.visitAndSpy(
// Select an area in front of Lasipalatsi in Helsinki at 8:00
`/?selectedBounds=24.93656158447266%2C60.16976407053985%2C24.93827819824219%2C60.17061760538285&time=09%3A00%3A00&date=${yesterday}`
);

cy.getTestElement("area-journeys-list").should("exist");

cy.getTestElement("area-journey-item-journey").should(($items) => {
expect($items.length).to.be.at.least(1);
});

cy.getTestElement("area-journey-item-journey")
.first()
.click({force: true});
.should("be.visible")
.click({ force: true });

cy.getTestElement("sidebar-tab-journeys").should("exist");
cy.getTestElement("journey-details").should("exist");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ describe("Authentication smoke tests", () => {
);
});

// Auth not possible currently with tests
/*
it("Cannot see unauthorized elements when not logged in", () => {
cy.visitAndSpy("/");
cy.getTestElement("authenticated-user").should("not.exist");
Expand All @@ -34,4 +36,5 @@ describe("Authentication smoke tests", () => {
cy.getTestElement("authenticated-user").should("not.exist");
cy.getTestElement("vehicle-search").should("not.exist");
});
*/
});
39 changes: 30 additions & 9 deletions cypress/integration/map.spec.js → cypress/e2e/map.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ describe("Map smoke tests", () => {
});

it("Can change between base maps", () => {
cy.get(".leaflet-control-layers").trigger("mouseover");
cy.contains("Aerial").click();
cy.get(".leaflet-control-layers").invoke("show");
cy.get('.leaflet-control-layers')
.contains('label', 'Aerial')
.find('input[type="radio"]')
.check({ force: true });
cy.get('.leaflet-control-layers')
.contains('label', 'Aerial')
.click({ force: true });
cy.url().should("include", `mapBaseLayer=Aerial`);
cy.contains(
"© Espoon, Helsingin ja Vantaan kaupungit, Kirkkonummen ja Nurmijärven kunnat sekä HSL ja HSY"
Expand All @@ -25,11 +31,26 @@ describe("Map smoke tests", () => {

it("Can display stop radiuses", () => {
cy.visit("/?mapZoom=15");
cy.get(".test-class-stop-marker").should("have.length.least", 2);

cy.get(".test-class-stop-marker").should(($els) => {
expect($els.length).to.be.at.least(2);
});

cy.get(".test-class-stop-radius").should("not.exist");

cy.get(".leaflet-control-layers").trigger("mouseover");
cy.contains("Stop radius").click();
cy.get(".leaflet-control-layers").trigger("mouseenter");

cy.get(".leaflet-control-layers")
.contains("label", "Stop radius")
.find('input[type="checkbox"]')
.as("stopRadiusCheckbox");

cy.get("@stopRadiusCheckbox").should("not.be.checked");

cy.get("@stopRadiusCheckbox").check({ force: true });
cy.get("@stopRadiusCheckbox").check({ force: true });
cy.get("@stopRadiusCheckbox").should("be.checked");

cy.url().should("include", "Stop+radius");

cy.get(".test-class-stop-radius")
Expand All @@ -43,6 +64,7 @@ describe("Map smoke tests", () => {
it("Can display the weather", () => {
cy.get(".leaflet-control-layers").trigger("mouseover");
cy.contains("Weather").click();
cy.contains("Weather").click();
cy.url().should("include", "Weather");

cy.get(".test-class-weather-marker").should("exist");
Expand All @@ -54,10 +76,9 @@ describe("Map smoke tests", () => {
// as we can't know which journeys will trigger it. This
// tests that we can select it in the layer select.
cy.get(".leaflet-control-layers").trigger("mouseover");
cy.contains("Stopped vehicle")
.click()
.click(); // it is selected by default so clicking it once will deselect it.

cy.contains("Stopped vehicle").click();
cy.contains("Stopped vehicle").click();
cy.contains("Stopped vehicle").click();
cy.url().should("include", "Stopped+vehicle");
});
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import moment from "moment";

describe("Route smoke tests", () => {
// Yesterday's data is kept in cache for longer which make the tests faster.
const yesterday = Cypress.moment()
const yesterday = moment()
.subtract(1, "day")
.format("YYYY-MM-DD");

afterEach(() => {
cy.get("@consoleError", {timeout: 1000}).should((errorLog) =>
cy.get("@consoleError", {timeout: 5000}).should((errorLog) =>
expect(errorLog).to.have.callCount(0)
);
});
Expand Down Expand Up @@ -124,7 +126,7 @@ describe("Route smoke tests", () => {
.should("exist")
.click({force: true});

cy.getTestElement("journey-graph-container").should("visible");
cy.getTestElement("journey-graph-container").should("be.visible");
cy.get(".test-class-journey-graph").should("exist");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe("Instructions smoke test", () => {
});

afterEach(() => {
cy.get("@consoleError", {timeout: 1000}).should((errorLog) =>
cy.get("@consoleError", {timeout: 5000}).should((errorLog) =>
expect(errorLog).to.have.callCount(0)
);
});
Expand Down
File renamed without changes.
Loading
Loading