diff --git a/cypress/e2e/release-note-version-control.cy.js b/cypress/e2e/release-note-version-control.cy.js new file mode 100644 index 00000000..289df7ca --- /dev/null +++ b/cypress/e2e/release-note-version-control.cy.js @@ -0,0 +1,23 @@ +/// + +describe('release notes version control', () => { + before(() => { + cy.visit('/wp-admin/edit.php?post_type=release-note'); + }); + + it('should change the version accordingly after a release note has been deleted', () => { + //asserts that the version number is the current version + cy.get('#wpadminbar').within(() => { + cy.get('#wp-admin-bar-release-note-version > a').should('contain', 'Version 1.6.0'); + }) + //deletes the current release note in the post list + cy.get('#the-list').within(() => { + cy.get('#post-5 .row-actions').invoke('attr', 'style', 'position: static').find('.submitdelete').click(); + cy.visit('/wp-admin/edit.php?post_type=release-note'); + cy.get('tr').should('have.length', 1); + }); + //asserts that the version number has changed to the previous release note version + cy.get('#wpadminbar').within(() => { + cy.get('#wp-admin-bar-release-note-version > a').should('contain', 'Version 1.5.0'); + }) }); +}); \ No newline at end of file diff --git a/cypress/seeds/ReleaseNoteSeeder.php b/cypress/seeds/ReleaseNoteSeeder.php index 18eda96e..12cea0fd 100644 --- a/cypress/seeds/ReleaseNoteSeeder.php +++ b/cypress/seeds/ReleaseNoteSeeder.php @@ -3,11 +3,89 @@ use WP_Cypress\Seeder\Seeder; use WP_Cypress\Fixtures; + class ReleaseNoteSeeder extends Seeder { public function run() { + $release_note_template = ' +

Overview

+ + +

%s

+ + +

Added

+ + + + + +

Changed

+ + + + + +

Fixed

+ + + + '; + + ( new Fixtures\Post([ + 'post_type' => 'release-note', + 'post_date' => date("Y-m-d H:i:s", strtotime("Nov 10, 2023 15:01:10")), + 'post_content' => sprintf( + $release_note_template, + $this->faker->realText( 100 ), + $this->faker->realText( 40 ), + $this->faker->realText( 40 ), + $this->faker->realText( 40 ), + $this->faker->realText( 40 ), + $this->faker->realText( 40 ), + $this->faker->realText( 40 ), + '1.5.0' + ), + 'post_meta' => [ + 'version' => '1.5.0', + 'release_date' => date("Y-m-d", strtotime("Nov 10, 2023")), + ] + ]))->create(1); + ( new Fixtures\Post([ 'post_type' => 'release-note', - ]) )->create(10); + 'post_date' => date("Y-m-d H:i:s", strtotime("Dec 04, 2023 14:22:32")), + 'post_content' => sprintf( + $release_note_template, + $this->faker->realText( 100 ), + $this->faker->realText( 40 ), + $this->faker->realText( 40 ), + $this->faker->realText( 40 ), + $this->faker->realText( 40 ), + $this->faker->realText( 40 ), + $this->faker->realText( 40 ), + '1.6.0' + ), + 'post_meta' => [ + 'version' => '1.6.0', + 'release_date' => date("Y-m-d", strtotime("Dec 04, 2023")), + ], + + ]))->create(1); } } diff --git a/package.json b/package.json index 145851e7..a8f66003 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "watch:dev:all": "webpack --mode=development --watch --env=\"all-projects\"", "watch:prod": "webpack --mode=production --watch --env=\"project=$npm_config_project\"", "watch:prod:all": "webpack --mode=production --watch --env=\"all-projects\"", - "test:e2e": "wp-cypress start" + "test:e2e": "wp-cypress stop && wp-cypress start && cypress open" }, "dependencies": { "@bigbite/build-tools": "git+ssh://git@github.com:bigbite/build-tools.git#1.0.0-beta.6",