Add E2E tests using Cypress

This commit is contained in:
Misode
2021-12-26 02:48:21 +01:00
parent 1e4f82129a
commit ffb2949f05
16 changed files with 2941 additions and 16 deletions

View File

@@ -25,7 +25,7 @@ const FORMATS: Record<string, {
}> = {
json: {
parse: json.parse,
stringify: (v, i) => json.stringify(v, null, i),
stringify: (v, i) => json.stringify(v, null, i) + '\n',
},
yaml: {
parse: yaml.load,
@@ -57,7 +57,7 @@ export function SourcePanel({ lang, name, model, blockStates, doCopy, doDownload
const getOutput = useCallback((model: DataModel, blockStates: BlockStateRegistry) => {
const data = model.schema.hook(transformOutput, new ModelPath(model), model.data, { blockStates })
return FORMATS[format].stringify(data, INDENT[indent]) + '\n'
return FORMATS[format].stringify(data, INDENT[indent])
}, [indent, format])
useEffect(() => {
@@ -136,7 +136,7 @@ export function SourcePanel({ lang, name, model, blockStates, doCopy, doDownload
return <>
<div class="controls">
<BtnMenu icon="gear" tooltip={loc('output_settings')}>
<BtnMenu icon="gear" tooltip={loc('output_settings')} data-cy="source-controls">
{Object.entries(INDENT).map(([key]) =>
<Btn label={loc(`indentation.${key}`)} active={indent === key}
onClick={() => changeIndent(key)}/>
@@ -147,7 +147,7 @@ export function SourcePanel({ lang, name, model, blockStates, doCopy, doDownload
onClick={() => changeFormat(key)} />)}
</BtnMenu>
</div>
<textarea ref={source} class="source" onBlur={onImport} spellcheck={false} autocorrect="off" placeholder={loc('source_placeholder')}></textarea>
<textarea ref={source} class="source" onBlur={onImport} spellcheck={false} autocorrect="off" placeholder={loc('source_placeholder')} data-cy="import-area"></textarea>
<a ref={download} style="display: none;"></a>
</>
}

View File

@@ -25,7 +25,7 @@ export function Tree({ lang, version, model, blockStates, onError }: TreePanelPr
setState(state => state + 1)
})
return <div class="tree">
return <div class="tree" data-cy="tree">
<FullNode {...{model, lang, version, blockStates}}/>
</div>
}