Commit 03187afaf43 for woocommerce

commit 03187afaf43248a09ddf68b78f40c519fcd9185f
Author: Vlad Olaru <vlad.olaru@automattic.com>
Date:   Tue Oct 20 11:32:25 2026 +0300

    [tests] Fix the one-second flake in the admin notes created-date test (#69650)

    * test: Fix the one-second flake in the notes created-date test

    test_note_correctly_sets_created_date_with_timestamp set a timestamp
    from time() on a new note, saved it, and expected the same second back.
    DataStore::create() ignores any date set before the first save and
    stamps its own time(), so the test failed whenever the save crossed a
    second boundary (seen in CI on PHP 8.5).

    Read time() on both sides of save() and assert the loaded timestamp
    falls between them. Drop the set_date_created() call, which never had
    an effect, and rename the test to what it checks. A non-UTC site
    timezone keeps the original intent from woocommerce-admin#6795: the
    date must load back in UTC, not shifted by the site offset.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    * chore: Add changelog entry for the notes created-date test fix

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

diff --git a/plugins/woocommerce/changelog/fix-flaky-notes-created-date-test b/plugins/woocommerce/changelog/fix-flaky-notes-created-date-test
new file mode 100644
index 00000000000..4d19c0d29b7
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-flaky-notes-created-date-test
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Fix a timing flake in the admin notes created-date test; no production change.
diff --git a/plugins/woocommerce/tests/legacy/unit-tests/woocommerce-admin/notes/class-wc-tests-notes-note.php b/plugins/woocommerce/tests/legacy/unit-tests/woocommerce-admin/notes/class-wc-tests-notes-note.php
index d4f7d0f8455..cd938812621 100644
--- a/plugins/woocommerce/tests/legacy/unit-tests/woocommerce-admin/notes/class-wc-tests-notes-note.php
+++ b/plugins/woocommerce/tests/legacy/unit-tests/woocommerce-admin/notes/class-wc-tests-notes-note.php
@@ -13,21 +13,24 @@ use Automattic\WooCommerce\Admin\Notes\Note;
 class WC_Admin_Tests_Notes_Note extends WC_Unit_Test_Case {

 	/**
-	 * Tests a note can be created with timestamp.
+	 * Tests a new note's created date is the time it was saved, read back in UTC whatever the
+	 * site timezone. The data store stamps the date during save(), so the check is a range: a
+	 * single time() read can fall in the second before.
 	 */
-	public function test_note_correctly_sets_created_date_with_timestamp() {
-		$timestamp     = time();
-		$datetime      = new WC_DateTime( "@{$timestamp}", new DateTimeZone( 'UTC' ) );
-		$expected_date = $datetime->format( 'Y-m-d H:i:s' );
+	public function test_new_note_created_date_is_the_save_time_in_utc() {
+		update_option( 'timezone_string', 'America/Los_Angeles' );

 		$note = new Note();
 		$note->set_title( 'test1' );
-		$note->set_date_created( $timestamp );
+
+		$before_save = time();
 		$note->save();
+		$after_save = time();

 		$note         = new Note( $note->get_id() );
-		$date_created = $note->get_date_created()->format( 'Y-m-d H:i:s' );
-		$this->assertEquals( $expected_date, $date_created );
+		$date_created = $note->get_date_created()->getTimestamp();
+		$this->assertGreaterThanOrEqual( $before_save, $date_created );
+		$this->assertLessThanOrEqual( $after_save, $date_created );
 	}

 	/**