Skip to content

Commit

Permalink
Add tests for the guide and api_reference pages.
Browse files Browse the repository at this point in the history
Replace text in Call to action button and point it to the guide page.
  • Loading branch information
Kapelianovych committed Nov 10, 2023
1 parent 51656eb commit b29405e
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default function createInitCommand() {
targetDirectoryPath,
);

if (basename(filePath) === "package.json") {
if (basename(filePath) === "package.json" || basename(filePath) === "globals.cjs") {
const fileContent = await readFile(filePath, "utf8");

const finalContent = fileContent
Expand Down
2 changes: 1 addition & 1 deletion templates/default/src/layouts/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
A brief introduction to the sample project, its main
features, and capabilities.
</p>
<button>Call to Action</button>
<a href="/guide">Get started</a>
</div>
<div class="hero-inner-img">
<img
Expand Down
24 changes: 24 additions & 0 deletions templates/default/test/commands/custom-pause.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = class CustomPause {
command(ms, cb) {
// If we don't pass the milliseconds, the client will
// be suspended indefinitely
if (!ms) {
return;
}

const returnValue = {
value: 'something'
};

return new Promise((resolve) => {
setTimeout(() => {
// if we have a callback, call it right before the complete event
if (cb) {
cb.call(this.api);
}

resolve(returnValue);
}, ms);
});
}
}
3 changes: 3 additions & 0 deletions templates/default/test/globals.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
name: "${project_name}"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
url: "/api_reference/configuration/index.html",
elements: {
exampleCode: "h2 code",
},
};
10 changes: 10 additions & 0 deletions templates/default/test/page-objects/guide.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
url: "/guide/index.html",
elements: {
rightSidebar: '#right-sidebar',
part1Heading: {
selector: '//h2[text()="Part 1"]',
locateStrategy: 'xpath'
}
},
};
9 changes: 9 additions & 0 deletions templates/default/test/src/api_reference/configuration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe("api_reference page", function () {
test("configuration example is present", function (browser) {
const configuration = browser.page.api_reference.configuration();

configuration.navigate().assert.visible("@exampleCode");

browser.end();
});
});
21 changes: 21 additions & 0 deletions templates/default/test/src/guide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
describe('guide page', function () {
test('right sidebar is visible', function (browser) {
const guide = browser.page.guide();

guide
.navigate()
.assert.visible('@rightSidebar');

browser.end();
});

test('second heading is visible', function (browser) {
const guide = browser.page.guide();

guide
.navigate()
.assert.visible('@part1Heading');

browser.end();
});
});

0 comments on commit b29405e

Please sign in to comment.