diff --git a/.dockerignore b/.dockerignore index 96cfe73..346f424 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,4 @@ var/www/html/node_modules -var/www/html/tests \ No newline at end of file +var/www/html/tests +var/www/html/install-tests.sh +var/www/html/run-tests.sh \ No newline at end of file diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index daedc16..0e578fe 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -68,6 +68,12 @@ jobs: run: | ./var/www/html/run-tests.sh ${{ env.imagetag }} + - name: Upload webdriver screenshots + uses: actions/upload-artifact@v4 + with: + name: webdriver-screenshots + path: ./var/www/html/tests/screens/ + - name: Build and push console:${{ env.imagetag }} uses: docker/build-push-action@v5 with: diff --git a/var/www/html/tests/console.test.js b/var/www/html/tests/console.test.js index 37d727f..fc91ef3 100644 --- a/var/www/html/tests/console.test.js +++ b/var/www/html/tests/console.test.js @@ -1,3 +1,4 @@ +const fs = require('fs').promises; const webdriver = require('selenium-webdriver'); const Chrome = require('selenium-webdriver/chrome'); const options = new Chrome.Options(); @@ -16,7 +17,8 @@ describe('console service front-end tests', function(){ beforeAll(async function(){ driver = await new webdriver.Builder().forBrowser(webdriver.Browser.CHROME).setChromeOptions(options).build(); - }); + await driver.manage().window().setRect({ width: 1400, height: 768 }); + }, 30000); afterAll(async function(){ await driver.quit(); @@ -55,15 +57,19 @@ describe('console service front-end tests', function(){ await driver.get(`${URL}/console`); let table = await driver.findElement(webdriver.By.className("table")); expect(table).not.toBeUndefined(); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/desktops-page.png', encodedString, 'base64'); }) - it("desktops : click on delete no desktop selected, should display error modal", async function(){ + it("desktops : click on delete no desktop selected, should display error toast", async function(){ await driver.findElement(webdriver.By.id("delete-desktop-button")).click(); let failureToastMessage = await driver.findElement(webdriver.By.id("toast-failure-message")); await driver.wait(webdriver.until.elementIsVisible(failureToastMessage), 2000); await failureToastMessage.getText().then(function(text){ expect(text).toBe("Error, no desktop selected"); }); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/desktops-page-error-toast.png', encodedString, 'base64'); }) }); @@ -93,15 +99,19 @@ describe('console service front-end tests', function(){ await driver.get(`${URL}/console/apps.html`); let table = await driver.findElement(webdriver.By.className("table")); expect(table).not.toBeUndefined(); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/apps-page.png', encodedString, 'base64'); }) - it("apps : click on delete but no apps selected, should display error modal", async function(){ + it("apps : click on delete but no apps selected, should display error toast", async function(){ await driver.findElement(webdriver.By.id("delete-app-button")).click(); let failureToastMessage = await driver.findElement(webdriver.By.id("toast-failure-message")); await driver.wait(webdriver.until.elementIsVisible(failureToastMessage), 2000); await failureToastMessage.getText().then(function(text){ expect(text).toBe("Error, no apps selected"); }); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/apps-page-error-toast.png', encodedString, 'base64'); }) it("apps : click on add button, modal should appear", async function(){ @@ -111,6 +121,8 @@ describe('console service front-end tests', function(){ await addAppModal.getAttribute("class").then(function(className){ expect(className.includes("show")).toBe(true); }); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/apps-page-modal-open.png', encodedString, 'base64'); }) it("apps : click on close button, modal should diseappear", async function(){ @@ -121,6 +133,8 @@ describe('console service front-end tests', function(){ await addAppModal.getAttribute("class").then(function(className){ expect(className.includes("show")).toBe(false); }); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/apps-page-modal-close.png', encodedString, 'base64'); }, 10000) }); @@ -150,6 +164,8 @@ describe('console service front-end tests', function(){ await driver.get(`${URL}/console/webfront.html`); let table = await driver.findElement(webdriver.By.className("table")); expect(table).not.toBeUndefined(); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/webfont-page.png', encodedString, 'base64'); }) it("webfront : dock section should not be visible", async function(){ @@ -186,15 +202,19 @@ describe('console service front-end tests', function(){ await driver.get(`${URL}/console/banIp.html`); let table = await driver.findElement(webdriver.By.className("table")); expect(table).not.toBeUndefined(); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/banIP-page.png', encodedString, 'base64'); }) - it("banIp : click on unban but no user selected, should display error modal", async function(){ + it("banIp : click on unban but no user selected, should display error toast", async function(){ await driver.findElement(webdriver.By.id("unban-ip-button")).click(); let failureToastMessage = await driver.findElement(webdriver.By.id("toast-failure-message")); await driver.wait(webdriver.until.elementIsVisible(failureToastMessage), 2000); await failureToastMessage.getText().then(function(text){ expect(text).toBe("Error, no banned user selected"); }); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/banIP-page-error-toast.png', encodedString, 'base64'); }) it("banIp : click on add button, modal should appear", async function(){ @@ -204,6 +224,8 @@ describe('console service front-end tests', function(){ await BanIpModal.getAttribute("class").then(function(className){ expect(className.includes("show")).toBe(true); }); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/banIP-page-modal-open.png', encodedString, 'base64'); }) it("banIp : click on close button, modal should diseappear", async function(){ @@ -214,6 +236,8 @@ describe('console service front-end tests', function(){ await BanIpModal.getAttribute("class").then(function(className){ expect(className.includes("show")).toBe(false); }); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/banIP-page-modal-close.png', encodedString, 'base64'); }, 10000) }); @@ -243,15 +267,19 @@ describe('console service front-end tests', function(){ await driver.get(`${URL}/console/banLogin.html`); let table = await driver.findElement(webdriver.By.className("table")); expect(table).not.toBeUndefined(); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/banLogin-page.png', encodedString, 'base64'); }) - it("banLogin : click on unban but no user selected, should display error modal", async function(){ + it("banLogin : click on unban but no user selected, should display error toast", async function(){ await driver.findElement(webdriver.By.id("unban-login-button")).click(); let failureToastMessage = await driver.findElement(webdriver.By.id("toast-failure-message")); await driver.wait(webdriver.until.elementIsVisible(failureToastMessage), 2000); await failureToastMessage.getText().then(function(text){ expect(text).toBe("Error, no banned user selected"); }); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/banLogin-page-error-toast.png', encodedString, 'base64'); }) it("banLogin : click on add button, modal should appear", async function(){ @@ -261,6 +289,8 @@ describe('console service front-end tests', function(){ await BanLoginModal.getAttribute("class").then(function(className){ expect(className.includes("show")).toBe(true); }); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/banLogin-page-mdoal-open.png', encodedString, 'base64'); }) it("banLogin : click on close button, modal should diseappear", async function(){ @@ -271,6 +301,8 @@ describe('console service front-end tests', function(){ await BanLoginModal.getAttribute("class").then(function(className){ expect(className.includes("show")).toBe(false); }); + let encodedString = await driver.takeScreenshot(); + await fs.writeFile('./tests/screens/banLogin-page-modal-close.png', encodedString, 'base64'); }, 10000) }); diff --git a/var/www/html/tests/screens/.gitkeep b/var/www/html/tests/screens/.gitkeep new file mode 100644 index 0000000..e69de29