Skip to content

Commit eb40d37

Browse files
authored
Merge pull request #5 from bigbite/feature/release-notes-tests
[4] Upgrade wp-cypress, remove cucumber, gherkin linter and refactor tests back to Cypress syntax
2 parents 536d9dd + 0594f57 commit eb40d37

File tree

8 files changed

+5559
-10290
lines changed

8 files changed

+5559
-10290
lines changed

.gherkin-lintrc

Lines changed: 0 additions & 53 deletions
This file was deleted.

cypress.config.js

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,7 @@
11
const { defineConfig } = require('cypress');
22

3-
const webpack = require('@cypress/webpack-preprocessor');
4-
const preprocessor = require('@badeball/cypress-cucumber-preprocessor');
5-
6-
async function setupNodeEvents(on, config) {
7-
// implement node event listeners here
8-
9-
await preprocessor.addCucumberPreprocessorPlugin(on, config);
10-
11-
on(
12-
'file:preprocessor',
13-
webpack({
14-
webpackOptions: {
15-
resolve: {
16-
extensions: ['.js'],
17-
},
18-
module: {
19-
rules: [
20-
{
21-
test: /\.feature$/,
22-
use: [
23-
{
24-
loader: '@badeball/cypress-cucumber-preprocessor/webpack',
25-
options: config,
26-
},
27-
],
28-
},
29-
],
30-
},
31-
},
32-
}),
33-
);
34-
35-
config = require('@bigbite/wp-cypress/lib/cypress-plugin')(on, config);
36-
return config;
37-
}
38-
393
module.exports = defineConfig({
404
e2e: {
41-
setupNodeEvents,
42-
specPattern: 'cypress/**/*.feature',
435
watchForFileChanges: true,
446
baseUrl: 'http://localhost:3333',
457
},

cypress/e2e/example.cy.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
describe('no release notes found', () => {
3+
it('some release notes are published', () => {
4+
cy.visit('/wp-admin/admin.php?page=release-notes');
5+
cy.get('article.release-note-single').should('exist');
6+
cy.get('article.release-note-single h1.release-note-title').contains('Release not found!');
7+
});
8+
});

cypress/e2e/example.feature

Lines changed: 0 additions & 10 deletions
This file was deleted.

cypress/e2e/example.js

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
describe('release note creation', () => {
2+
beforeEach(() => {
3+
cy.intercept({ method: 'POST', url: `/wp-json/wp/v2/release-note/*` }).as('releasePublished')
4+
})
5+
6+
it('an Administrator creates a new release note with provided updates', () => {
7+
cy.visit("/wp-admin/edit.php?post_type=release-note")
8+
cy.get(".page-title-action").contains("Add New").click()
9+
cy.get(".wp-block-post-title").click().type("hello world")
10+
cy.get(".is-root-container").within(() => {
11+
cy.get("p.wp-block-paragraph").type("Overview text")
12+
cy.get("ul").eq(0).within(() => {
13+
cy.get("li").eq(0).type("list item #1{enter}")
14+
cy.get("li").eq(1).type("list item #2")
15+
});
16+
cy.get("ul").eq(1).within(() => {
17+
cy.get("li").eq(0).type("list item #1{enter}")
18+
cy.get("li").eq(1).type("list item #2")
19+
});
20+
cy.get("ul").eq(2).within(() => {
21+
cy.get("li").eq(0).type("list item #1{enter}")
22+
cy.get("li").eq(1).type("list item #2")
23+
});
24+
});
25+
cy.contains("button", "Release Note").click()
26+
cy.contains("button", "Release Info").click()
27+
cy.get(".components-input-control__container").type("1.0.0")
28+
29+
cy.contains("button", "Publish").click()
30+
cy.get(".editor-post-publish-panel__header").within(() => {
31+
cy.contains("button", "Publish").click()
32+
});
33+
cy.saveCurrentPost()
34+
cy.wait("@releasePublished")
35+
.its("response.statusCode")
36+
.should("eq", 200)
37+
38+
cy.visit("wp-admin/admin.php?page=release-notes")
39+
cy.get(".menupop.release-note").should("contain", "1.0.0")
40+
cy.get(".release-note-version").should("contain", "1.0.0")
41+
});
42+
});

0 commit comments

Comments
 (0)