Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(test): Storybook test integration #878

Merged
merged 49 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e9cbceb
add: initial storybook config
radupasparuga Apr 8, 2024
f588a6c
add: loop through stories and wait for console error
radupasparuga Apr 22, 2024
c3b238e
add: dynamic individual tests for each story
radupasparuga Apr 22, 2024
359fcae
add: port setup
radupasparuga Apr 22, 2024
f98e895
Merge branch 'main' of github.com:EOX-A/elements into testing/feat/st…
radupasparuga Apr 22, 2024
54616c6
chore: cleanup test config
radupasparuga Apr 24, 2024
b9230fe
fix: e2e infinite loop
radupasparuga Apr 30, 2024
a23fcfb
chore(ci): add periodic storybook tests
radupasparuga Apr 30, 2024
6c9b865
test: period runner
radupasparuga Apr 30, 2024
d675fab
test: wait a bit for storybook to run before starting e2e tests
radupasparuga Apr 30, 2024
add5cb3
Merge branch 'main' of github.com:EOX-A/elements into testing/feat/st…
radupasparuga Apr 30, 2024
6105666
test: small delay before e2e
radupasparuga Apr 30, 2024
5973f7f
tests: separate storybook tests from e2e tests
radupasparuga Apr 30, 2024
17a1742
test: fix normal e2e tests
radupasparuga Apr 30, 2024
eb7c18c
fix: storybook test command
radupasparuga Apr 30, 2024
0611366
tests: revert e2e test command
radupasparuga May 6, 2024
af72dd7
test: storybook first test retry
radupasparuga May 6, 2024
090746e
tests: revert default test run
radupasparuga May 13, 2024
331e85d
test: storybook tests using docs folder
radupasparuga May 13, 2024
41e8ea5
Merge branch 'main' of github.com:EOX-A/elements into testing/feat/st…
radupasparuga May 13, 2024
b8267d3
test: try git diff env variable
radupasparuga May 13, 2024
d04fe15
add: env export to storybook workflow
radupasparuga May 13, 2024
1026b06
add: update workflow
radupasparuga May 13, 2024
f186a2c
test: git diff
radupasparuga May 13, 2024
47c9e46
test: run storybook based on git diff
radupasparuga May 13, 2024
65ae43f
Merge branch 'main' of github.com:EOX-A/elements into testing/feat/st…
radupasparuga May 15, 2024
6cf4680
test: storybook runner
radupasparuga May 15, 2024
c8f37a4
fix: CI error
radupasparuga May 15, 2024
dd8cdc5
test: storybook drawtools diff
radupasparuga May 15, 2024
a071d9a
chore: combine storybook action with test action
radupasparuga May 15, 2024
9214ffa
fix: properly pass diff as env variable
radupasparuga May 15, 2024
756e32e
test: git diff passing
radupasparuga May 15, 2024
df2fb94
chore: revert component change
radupasparuga May 15, 2024
26c2d3a
chore: test new git diff command
radupasparuga May 15, 2024
95e9e00
fix: handle case when cypress folder is changed in git diff
radupasparuga May 15, 2024
d16aacb
chore: update CI
radupasparuga May 15, 2024
fa59ef6
fix: debug storybook CI
radupasparuga May 15, 2024
81482ff
fix: experiment main branch referencing in test action
radupasparuga May 15, 2024
bfc7d96
fix: revert git diff to previous commit
radupasparuga May 15, 2024
fe2f7c9
chore: temporarily move storybook test action
radupasparuga May 15, 2024
3878971
chore: cleanup
radupasparuga May 15, 2024
cce244e
chore: move storybook tests to last in the github workflow
radupasparuga May 15, 2024
b49b66d
Merge branch 'main' of github.com:EOX-A/elements into testing/feat/st…
radupasparuga May 16, 2024
125d159
chore: re-add removed line
silvester-pari May 16, 2024
c7451c1
fix: stacinfo custom slot story
radupasparuga May 16, 2024
6db0a5a
Merge branch 'main' into testing/feat/storybook-integration
silvester-pari May 16, 2024
f618483
chore: combine E2E and storybook tests
radupasparuga May 21, 2024
db59ada
fix: storytelling bug
radupasparuga May 21, 2024
508c89d
Merge branch 'main' of github.com:EOX-A/elements into testing/feat/st…
radupasparuga May 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ jobs:
run: |
export CI_PATHS_CHANGED=$(git diff --name-only -r HEAD^1 HEAD)
npm run test:component

- name: Run e2e tests 👀
run: npm run test:e2e

- name: Run storybook tests 👀
run: |
export CI_PATHS_CHANGED=$(git diff --name-only -r HEAD^1 HEAD) && npm run test:storybook

- name: Upload failed test screenshots 📷
uses: actions/upload-artifact@v4
if: failure()
Expand Down
7 changes: 7 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ if (pathsChanged) {
}
}
export default defineConfig({
env: {
CI_PATHS_CHANGED: pathsChanged,
},
e2e: {
// specPattern: "**/*.cy.{js,jsx,ts,tsx}",
supportFile: false,
experimentalRunAllSpecs: true,
excludeSpecPattern: ["**/storybook.cy.js"],
},
component: {
supportFile: "cypress/support/component.ts",
Expand All @@ -35,4 +39,7 @@ export default defineConfig({
specPattern: specPatternComponentTests,
indexHtmlFile: "cypress/support/component-index.html",
},
retries: {
runMode: 2,
},
});
37 changes: 37 additions & 0 deletions cypress/e2e/storybook.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import "cypress-network-idle";
import stories from "../../docs/index.json";

describe("Stories test", () => {
const pathsChanged = Cypress.env("CI_PATHS_CHANGED");
let uniqueElementFolders = [];
let cypressChanged = false;
// only run stories from files that have been changed
if (pathsChanged) {
const changed = pathsChanged.split("\n");
// if cypress folder changed => run all tests
if (!changed.some((item) => item.startsWith("cypress"))) {
const filteredElementsFolders = changed
.filter((filePath) => filePath.startsWith("elements/"))
.map((filePath) => filePath.split("/")[1]);
uniqueElementFolders = [...new Set(filteredElementsFolders)];
console.log(uniqueElementFolders);
} else {
cypressChanged = true;
}
}
const filteredStories = cypressChanged
? Object.values(stories.entries)
: Object.values(stories.entries).filter((obj) => {
return uniqueElementFolders.some((folder) =>
obj.importPath.includes(folder)
);
});
filteredStories.forEach((story) => {
if (story.type && story.type == "story") {
it(`${story.id}`, () => {
cy.visit(`../../docs/iframe.html?id=${story.id}`);
cy.waitForNetworkIdle(1000);
});
}
});
});
9 changes: 3 additions & 6 deletions elements/stacinfo/stacinfo.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,17 @@ export const CustomSlotContent = {
style="width: 400px"
>
<div
slot="region"
slot="agency"
style="background: lightgrey; width: 100%; padding: 10px 20px; border-radius: 4px;"
>
<p>
Replacing the "region" property slot to render it in a custom manner:
</p>
<p>--> <strong>Region:</strong> <span class="content"></span>!</p>
<p>--> <strong>Agency:</strong> <span class="content"></span>!</p>
</div>
</eox-stacinfo>
<script>
const stacInfo = document.querySelector("eox-stacinfo#slot");
stacInfo.addEventListener("loaded", () => {
setTimeout(() => {
const value = stacInfo.stacProperties["osc:region"];
const value = stacInfo.stacProperties["agency"];
document.querySelector(".content").innerHTML = value.formatted;
});
});
Expand Down
Loading
Loading