Skip to content

Commit

Permalink
Merge branch 'develop' into CP-2607
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarski committed Jul 12, 2024
2 parents 0efcd94 + 137cb71 commit 34c0f81
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ apps/mudita-center/static/sql-wasm*
.nx

matomo-to-gsheet-*.json
allure-results
allure-report
10 changes: 10 additions & 0 deletions apps/mudita-center-e2e/src/specs/news/news-check-offline.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ import {
newsImageRegex,
} from "../../consts/regex-const"
import testsHelper from "../../helpers/tests.helper"
import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"

describe("News Page Check in Offline Mode", () => {
before(async () => {
E2EMockClient.connect()
//wait for a connection to be established
await browser.waitUntil(() => {
return E2EMockClient.checkConnection()
})

// Clear browser cache
await browser.deleteAllCookies()
await browser.execute("window.localStorage.clear();")
Expand Down Expand Up @@ -114,6 +121,9 @@ describe("News Page Check in Offline Mode", () => {
})

after(async () => {
E2EMockClient.stopServer()
E2EMockClient.disconnect()

// Switch back to online mode after finishing the tests
await browser.setNetworkConditions({
offline: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,45 @@

import SettingsPage from "../../page-objects/settings.page"
import NavigationTabs from "../../page-objects/tabs.page"
import ModalPage from "../../page-objects/mc-update-modal.page"
import ModalPage from "../../page-objects/modal.page"
import McUpdateModalPage from "../../page-objects/mc-update-modal.page"
import HomePage from "../../page-objects/home.page"
import TestHelper from "../../helpers/tests.helper"
import testsHelper from "../../helpers/tests.helper"
import dns from "node:dns"
import screenshotHelper from "../../helpers/screenshot.helper"
import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"

describe("Checking for Mudita Center updates", () => {
before(async function () {
if (TestHelper.isLinux()) {
if (testsHelper.isLinux()) {
this.skip()
}

dns.setDefaultResultOrder("ipv4first")
await browser.throttle("offline")
E2EMockClient.connect()
//wait for a connection to be established
await browser.waitUntil(() => {
return E2EMockClient.checkConnection()
})

// Clear browser cache
await browser.deleteAllCookies()
await browser.execute("window.localStorage.clear();")
await browser.execute("window.sessionStorage.clear();")

// Switch to offline mode before starting the tests
await browser.setNetworkConditions({
offline: true,
latency: 0,
download_throughput: 0,
upload_throughput: 0,
})

// Add a small delay to ensure network conditions are applied
await browser.pause(1000)

// Verify network conditions
const isOnline = await testsHelper.isOnline()
await expect(isOnline).toBeFalsy()

const notNowButton = await HomePage.notNowButton
await notNowButton.waitForDisplayed()
Expand All @@ -32,17 +58,6 @@ describe("Checking for Mudita Center updates", () => {
const aboutTab = await SettingsPage.aboutTab
await aboutTab.waitForDisplayed()
await aboutTab.click()

const aboutCheckForUpdateFailedLabel =
await SettingsPage.aboutCheckForUpdateFailedLabel
await browser.executeAsync((done) => {
setTimeout(done, 10000)
})

await expect(aboutCheckForUpdateFailedLabel).toBeDisplayed()
await expect(aboutCheckForUpdateFailedLabel).toHaveText(
"Checking for updates failed"
)
})

it("Check 'Check for updates' button", async () => {
Expand All @@ -61,14 +76,48 @@ describe("Checking for Mudita Center updates", () => {

it("Check for updates", async () => {
const checkingFailedUpdateSubtitle =
await ModalPage.checkingFailedUpdateSubtitle
await McUpdateModalPage.checkingFailedUpdateSubtitle
await expect(checkingFailedUpdateSubtitle).toBeDisplayed()
await expect(checkingFailedUpdateSubtitle).toHaveText("Checking failed")

const checkingFailedUpdateBody = await ModalPage.checkingFailedUpdateBody
const checkingFailedUpdateBody =
await McUpdateModalPage.checkingFailedUpdateBody
await expect(checkingFailedUpdateBody).toBeDisplayed()
await expect(checkingFailedUpdateBody).toHaveText(
"Opps, something went wrong. \nPlease check your internet connection"
)

await ModalPage.closeModalButtonClick()
})
it("Check Settings -> About checking failed label", async () => {
screenshotHelper.makeViewScreenshot()
const aboutCheckForUpdateFailedLabel =
await SettingsPage.aboutCheckForUpdateFailedLabel

await expect(aboutCheckForUpdateFailedLabel).toBeDisplayed()

await expect(aboutCheckForUpdateFailedLabel).toHaveText(
"Checking for updates failed"
)
})

after(async () => {
E2EMockClient.stopServer()
E2EMockClient.disconnect()

// Switch back to online mode after finishing the tests
await browser.setNetworkConditions({
offline: false,
latency: 0,
download_throughput: -1,
upload_throughput: -1,
})

// Add a small delay to ensure network conditions are applied
await browser.pause(1000)

// Verify network conditions
const isOnline = await testsHelper.isOnline()
await expect(isOnline).toBeTruthy()
})
})
40 changes: 34 additions & 6 deletions apps/mudita-center-e2e/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import type { Options } from "@wdio/types"
import * as dotenv from "dotenv"
import { TestFilesPaths, toRelativePath } from "./src/test-filenames"
import allure from "allure-commandline"

dotenv.config()

Expand Down Expand Up @@ -229,11 +230,13 @@ export const config: Options.Testrunner = {
// The only one supported by default is 'dot'
// see also: https://webdriver.io/docs/dot-reporter
reporters: [
"spec",
[
"json",
"allure",
{
outputDir: "./results",
outputDir: "./allure-results",
disableWebdriverStepsReporting: false,
disableWebdriverScreenshotsReporting: false,
addConsoleLogs: true,
},
],
],
Expand Down Expand Up @@ -329,7 +332,6 @@ export const config: Options.Testrunner = {
*/
// afterTest: function(test, context, { error, result, duration, passed, retries }) {
// },

/**
* Hook that gets executed after the suite has ended
* @param {Object} suite suite details
Expand Down Expand Up @@ -369,8 +371,34 @@ export const config: Options.Testrunner = {
* @param {Array.<Object>} capabilities list of capabilities details
* @param {<Object>} results object containing test results
*/
// onComplete: function(exitCode, config, capabilities, results) {
// },
onComplete: function (wdioExitCode, config, capabilities, results) {
const reportError = new Error("Could not generate Allure report")
const generation = allure(["generate", "allure-results", "--clean"])
return new Promise<void>((resolve, reject) => {
const generationTimeout = setTimeout(() => {
console.log("Allure generation timeout")
return reject(reportError)
}, 60 * 1000)

generation.on("exit", function (allureExitCode: number) {
clearTimeout(generationTimeout)
if (allureExitCode !== 0) {
console.log(`Error in allure generation: exit code=${allureExitCode}`)
return reject(reportError)
}
console.log(
"Wdio Test Suite Exit Code: ",
wdioExitCode,
"Allure Exit Code: ",
allureExitCode
)

console.log("Allure Report Generation Success")

return resolve(process.exit(0))
})
})
},
/**
* Gets executed when a refresh happens.
* @param {String} oldSessionId session ID of the old session
Expand Down

0 comments on commit 34c0f81

Please sign in to comment.