Skip to content
Snippets Groups Projects
Commit 6f9e3ab8 authored by s87777's avatar s87777
Browse files
parents 1db5fdae f0e8a760
No related branches found
No related tags found
No related merge requests found
# Wir verwenden das Frontend als Proxy, siehe package.json
# Daher ist hier der API-Server das Frontend
REACT_APP_API_SERVER_URL=http://127.0.0.1:80
REACT_APP_API_SERVER_URL=http://localhost:80
# cf. https://github.com/facebook/create-react-app/issues/11762
# related to proxy-setting in package.json
DANGEROUSLY_DISABLE_HOST_CHECK=true
......@@ -11,5 +11,5 @@ DANGEROUSLY_DISABLE_HOST_CHECK=true
PIPELINE_TEST=false
BROWSER_NAME=firefox
USE_REMOTE=0
SL_TEST_REMOTE_URL=http://selenium-hub:4444/wd/hub
SL_TEST_BASE_URL=http://localhost:3000
\ No newline at end of file
REMOTE_URL=http://selenium-hub:4444/wd/hub
BASE_URL=http://localhost:3000
\ No newline at end of file
......@@ -5,6 +5,16 @@ services:
stages:
- test
build-job:
stage: test
script:
- echo $CI_REGISTRY_PASSWORD | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin
- docker build -t registry.bht-berlin.de:443/s87777/profwebfrontend:latest .
- docker push registry.bht-berlin.de:443/s87777/profwebfrontend
tags:
- docker-privileged
test-job:
stage: test
image: node:latest
......@@ -12,9 +22,9 @@ test-job:
FF_NETWORK_PER_BUILD: 1
PIPELINE_TEST: "true"
REACT_APP_API_SERVER_URL: "http://backend:80"
SL_TEST_BASE_URL: "http://frontend:3000"
BASE_URL: "http://frontend:3000"
REMOTE_URL: "http://selenium:4444/wd/hub"
USE_REMOTE: "1"
SL_TEST_REMOTE_URL: "http://selenium:4444/wd/hub"
BROWSER_NAME: "firefox"
services:
- name: registry.bht-berlin.de:443/s87777/profwebbackend:latest
......@@ -24,11 +34,6 @@ test-job:
- name: selenium/standalone-firefox:latest
alias: selenium
script:
- sleep 5
- curl http://backend:80
- curl http://frontend:3000
- curl http://frontend:3000/shopper
- curl http://selenium:4444/wd/hub/status
- echo "installing dependencies"
- npm install
- sleep 5
......
......@@ -11,15 +11,15 @@ describe("Login Test", function () {
const PIPELINE_TEST = process.env.PIPELINE_TEST!;
const BROWSER_NAME = process.env.BROWSER_NAME!;
const USE_REMOTE = process.env.USE_REMOTE!;
const SL_TEST_REMOTE_URL = process.env.SL_TEST_REMOTE_URL!;
const SL_TEST_BASE_URL = process.env.SL_TEST_BASE_URL!;
const REMOTE_URL = process.env.REMOTE_URL!;
const BASE_URL = process.env.BASE_URL!;
beforeEach(async function () {
if (PIPELINE_TEST === "false") {
driver = await new Builder()
.forBrowser("chrome")
.setChromeOptions(new chrome.Options().headless().windowSize({ width: 1920, height: 1080 }))
.setChromeOptions(new chrome.Options().headless())
.build();
await driver.get(`http://localhost:3000`);
await driver.manage().window().maximize();
......@@ -29,13 +29,13 @@ describe("Login Test", function () {
.setChromeOptions(new ChromeOptions().windowSize({ width: 1280, height: 720 }).headless())
.setFirefoxOptions(new FirefoxOptions().windowSize({ width: 1280, height: 720 }).headless());
if (USE_REMOTE === "1") {
builder = builder.usingServer(SL_TEST_REMOTE_URL);
builder = builder.usingServer(REMOTE_URL);
}
driver = await builder.build();
await driver.get(SL_TEST_BASE_URL);
await driver.get(BASE_URL);
driver.manage().window().maximize();
}
},10000);
},15000);
afterEach(async function () {
await driver.quit();
......@@ -44,11 +44,7 @@ describe("Login Test", function () {
it("login with correct credentials", async function () {
const loginButton = await driver.findElement(By.id("loginButton"));
await loginButton.click();
await driver.wait(until.elementLocated(By.id("loginDialog")), 5000);
// Überprüfe, ob der Dialog geöffnet wurde
const isDialogOpen = await driver.findElement(By.id("loginDialog")).isDisplayed();
assert.strictEqual(isDialogOpen, true, "Der Dialog wurde nicht geöffnet.");
await driver.wait(until.elementLocated(By.id("loginDialog")),10000);
const inputMail = await driver.findElement(By.id("inputEmail"));
const inputPassword = await driver.findElement(By.id("inputPassword"));
......@@ -58,17 +54,17 @@ describe("Login Test", function () {
const okButton = await driver.findElement(By.id("okButton"));
await okButton.click();
await driver.wait(until.elementLocated(By.id("logoutButton")), 5000);
await driver.wait(until.elementLocated(By.id("logoutButton")),10000);
const isLogoutButtonOpen = await driver.findElement(By.id("logoutButton")).isDisplayed();
assert.strictEqual(isLogoutButtonOpen, true, "Der Logout Button wird nicht angezeigt.");
},10000);
},15000);
it("test login with wrong credentials", async function () {
// test
await driver.findElement(By.id("loginButton")).click();
await driver.wait(until.elementLocated(By.id("loginDialog")), 5000);
await driver.wait(until.elementLocated(By.id("loginDialog")),10000);
// Überprüfe, ob der Dialog geöffnet wurde
const isDialogOpen = await driver.findElement(By.id("loginDialog")).isDisplayed();
......@@ -83,17 +79,17 @@ describe("Login Test", function () {
const okButton = await driver.findElement(By.id("okButton"));
await okButton.click();
await driver.wait(until.elementLocated(By.id("errorMessage")), 5000);
await driver.wait(until.elementLocated(By.id("errorMessage")),10000);
// Überprüfen, ob eine Fehlermeldung oder ein Verhalten für falsche Anmeldeinformationen angezeigt wird
const isErrorMessageVisible = await driver.findElement(By.id("errorMessage")).isDisplayed();
assert.strictEqual(isErrorMessageVisible, true, "Falsche Anmeldeinformationen werden nicht erkannt.");
},10000);
},15000);
it("user cant see user management", async function () {
const loginButton = await driver.findElement(By.id("loginButton"));
await loginButton.click();
await driver.wait(until.elementLocated(By.id("loginDialog")), 5000);
await driver.wait(until.elementLocated(By.id("loginDialog")),10000);
// Überprüfe, ob der Dialog geöffnet wurde
const isDialogOpen = await driver.findElement(By.id("loginDialog")).isDisplayed();
......@@ -107,7 +103,7 @@ describe("Login Test", function () {
const okButton = await driver.findElement(By.id("okButton"));
await okButton.click();
await driver.wait(until.elementLocated(By.id("logoutButton")), 5000);
await driver.wait(until.elementLocated(By.id("logoutButton")),10000);
const isLogoutButtonOpen = await driver.findElement(By.id("logoutButton")).isDisplayed();
assert.strictEqual(isLogoutButtonOpen, true, "Der Logout Button wird nicht angezeigt.");
......@@ -115,5 +111,5 @@ describe("Login Test", function () {
//dont show user management
const UserManagmentLink = await driver.findElements(By.linkText("UserManagment"));
assert.strictEqual(UserManagmentLink.length, 0, "Der Link zu UserManagment sollte nicht sichtbar sein.");
}, 10000)
}, 15000)
});
......@@ -12,14 +12,14 @@ describe("User Management Test", function () {
const PIPELINE_TEST = process.env.PIPELINE_TEST!;
const BROWSER_NAME = process.env.BROWSER_NAME!;
const USE_REMOTE = process.env.USE_REMOTE!;
const SL_TEST_REMOTE_URL = process.env.SL_TEST_REMOTE_URL!;
const SL_TEST_BASE_URL = process.env.SL_TEST_BASE_URL!;
const REMOTE_URL = process.env.REMOTE_URL!;
const BASE_URL = process.env.BASE_URL!;
beforeEach(async function () {
console.log("Test für Pipeline: " + PIPELINE_TEST);
console.log("Browser: " + BROWSER_NAME);
console.log("Use Server: " + USE_REMOTE);
console.log("Selenium Testing Server: " + SL_TEST_REMOTE_URL);
console.log("Selenium Testing Server: " + REMOTE_URL);
console.log("React-Rest Anbindung: " + process.env.REACT_APP_API_SERVER_URL);
if (PIPELINE_TEST === "false") {
......@@ -35,20 +35,17 @@ describe("User Management Test", function () {
.setChromeOptions(new ChromeOptions().windowSize({ width: 1280, height: 720 }).headless())
.setFirefoxOptions(new FirefoxOptions().windowSize({ width: 1280, height: 720 }).headless());
if (USE_REMOTE === "1") {
builder = builder.usingServer(SL_TEST_REMOTE_URL);
builder = builder.usingServer(REMOTE_URL);
}
driver = await builder.build();
await driver.get(SL_TEST_BASE_URL);
driver.manage().window().maximize();
await driver.get(BASE_URL);
await driver.manage().window().maximize();
}
const loginButton = await driver.findElement(By.id("loginButton"));
await loginButton.click();
await driver.wait(until.elementLocated(By.id("loginDialog")), 5000);
const isDialogOpen = await driver.findElement(By.id("loginDialog")).isDisplayed();
assert.strictEqual(isDialogOpen, true, "Der Dialog wurde nicht geöffnet.");
await driver.wait(until.elementLocated(By.id("loginDialog")),10000);
const inputMail = await driver.findElement(By.id("inputEmail"));
await inputMail.sendKeys("john@some-host.de");
......@@ -57,7 +54,7 @@ describe("User Management Test", function () {
const okButton = await driver.findElement(By.id("okButton"));
await okButton.click();
await driver.wait(until.elementLocated(By.id("logoutButton")), 5000);
await driver.wait(until.elementLocated(By.id("logoutButton")),10000);
const isLogoutButtonOpen = await driver.findElement(By.id("logoutButton")).isDisplayed();
driver.sleep(1000);
assert.strictEqual(isLogoutButtonOpen, true, "Der Logout Button wird nicht angezeigt.");
......@@ -65,10 +62,10 @@ describe("User Management Test", function () {
// click User Management
const clickManagment = driver.findElement(By.linkText("UserManagment"));
await clickManagment.click();
await driver.wait(until.elementLocated(By.id("listUsers")), 5000);
await driver.wait(until.elementLocated(By.id("listUsers")),10000);
const listUsers = await driver.findElement(By.id("listUsers")).isDisplayed();
assert.strictEqual(listUsers, true, "Der Dialog wurde nicht geöffnet.");
}, 10000);
}, 15000);
afterEach(async function () {
await driver.quit();
......@@ -83,7 +80,7 @@ describe("User Management Test", function () {
it("create user", async function () {
driver.findElement(By.id("addUserButton")).click();
await driver.wait(until.elementLocated(By.id("addUserDialog")), 5000);
await driver.wait(until.elementLocated(By.id("addUserDialog")),10000);
const inputUsername = await driver.findElement(By.id("inputUsername"));
const inputMail = await driver.findElement(By.id("inputEmail"));
......@@ -96,15 +93,15 @@ describe("User Management Test", function () {
await addButton.click();
// Überprüfung ob User im Frontend angelegt wurde
await driver.wait(until.elementLocated(By.id("user-Max")), 5000);
await driver.wait(until.elementLocated(By.id("user-Max")),10000);
const userMax = await driver.findElement(By.id("user-Max")).isDisplayed();
assert.strictEqual(userMax, true, "Der User Max wurde nicht gefunden.");
}, 10000);
}, 15000);
it("edit user", async function () {
const editButton = driver.findElement(By.id("editButton-Flo"));
await editButton.click();
await driver.wait(until.elementLocated(By.id("editUserDialog")), 5000);
await driver.wait(until.elementLocated(By.id("editUserDialog")),10000);
const isDialogOpen = await driver.findElement(By.id("editUserDialog")).isDisplayed();
const usernameInput = await driver.findElement(By.id("inputUsername"));
......@@ -116,10 +113,10 @@ describe("User Management Test", function () {
const editNowButton = await driver.findElement(By.id("editNow"));
await editNowButton.click();
await driver.wait(until.elementLocated(By.id("user-Florian")), 5000);
await driver.wait(until.elementLocated(By.id("user-Florian")),10000);
const userFlorianAdmin = await driver.findElement(By.id("user-Florian")).isDisplayed();
assert.strictEqual(userFlorianAdmin, true, "Der User Florian wurde nicht gefunden.");
}, 10000);
}, 15000);
it("delete user", async function () {
const deleteButton = await driver.findElement(By.id("deleteButton-Max"));
......@@ -136,12 +133,12 @@ describe("User Management Test", function () {
);
await driver.sleep(1000);
assert.strictEqual(isMaxDeleted, true, "Der Benutzer 'Max' wurde nicht gelöscht.");
}, 10000);
}, 15000);
it("login with new account", async function () {
const addButton = driver.findElement(By.id("addUserButton"));
await addButton.click();
await driver.wait(until.elementLocated(By.id("addUserDialog")), 5000);
await driver.wait(until.elementLocated(By.id("addUserDialog")),10000);
//Informationen in Dialog eintragen
const inputUsername = await driver.findElement(By.id("inputUsername"));
......@@ -155,7 +152,7 @@ describe("User Management Test", function () {
await addButtonDialog.click();
//Check ob User erstellt
await driver.wait(until.elementLocated(By.id("user-Max")), 5000);
await driver.wait(until.elementLocated(By.id("user-Max")),10000);
const userMax = await driver.findElement(By.id("user-Max")).isDisplayed();
await driver.sleep(1500);
assert.strictEqual(userMax, true, "Der User Max wurde nicht gefunden.");
......@@ -168,7 +165,7 @@ describe("User Management Test", function () {
//Login mit neuen User
const loginButton = await driver.findElement(By.id("loginButton"));
await loginButton.click();
await driver.wait(until.elementLocated(By.id("loginDialog")), 5000);
await driver.wait(until.elementLocated(By.id("loginDialog")),10000);
const emailInput = await driver.findElement(By.id("inputEmail"));
const passwordInput = await driver.findElement(By.id("inputPassword"));
......@@ -178,15 +175,15 @@ describe("User Management Test", function () {
await okButton.click();
//Check ob eingeloggt
await driver.wait(until.elementLocated(By.id("logoutButton")), 5000);
await driver.wait(until.elementLocated(By.id("logoutButton")),10000);
const isLogoutButtonOpenMax = await driver.findElement(By.id("logoutButton")).isDisplayed();
assert.strictEqual(isLogoutButtonOpenMax, true, "Der Logout Button Max wird nicht angezeigt.");
}, 10000);
}, 15000);
it("create User without password ERROR!", async function () {
const addUserButton = driver.findElement(By.id("addUserButton"));
await addUserButton.click();
await driver.wait(until.elementLocated(By.id("addUserDialog")), 5000);
await driver.wait(until.elementLocated(By.id("addUserDialog")),10000);
const inputUsername = await driver.findElement(By.id("inputUsername"));
const inputMail = await driver.findElement(By.id("inputEmail"));
......@@ -198,10 +195,10 @@ describe("User Management Test", function () {
const addButton = await driver.findElement(By.id("addButton"));
await addButton.click();
await driver.wait(until.elementLocated(By.id("warningMessage")), 5000);
await driver.wait(until.elementLocated(By.id("warningMessage")),10000);
const warningMessage = await driver.findElement(By.id("warningMessage")).isDisplayed();
assert.strictEqual(warningMessage, true, "Die Fehlermeldung wurde nicht gefunden.");
}, 10000);
}, 15000);
it("clean up test", async function () {
console.log("Start afterAll");
......@@ -211,7 +208,7 @@ describe("User Management Test", function () {
const editButtonFlo = await driver.findElement(By.id("editButton-Florian"));
await editButtonFlo.click();
await driver.wait(until.elementLocated(By.id("editUserDialog")), 5000);
await driver.wait(until.elementLocated(By.id("editUserDialog")),10000);
const usernameInput = await driver.findElement(By.id("inputUsername"));
usernameInput.clear();
......@@ -225,8 +222,8 @@ describe("User Management Test", function () {
const editNowButton = await driver.findElement(By.id("editNow"));
await editNowButton.click();
await driver.wait(until.elementLocated(By.id("user-Flo")), 5000);
await driver.wait(until.elementLocated(By.id("user-Flo")),10000);
const userFlorianAdmin = await driver.findElement(By.id("user-Flo")).isDisplayed();
assert.strictEqual(userFlorianAdmin, true, "Der User Flo wurde nicht gefunden.");
}, 10000);
}, 15000);
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment