-
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: add e2e test
- Loading branch information
Showing
43 changed files
with
2,506 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# We'll let Git's auto-detection algorithm infer if a file is text. If it is, | ||
# enforce LF line endings regardless of OS or git configurations. | ||
* text=auto eol=lf | ||
* text=auto eol=lf | ||
e2e/fixtures/** filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-checkout'.\n"; exit 2; } | ||
git lfs post-checkout "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-commit'.\n"; exit 2; } | ||
git lfs post-commit "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-merge'.\n"; exit 2; } | ||
git lfs post-merge "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'.\n"; exit 2; } | ||
git lfs pre-push "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,16 @@ Everyone is welcome to join us! Whether you find a bug, have a great feature req | |
|
||
Make sure to read the [Contributing Guide](.github/HOW_TO_CONTRIBUTE.md) / [贡献指南](https://github.com/galacean/engine/wiki/%E5%A6%82%E4%BD%95%E4%B8%8E%E6%88%91%E4%BB%AC%E5%85%B1%E5%BB%BA-Oasis-%E5%BC%80%E6%BA%90%E4%BA%92%E5%8A%A8%E5%BC%95%E6%93%8E) before submitting changes. | ||
|
||
## Clone | ||
Prerequisites: | ||
- [git-lfs](https://git-lfs.com/) (Install by official website) | ||
|
||
Clone this repository: | ||
|
||
```sh | ||
git clone [email protected]:galacean/runtime.git | ||
``` | ||
|
||
## Build | ||
|
||
Prerequisites: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { defineConfig } from "cypress"; | ||
import { compare } from "odiff-bin"; | ||
|
||
const path = require("path"); | ||
const fs = require("fs-extra"); | ||
|
||
const downloadDirectory = path.join(__dirname, "e2e/downloads"); | ||
let isRunningInCommandLine = false; | ||
export default defineConfig({ | ||
e2e: { | ||
viewportWidth: 1200, | ||
viewportHeight: 800, | ||
baseUrl: "http://localhost:5175", | ||
defaultCommandTimeout: 60000, | ||
fileServerFolder: "e2e", | ||
supportFile: "e2e/support/e2e.ts", | ||
fixturesFolder: "e2e/fixtures", | ||
screenshotsFolder: "e2e/screenshots", | ||
videosFolder: "e2e/videos", | ||
specPattern: "e2e/tests/*.cy.ts", | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
on("before:browser:launch", (browser, launchOptions) => { | ||
console.log("launching browser %s is headless? %s", browser.name, browser.isHeadless); | ||
// supply the absolute path to an unpacked extension's folder | ||
// NOTE: extensions cannot be loaded in headless Chrome | ||
if (fs.existsSync("e2e/diff")) { | ||
fs.rmdirSync("e2e/diff", { recursive: true }); | ||
} | ||
if (browser.name === "chrome") { | ||
launchOptions.preferences.default["download"] = { | ||
default_directory: downloadDirectory | ||
}; | ||
} | ||
if (browser.isHeadless) { | ||
isRunningInCommandLine = true; | ||
} | ||
launchOptions.args.push("--force-device-scale-factor=1"); | ||
return launchOptions; | ||
}), | ||
on("task", { | ||
async compare({ fileName, options }) { | ||
fileName += ".png"; | ||
const baseFolder = "e2e/fixtures/originImage/"; | ||
const newFolder = path.join("e2e/screenshots", isRunningInCommandLine ? options.specFolder : ""); | ||
const diffFolder = path.join("e2e/diff", options.specFolder); | ||
if (!fs.existsSync(diffFolder)) { | ||
fs.mkdirSync(diffFolder, { recursive: true }); | ||
} | ||
const baseImage = path.join(baseFolder, fileName); | ||
const newImage = path.join(newFolder, fileName); | ||
const diffImage = path.join(diffFolder, fileName); | ||
console.log("comparing base image %s to the new image %s", baseImage, newImage); | ||
if (options) { | ||
console.log("odiff options %o", options); | ||
} | ||
const started = +new Date(); | ||
|
||
const result = await compare(baseImage, newImage, diffImage, options); | ||
const finished = +new Date(); | ||
const elapsed = finished - started; | ||
console.log("odiff took %dms", elapsed); | ||
|
||
console.log(result); | ||
return result; | ||
} | ||
}); | ||
} | ||
}, | ||
chromeWebSecurity: false | ||
}); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Galacean Case</title> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<div class="header"> | ||
<a class="logo" href="https://galacean.antgroup.com/" target="Home"> | ||
<img | ||
src="https://mdn.alipayobjects.com/huamei_qbugvr/afts/img/A*ppQsSphM7uUAAAAAAAAAAAAADtKFAQ/original" | ||
alt="" | ||
/> | ||
<span> Galacean </span> | ||
</a> | ||
</div> | ||
<input | ||
placeholder="search..." | ||
class="search-bar" | ||
id="searchBar" | ||
autocorrect="off" | ||
autocapitalize="off" | ||
spellcheck="false" | ||
/> | ||
<div class="nav-left"> | ||
<div class="item-list" id="itemList"></div> | ||
</div> | ||
|
||
<div class="nav-right"> | ||
<iframe id="iframe" allowfullscreen src="" frameborder="0"></iframe> | ||
</div> | ||
</div> | ||
|
||
<script type="module" src="./index.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import './index.sass'; | ||
import demoList from './mpa/.demoList.json'; | ||
const itemListDOM = document.getElementById('itemList'); | ||
const searchBarDOM = document.getElementById('searchBar'); | ||
const iframe = document.getElementById('iframe'); | ||
const items = []; // itemDOM,label | ||
|
||
Object.keys(demoList).forEach((group) => { | ||
const demos = demoList[group]; | ||
const groupDOM = document.createElement('div'); | ||
const demosDOM = document.createElement('ul'); | ||
itemListDOM.appendChild(groupDOM); | ||
groupDOM.appendChild(demosDOM); | ||
|
||
demos.forEach((item) => { | ||
const { label, src } = item; | ||
const itemDOM = document.createElement('a'); | ||
|
||
itemDOM.innerHTML = src; | ||
itemDOM.title = `${src}`; | ||
itemDOM.onclick = function () { | ||
clickItem(itemDOM); | ||
}; | ||
demosDOM.appendChild(itemDOM); | ||
|
||
items.push({ | ||
itemDOM, | ||
label, | ||
src, | ||
}); | ||
}); | ||
}); | ||
|
||
searchBarDOM.oninput = () => { | ||
updateFilter(searchBar.value); | ||
}; | ||
|
||
function updateFilter(value) { | ||
const reg = new RegExp(value, 'i'); | ||
|
||
items.forEach(({ itemDOM, label, src }) => { | ||
reg.lastIndex = 0; | ||
if (reg.test(label) || reg.test(src)) { | ||
itemDOM.classList.remove('hide'); | ||
} else { | ||
itemDOM.classList.add('hide'); | ||
} | ||
}); | ||
} | ||
|
||
function clickItem(itemDOM) { | ||
window.location.hash = `#mpa/${itemDOM.title}`; | ||
} | ||
|
||
function onHashChange() { | ||
const hashPath = window.location.hash.split('#')[1]; | ||
if (!hashPath) { | ||
clickItem(items[0].itemDOM); | ||
return; | ||
} | ||
iframe.src = hashPath + '.html'; | ||
|
||
items.forEach(({ itemDOM }) => { | ||
const itemPath = `mpa/${itemDOM.title}`; | ||
if (itemPath === hashPath) { | ||
itemDOM.classList.add('active'); | ||
} else { | ||
itemDOM.classList.remove('active'); | ||
} | ||
}); | ||
} | ||
|
||
window.onhashchange = onHashChange; | ||
|
||
// init | ||
onHashChange(); |
Oops, something went wrong.