[tests] feat: when sampling options, also test different settings for sa, paperless and complete (#225)
This ensures that we catch crashes that only occur with certain options set and/or only with sa and/or complete enabled. Closes #189 Closes #85 Reviewed-on: https://codeberg.org/freesewing/freesewing/pulls/225 Reviewed-by: Joost De Cock <joostdecock@noreply.codeberg.org> Co-authored-by: Jonathan Haas <haasjona@gmail.com> Co-committed-by: Jonathan Haas <haasjona@gmail.com>
This commit is contained in:
parent
5672638bf9
commit
aa9267b3c9
1 changed files with 86 additions and 18 deletions
|
@ -50,6 +50,23 @@ export const testPatternSampling = (Pattern, log = false) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const doesItDraftAndRender = (pattern, log = false) => {
|
||||||
|
try {
|
||||||
|
pattern.draft().render()
|
||||||
|
if (log) {
|
||||||
|
console.log(pattern.store.logs)
|
||||||
|
console.log(pattern.setStores[0].logs)
|
||||||
|
}
|
||||||
|
if (pattern.store.logs.error.length < 1 && pattern.setStores[0].logs.error.length < 1)
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
} catch (err) {
|
||||||
|
if (log) console.log(err)
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sample different measurements
|
* Sample different measurements
|
||||||
*/
|
*/
|
||||||
|
@ -76,25 +93,76 @@ export const testPatternSampling = (Pattern, log = false) => {
|
||||||
* Sample different options
|
* Sample different options
|
||||||
*/
|
*/
|
||||||
describe('Sample options:', () => {
|
describe('Sample options:', () => {
|
||||||
for (const option in config.options) {
|
let hasSampledCoreSettings = false
|
||||||
if (typeof config.options[option] === 'object') {
|
for (const option in config.options) {
|
||||||
it(` Sample ${option}:`, () => {
|
let saValues = [0, 10]
|
||||||
expect(
|
let paperlessValues = [false, true]
|
||||||
doesItSample(
|
let completeValues = [true, false]
|
||||||
new Pattern({
|
if (option.list || option.bool) {
|
||||||
sample: {
|
hasSampledCoreSettings = true
|
||||||
type: 'option',
|
} else {
|
||||||
option,
|
// Performance optimization:
|
||||||
},
|
// sample different sa and paperless/complete settings only for options,
|
||||||
measurements: adult.cisFemale['36'],
|
// which likely change the pattern structure (e.g. enable/disable parts).
|
||||||
}),
|
// These are 'list' and 'bool' options.
|
||||||
log
|
// The hasSampledCoreSettings variable is used to ensure that all variants are tested at least once,
|
||||||
)
|
// even if no such options are present.
|
||||||
).to.equal(true)
|
saValues = [0]
|
||||||
})
|
paperlessValues = [false]
|
||||||
|
completeValues = [true]
|
||||||
|
}
|
||||||
|
for (const sa of saValues) {
|
||||||
|
for (const complete of completeValues) {
|
||||||
|
for (const paperless of paperlessValues) {
|
||||||
|
if (typeof config.options[option] === 'object') {
|
||||||
|
it(` Sample ${option} with sa:${sa} complete:${complete} paperless:${paperless}`, () => {
|
||||||
|
expect(
|
||||||
|
doesItSample(
|
||||||
|
new Pattern({
|
||||||
|
sample: {
|
||||||
|
type: 'option',
|
||||||
|
option,
|
||||||
|
},
|
||||||
|
measurements: adult.cisFemale['36'],
|
||||||
|
sa: sa,
|
||||||
|
complete: complete,
|
||||||
|
paperless: paperless,
|
||||||
|
}),
|
||||||
|
log
|
||||||
|
)
|
||||||
|
).to.equal(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (!hasSampledCoreSettings) {
|
||||||
})
|
// test core settings without sampling a specific option
|
||||||
|
let saValues = [0, 10]
|
||||||
|
let paperlessValues = [false, true]
|
||||||
|
let completeValues = [true, false]
|
||||||
|
for (const sa of saValues) {
|
||||||
|
for (const complete of completeValues) {
|
||||||
|
for (const paperless of paperlessValues) {
|
||||||
|
it(` Draft sa:${sa} complete:${complete} paperless:${paperless}`, () => {
|
||||||
|
expect(
|
||||||
|
doesItDraftAndRender(
|
||||||
|
new Pattern({
|
||||||
|
measurements: adult.cisFemale['36'],
|
||||||
|
sa: sa,
|
||||||
|
complete: complete,
|
||||||
|
paperless: paperless,
|
||||||
|
}),
|
||||||
|
log
|
||||||
|
)
|
||||||
|
).to.equal(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sample pattern for different models
|
* Sample pattern for different models
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue