Skip to content

Commit 604bf1b

Browse files
committed
Create mocks for the entire checkout extension API
1 parent 07d5a50 commit 604bf1b

22 files changed

Lines changed: 4159 additions & 26 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Environment Configuration
2+
.env
3+
.env.*
4+
5+
# Dependency directory
6+
node_modules
7+
8+
# Test coverage directory
9+
coverage
10+
11+
# Ignore Apple macOS Desktop Services Store
12+
.DS_Store
13+
14+
# Logs
15+
logs
16+
*.log
17+
18+
# extensions build output
19+
extensions/*/build
20+
extensions/*/dist
21+
22+
# lock files
23+
24+
25+
26+
27+
# Ignore shopify files created during app dev
28+
.shopify/*
29+
.shopify.lock
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const fs = require("node:fs");
2+
3+
function getConfig() {
4+
const config = {
5+
projects: {},
6+
};
7+
8+
let extensions = [];
9+
try {
10+
extensions = fs.readdirSync("./extensions");
11+
} catch {
12+
// ignore if no extensions
13+
}
14+
15+
for (const entry of extensions) {
16+
const extensionPath = `./extensions/${entry}`;
17+
const schema = `${extensionPath}/schema.graphql`;
18+
if (!fs.existsSync(schema)) {
19+
continue;
20+
}
21+
config.projects[entry] = {
22+
schema,
23+
documents: [`${extensionPath}/**/*.graphql`],
24+
};
25+
}
26+
27+
return config;
28+
}
29+
30+
module.exports = getConfig();
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
This extension was created with:
2+
3+
```
4+
shopify app init --name checkout-basic-testing-example
5+
cd checkout-basic-testing-example
6+
shopify app generate extension
7+
# I chose 'Checkout UI'
8+
```
9+
10+
See it in action:
11+
12+
```
13+
npm install
14+
npm run typecheck
15+
npm test
16+
```

examples/testing/checkout-basic-testing-example/extensions/.gitkeep

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Instructions are in [app's README](../../)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"welcome": "Welcome to the {{target}} extension!",
3+
"iWouldLikeAFreeGiftWithMyOrder": "I would like to receive a free gift with my order",
4+
"addAFreeGiftToMyOrder": "Add a free gift to my order",
5+
"attributeChangesAreNotSupported": "Attribute changes are not supported in this checkout"
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"welcome": "Bienvenue dans l'extension {{target}}!",
3+
"iWouldLikeAFreeGiftWithMyOrder": "Je souhaite recevoir un cadeau gratuit avec ma commande",
4+
"addAFreeGiftToMyOrder": "Ajouter un cadeau gratuit à ma commande",
5+
"attributeChangesAreNotSupported": "Les modifications d'attribut ne sont pas prises en charge dans cette commande"
6+
}

0 commit comments

Comments
 (0)