Skip to content

Commit 5b8d175

Browse files
authored
Merge pull request #159 from HSLdevcom/68397-dependency-upgrades
dependecy updates, webpack configuration updates
2 parents bbc9b3d + 9b1cdad commit 5b8d175

15 files changed

Lines changed: 3946 additions & 4078 deletions

.babelrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

.eslintrc.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
module.exports = {
2+
parser: "@babel/eslint-parser",
23
parserOptions: {
3-
ecmaVersion: 2018,
4-
ecmaFeatures: {
5-
jsx: true
6-
}
4+
requireConfigFile: false,
5+
babelOptions: {
6+
presets: ["@babel/preset-env"],
7+
},
78
},
9+
810
extends: ["airbnb", "plugin:prettier/recommended"],
911
rules: {
1012
"no-console": "off",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: 'Dependency scan'
2+
on: [pull_request]
3+
permissions:
4+
contents: read
5+
jobs:
6+
dependency-review:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: 'Checkout Repository'
10+
uses: actions/checkout@v4
11+
- name: 'Dependency Review'
12+
uses: actions/dependency-review-action@v4
13+
with:
14+
fail-on-severity: high

.github/workflows/dev.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v4
1414
- name: Cypress run
1515
uses: cypress-io/github-action@v4
16-
with:
17-
config-file: /cypress.dev.json
1816
env:
1917
CYPRESS_BASE_URL: https://dev.kartat.hsl.fi/kartta
18+
CYPRESS_API_URL: https://dev.kartat.hsl.fi/routemap-api
2019
CYPRESS_HSLID_CLIENT_ID: ${{ secrets.CYPRESS_HSLID_CLIENT_ID }}
2120
CYPRESS_HSLID_CLIENT_SECRET: ${{ secrets.CYPRESS_HSLID_CLIENT_SECRET }}
2221
CYPRESS_TESTING_HSLID_USERNAME: ${{ secrets.CYPRESS_TESTING_HSLID_USERNAME }}

babel.config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": [
3+
["@babel/preset-env"],
4+
["@babel/preset-react", { "runtime": "automatic" }]
5+
]
6+
}

cypress.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const { defineConfig } = require("cypress");
2+
3+
module.exports = defineConfig({
4+
viewportWidth: 1200,
5+
viewportHeight: 1300,
6+
numTestsKeptInMemory: 1,
7+
projectId: "rax4es",
8+
video: true,
9+
e2e: {
10+
specPattern: "cypress/integration/**/*.spec.js",
11+
supportFile: "cypress/support/index.js",
12+
baseUrl: process.env.CYPRESS_BASE_URL || "http://localhost:3000",
13+
env: {
14+
apiUrl: process.env.CYPRESS_API_URL || "http://localhost:4000",
15+
},
16+
},
17+
});

cypress.dev.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

cypress.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

cypress/integration/general.spec.js

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const uuidv4 = require("uuid/v4");
1+
const { v4: uuidv4 } = require("uuid");
22

33
// TODO: Envify here and cypress.json properly
4-
const API_URL = Cypress.config().apiUrl;
4+
const API_URL = Cypress.env("API_URL");
55
const TEST_PREFIX = "CY-TEST";
66

77
describe("Basic functionalities", () => {
@@ -34,8 +34,7 @@ describe("Basic functionalities", () => {
3434

3535
it("Add list, select it for use and show it", () => {
3636
const uuid = `${TEST_PREFIX}-${uuidv4()}`;
37-
cy.server();
38-
cy.route("POST", `${API_URL}/builds`).as("postBuild");
37+
cy.intercept("POST", `${API_URL}/builds`).as("postBuild");
3938

4039
cy.get("[data-cy=toggle-mode-button]").click();
4140
cy.get("[data-cy=new-list-button").click();
@@ -153,14 +152,12 @@ describe("Basic functionalities", () => {
153152
it("Generate poster", () => {
154153
const uuid = `${TEST_PREFIX}-${uuidv4()}`;
155154
const posterName = uuid.substr(0, 5);
156-
cy.server();
157-
cy.route("POST", `${API_URL}/builds`).as("postBuild");
155+
156+
cy.intercept("POST", `${API_URL}/builds`).as("postBuild");
158157

159158
cy.get("[data-cy=toggle-mode-button]").click();
160-
cy.get("[data-cy=new-list-button").click();
161-
cy.get("[data-cy=new-list-name-input]")
162-
.click()
163-
.type(uuid);
159+
cy.get("[data-cy=new-list-button]").click();
160+
cy.get("[data-cy=new-list-name-input]").click().type(uuid);
164161

165162
cy.get("[data-cy=new-list-name-input]").should("have.value", uuid);
166163
cy.get("[data-cy=add-list-button]").click();
@@ -170,33 +167,25 @@ describe("Basic functionalities", () => {
170167
cy.get("[data-cy=select-list-button]").click();
171168

172169
cy.get("[data-cy=size-selector-button]").click();
173-
cy.get("[data-cy=size-selector-width-input]")
174-
.click()
175-
.clear()
176-
.type(200);
177-
cy.get("[data-cy=size-selector-height-input]")
178-
.click()
179-
.clear()
180-
.type(200);
170+
cy.get("[data-cy=size-selector-width-input]").click().clear().type(200);
171+
cy.get("[data-cy=size-selector-height-input]").click().clear().type(200);
181172

182173
cy.get("[data-cy=new-poster-name]").type(posterName);
183-
cy.get("[data-cy=generate-button").click();
184-
cy.get("[data-cy=close-generate-prompt-button").click();
174+
cy.get("[data-cy=generate-button]").click();
175+
cy.get("[data-cy=close-generate-prompt-button]").click();
185176
cy.get("[data-cy=show-list-button]").click();
186177

187-
// 60 seconds should be more than enough for 200x200 poster.
188-
// Better implementation would be to somehow stop waiting after
189-
// polling for build status returns "pending: 0".
190178
cy.wait(60000);
191179
cy.get(`[data-cy=${posterName}]`).contains("READY");
192180

193-
// Remove build
194181
cy.request("GET", `${API_URL}/builds`)
195182
.its("body")
196183
.then((buildArr) => {
197-
const build = buildArr.find((build) => build.title === uuid);
198-
cy.request("DELETE", `${API_URL}/builds/${build.id}`);
199-
});
184+
const build = buildArr.find((b) => b.title === uuid);
185+
if (build) {
186+
cy.request("DELETE", `${API_URL}/builds/${build.id}`);
187+
}
188+
});
200189

201190
cy.get("[data-cy=close-list-modal-button]").click();
202191
});

cypress/support/commands.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ Cypress.Commands.add("hslLogin", () => {
33
const AUTH_SCOPE =
44
"email https://oneportal.trivore.com/scope/groups.readonly";
55

6-
const CLIENT_ID = Cypress.env("CYPRESS_HSLID_CLIENT_ID");
7-
const CLIENT_SECRET = Cypress.env("CYPRESS_HSLID_CLIENT_SECRET");
8-
const HSLID_USERNAME = Cypress.env("CYPRESS_TESTING_HSLID_USERNAME");
9-
const HSLID_PASSWORD = Cypress.env("CYPRESS_TESTING_HSLID_PASSWORD");
6+
const CLIENT_ID = Cypress.env("HSLID_CLIENT_ID");
7+
const CLIENT_SECRET = Cypress.env("HSLID_CLIENT_SECRET");
8+
const HSLID_USERNAME = Cypress.env("TESTING_HSLID_USERNAME");
9+
const HSLID_PASSWORD = Cypress.env("TESTING_HSLID_PASSWORD");
10+
11+
if (!CLIENT_ID || !CLIENT_SECRET) {
12+
throw new Error("Missing HSLID envs");
13+
}
1014

1115
const authHeader = `Basic ${btoa(`${CLIENT_ID}:${CLIENT_SECRET}`)}`;
1216

@@ -26,7 +30,10 @@ Cypress.Commands.add("hslLogin", () => {
2630
}
2731
};
2832

29-
cy.request(options).then((response) => {
33+
cy.request({ ...options, failOnStatusCode: false }).then((response) => {
34+
if (response.status !== 200) {
35+
throw new Error(`Auth failed: ${response.status} ${JSON.stringify(response.body)}`);
36+
}
3037
const {access_token} = response.body;
3138
cy.log(access_token);
3239
expect(response.status).to.eq(200);

0 commit comments

Comments
 (0)