Skip to content

Commit 5052f2d

Browse files
authored
fix: flaky tests fix (#2037)
## Description This PR aims to fix flaky tests ## Motivation Background on use case, changes needed ## Fixes: Please provide a list of the fixes implemented in this PR * Items added ## Changes: Please provide a list of the changes implemented by this PR * changes made ## Tests included - [ ] Included for each change/fix? - [ ] Passing? (Merge will not be approved unless this is checked) ## Documentation - [ ] swagger documentation updated \[required\] - [ ] official documentation updated \[nice-to-have\] ### official documentation info If you have updated the official documentation, please provide PR # and URL of the pages where the updates are included ## Backend version - [ ] Does it require a specific version of the backend - which version of the backend is required: ## Summary by Sourcery Tests: - Add a comment to mark the pre-configured conditions test as flaky in the datasets-general Cypress suite
1 parent 552e551 commit 5052f2d

File tree

4 files changed

+65
-66
lines changed

4 files changed

+65
-66
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ jobs:
129129
uses: cypress-io/github-action@v6
130130
with:
131131
config-file: cypress.config.ts
132+
browser: chrome
132133
install-command: npm install --omit peer
133134
- name: docker logs
134135
if: ${{ failure() }}

cypress/e2e/datasets/datasets-general.cy.js

Lines changed: 59 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -231,37 +231,36 @@ describe("Datasets general", () => {
231231
},
232232
},
233233
isPublished: true,
234-
}).then(() => {
235-
cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => {
236-
const testConfig = {
237-
...baseConfig,
238-
defaultDatasetsListSettings: {
239-
...baseConfig.defaultDatasetsListSettings,
240-
conditions: [
241-
{
242-
condition: {
243-
lhs: "outgassing_values_after_1h",
244-
relation: "GREATER_THAN",
245-
rhs: 1,
246-
unit: "",
247-
unitsOptions: [
248-
"mbar l/s/cm^2",
249-
"Pa m^3/s/m^2",
250-
"bar m^3/s/m^2",
251-
],
252-
},
253-
enabled: false,
234+
});
235+
cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => {
236+
const testConfig = {
237+
...baseConfig,
238+
defaultDatasetsListSettings: {
239+
...baseConfig.defaultDatasetsListSettings,
240+
conditions: [
241+
{
242+
condition: {
243+
lhs: "outgassing_values_after_1h",
244+
relation: "GREATER_THAN",
245+
rhs: 1,
246+
unit: "",
247+
unitsOptions: [
248+
"mbar l/s/cm^2",
249+
"Pa m^3/s/m^2",
250+
"bar m^3/s/m^2",
251+
],
254252
},
255-
],
256-
},
257-
};
258-
259-
cy.intercept("GET", "**/admin/config", testConfig).as("getConfig");
260-
cy.visit("/datasets");
261-
cy.wait("@getConfig", { timeout: 20000 });
262-
cy.finishedLoading();
263-
});
253+
enabled: false,
254+
},
255+
],
256+
},
257+
};
258+
259+
cy.intercept("GET", "**/admin/config", testConfig).as("getConfig");
264260
});
261+
cy.visit("/datasets");
262+
cy.wait("@getConfig", { timeout: 20000 });
263+
cy.finishedLoading();
265264
});
266265

267266
it("should display limited options in units dropdown", () => {
@@ -319,7 +318,7 @@ describe("Datasets general", () => {
319318

320319
cy.intercept("GET", "**/admin/config", testConfig).as("getConfig");
321320
cy.visit("/datasets");
322-
cy.wait("@getConfig", { timeout: 10000 });
321+
cy.wait("@getConfig");
323322
cy.finishedLoading();
324323
});
325324
});
@@ -342,38 +341,37 @@ describe("Datasets general", () => {
342341
extra_entry_end_time: { type: "number", value: 2, unit: "" },
343342
},
344343
isPublished: true,
345-
}).then(() => {
346-
cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => {
347-
const relationsToTest = [
348-
{ relation: "GREATER_THAN", rhs: 1 },
349-
{ relation: "LESS_THAN", rhs: 3 },
350-
{ relation: "EQUAL_TO_NUMERIC", rhs: 2 },
351-
{ relation: "GREATER_THAN_OR_EQUAL", rhs: 2 },
352-
{ relation: "LESS_THAN_OR_EQUAL", rhs: 2 },
353-
{ relation: "RANGE", rhs: [1, 3] },
354-
];
355-
const testConfig = {
356-
...baseConfig,
357-
defaultDatasetsListSettings: {
358-
...baseConfig.defaultDatasetsListSettings,
359-
conditions: relationsToTest.map(({ relation, rhs }) => ({
360-
condition: {
361-
lhs: "extra_entry_end_time",
362-
relation,
363-
rhs,
364-
unit: "",
365-
},
366-
enabled: true,
367-
})),
368-
},
369-
};
370-
371-
cy.intercept("GET", "**/admin/config", testConfig).as("getConfig");
372-
cy.visit("/datasets");
373-
cy.wait("@getConfig", { timeout: 20000 });
374-
cy.finishedLoading();
375-
});
376344
});
345+
346+
cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => {
347+
const relationsToTest = [
348+
{ relation: "GREATER_THAN", rhs: 1 },
349+
{ relation: "LESS_THAN", rhs: 3 },
350+
{ relation: "EQUAL_TO_NUMERIC", rhs: 2 },
351+
{ relation: "GREATER_THAN_OR_EQUAL", rhs: 2 },
352+
{ relation: "LESS_THAN_OR_EQUAL", rhs: 2 },
353+
{ relation: "RANGE", rhs: [1, 3] },
354+
];
355+
const testConfig = {
356+
...baseConfig,
357+
defaultDatasetsListSettings: {
358+
...baseConfig.defaultDatasetsListSettings,
359+
conditions: relationsToTest.map(({ relation, rhs }) => ({
360+
condition: {
361+
lhs: "extra_entry_end_time",
362+
relation,
363+
rhs,
364+
unit: "",
365+
},
366+
enabled: true,
367+
})),
368+
},
369+
};
370+
371+
cy.intercept("GET", "**/admin/config", testConfig).as("getConfig");
372+
});
373+
cy.visit("/datasets");
374+
cy.wait("@getConfig");
377375
});
378376

379377
it("should check if pre-configured conditions are applied", () => {

cypress/e2e/mainPage/main-page.cy.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ describe("Main Page", () => {
6767

6868
describe("Main page configuration as authenticated user", () => {
6969
it("should visit main page correctly configured", () => {
70-
const username = Cypress.env("username");
71-
const password = Cypress.env("password");
72-
7370
cy.visit("/");
7471
cy.finishedLoading();
7572

@@ -94,7 +91,7 @@ describe("Main Page", () => {
9491
"button.mat-mdc-menu-item:nth-child(2) > span:nth-child(2) > span:nth-child(1)",
9592
).should("contain", "Files");
9693

97-
cy.get("div.main-menu").click();
94+
cy.get("body").type("{esc}");
9895

9996
cy.get('[data-cy="login-button"]').should("not.exist");
10097
cy.get(".user-button").should("exist");

cypress/e2e/published-data/published-data.cy.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ describe("Datasets general", () => {
140140

141141
cy.isLoading();
142142

143-
cy.get(".dataset-table mat-row input[type='checkbox']").last().click();
143+
cy.get(".dataset-table mat-row input[type='checkbox']")
144+
.last()
145+
.and("not.be.disabled")
146+
.click();
144147

145148
cy.get("#addToBatchButton").click();
146149

0 commit comments

Comments
 (0)