diff --git a/e2e-tests/cypress/tests/cypress.config.ts b/e2e-tests/cypress/tests/cypress.config.ts
index 0f1d6aa01..e4ae6c34d 100644
--- a/e2e-tests/cypress/tests/cypress.config.ts
+++ b/e2e-tests/cypress/tests/cypress.config.ts
@@ -31,13 +31,16 @@ export default defineConfig({
excludeSpecPattern: "*.js",
baseUrl: 'http://localhost:3000',
chromeWebSecurity: false,
- supportFile: false,
+ supportFile: 'cypress/support/index.ts',
viewportHeight: 720,
viewportWidth: 1280,
retries: {
runMode: 2,
openMode: 0
},
+ env: {
+ backendURL: 'http://localhost:4000',
+ },
setupNodeEvents
}
})
diff --git a/e2e-tests/cypress/tests/cypress/support/e2e.ts b/e2e-tests/cypress/tests/cypress/support/e2e.ts
new file mode 100644
index 000000000..c34292165
--- /dev/null
+++ b/e2e-tests/cypress/tests/cypress/support/e2e.ts
@@ -0,0 +1,26 @@
+Cypress.Commands.add('login', (email, password) => {
+ Cypress.LocalStorage.clear
+
+ cy.request({
+ method: 'POST',
+ url: Cypress.env('backendURL'),
+ body: {
+ "operationName": null,
+ "variables": {
+ "email": email,
+ "password": password
+ },
+ "query": "query ($email: String!, $password: String!, $publisherId: Int) {\n login(email: $email, password: $password, publisherId: $publisherId) {\n email\n firstName\n lastName\n language\n klickTipp {\n newsletterState\n __typename\n }\n hasElopage\n publisherId\n isAdmin\n creation\n __typename\n }\n}\n"
+ }
+ })
+ .then((response) => {
+ let vuexToken = {
+ token : JSON.parse(JSON.stringify(response.headers))['token'],
+ // TODO: how to compute the token time from the token im response?
+ tokenTime : 1663224487
+ };
+
+ cy.visit('/');
+ window.localStorage.setItem('vuex', JSON.stringify(vuexToken));
+ })
+})
\ No newline at end of file
diff --git a/e2e-tests/cypress/tests/cypress/support/index.ts b/e2e-tests/cypress/tests/cypress/support/index.ts
new file mode 100644
index 000000000..b5db7da24
--- /dev/null
+++ b/e2e-tests/cypress/tests/cypress/support/index.ts
@@ -0,0 +1,11 @@
+///
+
+import './e2e';
+
+declare global {
+ namespace Cypress {
+ interface Chainable {
+ login(email: string, password: string): Chainable
+ }
+ }
+}
\ No newline at end of file
diff --git a/e2e-tests/cypress/tests/tsconfig.json b/e2e-tests/cypress/tests/tsconfig.json
index e9739ec00..c031a126e 100644
--- a/e2e-tests/cypress/tests/tsconfig.json
+++ b/e2e-tests/cypress/tests/tsconfig.json
@@ -3,8 +3,8 @@
"target": "es2016",
"lib": ["es6", "dom"],
"baseUrl": "../node_modules",
- "types": ["cypress", "node"],
- "strict": true
+ "types": ["cypress", "node"],
+ "strict": true
},
"include": ["**/*.ts"]
}