Skip to content

Commit

Permalink
Merge pull request #53 from sergiomrebelo/readability-constraints
Browse files Browse the repository at this point in the history
Readability constraints
  • Loading branch information
sergiomrebelo authored Aug 28, 2023
2 parents ffa63f0 + 5f4e04f commit 1046352
Show file tree
Hide file tree
Showing 19 changed files with 3,944 additions and 75 deletions.
58 changes: 58 additions & 0 deletions cypress/e2e/evolution.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'cypress-wait-until';

const TESTING_EXAMPLES = [
{text: `Never Mind¶The Bollocks,¶Here's the¶Sex Pistols`}
]

// check if system is evolving
let checkingInterval;

for (let i in TESTING_EXAMPLES) {
let e = TESTING_EXAMPLES[i];
describe(`testing no. ${i} (elitist Mode)`, () => {
beforeEach(() => {
cy.visit(`http://localhost:8000`);
});

it(`a new poster for the text ${e.text} (elite = 1)`, () => {
evolve(e.text, 1);
});

it(`a new poster for the text ${e.text} (no elite)`, () => {
evolve(e.text, 0);
});
});
}


const evolve = (text, elite = 0) => {
cy.get("#formControlTextarea").type(text);
cy.get("#lineDivisionCheck").uncheck();
cy.get('button.btn.btn-primary.mb-2').click();
cy.get('#bt-start-evo').click();
cy.get('#evolve-bt').click();
cy.get('#elite-size-input').invoke('val', elite).trigger('change').then(() => {
cy.get('#start-bt').click();
cy.get('.navbar-toggler-icon').click();
cy.window().then((w) => {
// evolving
cy.wrap(isEvolving(w.app.population), { timeout: 600000 }).then((res) => {
console.log (`evolution is complete (no. generations=${res.nGen})`);
})
});
});
}

const isEvolving = async (pop) => {
return new Promise((resolve, reject) => {
checkingInterval = setInterval(() => {
if (!pop.evolving) {
clearInterval(checkingInterval);
resolve({
type: 'success',
nGen: pop.generations
})
}
}, 10000)
});
}
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"bootstrap": "^5.3.0",
"bootstrap-slider": "^11.0.2",
"cypress": "^12.15.0",
"cypress-wait-until": "^2.0.0",
"jest": "^29.5.0",
"lit": "^2.7.5",
"lodash.clonedeep": "^4.5.0",
Expand Down
Loading

0 comments on commit 1046352

Please sign in to comment.