Focus on testing Diag UI only, if BE fails, we skip that (#1958)

This commit is contained in:
Cesar Celis Hernandez
2022-05-06 12:27:54 -04:00
committed by GitHub
parent 3bfdbb5ec7
commit 9d052703ad

View File

@@ -17,6 +17,7 @@
import * as roles from "../utils/roles";
import * as elements from "../utils/elements";
import { diagnosticsElement, supportElement } from "../utils/elements-menu";
import { ClientFunction } from 'testcafe';
fixture("For user with Diagnostics permissions").page("http://localhost:9090");
@@ -57,43 +58,88 @@ test("Start Diagnostic button can be clicked", async (t) => {
});
test("Download button exists after Diagnostic is completed", async (t) => {
// MinIO can fail in the diagnostic and this is not UI problem
// If there is an error with diagnostic, don't proceed with UI testing
// Only proceed if there is no error
const matchingElement = ClientFunction(
() =>
document.evaluate("//div[text()='An error occurred while getting Diagnostic file.']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
)
await t
.useRole(roles.diagnostics)
.navigateTo("http://localhost:9090/support/diagnostics")
.click(elements.startDiagnosticButton)
.wait(3000)
.expect(elements.downloadButton.exists)
.ok();
if (await matchingElement() == null) {
// expect button only no error from minio diagnostic
await t
.expect(elements.downloadButton.exists)
.ok();
}
});
test("Download button is clickable after Diagnostic is completed", async (t) => {
// MinIO can fail in the diagnostic and this is not UI problem
// If there is an error with diagnostic, don't proceed with UI testing
// Only proceed if there is no error
const matchingElement = ClientFunction(
() =>
document.evaluate("//div[text()='An error occurred while getting Diagnostic file.']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
)
await t
.useRole(roles.diagnostics)
.navigateTo("http://localhost:9090/support/diagnostics")
.click(elements.startDiagnosticButton)
.wait(2000)
.click(elements.downloadButton);
if (await matchingElement() == null) {
// click only if no error
await t
.click(elements.downloadButton);
}
});
test("Start New Diagnostic button exists after Diagnostic is completed", async (t) => {
// MinIO can fail in the diagnostic and this is not UI problem
// If there is an error with diagnostic, don't proceed with UI testing
// Only proceed if there is no error
const matchingElement = ClientFunction(
() =>
document.evaluate("//div[text()='An error occurred while getting Diagnostic file.']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
)
await t
.useRole(roles.diagnostics)
.navigateTo("http://localhost:9090/support/diagnostics")
.click(elements.startDiagnosticButton)
.wait(3000)
.expect(elements.downloadButton.exists)
.ok()
.expect(elements.startNewDiagnosticButton.exists)
.ok();
if (await matchingElement() == null) {
// expect button only if no error
await t
.expect(elements.downloadButton.exists)
.ok()
.expect(elements.startNewDiagnosticButton.exists)
.ok();
}
});
test("Start New Diagnostic button is clickable after Diagnostic is completed", async (t) => {
// MinIO can fail in the diagnostic and this is not UI problem
// If there is an error with diagnostic, don't proceed with UI testing
// Only proceed if there is no error
const matchingElement = ClientFunction(
() =>
document.evaluate("//div[text()='An error occurred while getting Diagnostic file.']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
)
await t
.useRole(roles.diagnostics)
.navigateTo("http://localhost:9090/support/diagnostics")
.click(elements.startDiagnosticButton)
.wait(3000)
.expect(elements.downloadButton.exists)
.ok()
.click(elements.startNewDiagnosticButton);
if (await matchingElement() == null) {
// expect button only if no error
await t
.expect(elements.downloadButton.exists)
.ok()
.click(elements.startNewDiagnosticButton);
}
});