Skip to content

Fix date timestamp typo ( Created and Modified date are different for newly saved Image Preview) #29452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\ReadInterface;
use Magento\Framework\Filesystem\Driver\File;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\MediaGalleryApi\Api\Data\AssetInterface;
use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory;
use Magento\MediaGalleryMetadataApi\Api\ExtractMetadataInterface;
Expand All @@ -24,11 +23,6 @@
*/
class CreateAssetFromFile
{
/**
* Date format
*/
private const DATE_FORMAT = 'Y-m-d H:i:s';

/**
* @var Filesystem
*/
Expand All @@ -39,11 +33,6 @@ class CreateAssetFromFile
*/
private $driver;

/**
* @var TimezoneInterface;
*/
private $date;

/**
* @var AssetInterfaceFactory
*/
Expand All @@ -67,7 +56,6 @@ class CreateAssetFromFile
/**
* @param Filesystem $filesystem
* @param File $driver
* @param TimezoneInterface $date
* @param AssetInterfaceFactory $assetFactory
* @param GetContentHashInterface $getContentHash
* @param ExtractMetadataInterface $extractMetadata
Expand All @@ -76,15 +64,13 @@ class CreateAssetFromFile
public function __construct(
Filesystem $filesystem,
File $driver,
TimezoneInterface $date,
AssetInterfaceFactory $assetFactory,
GetContentHashInterface $getContentHash,
ExtractMetadataInterface $extractMetadata,
SplFileInfoFactory $splFileInfoFactory
) {
$this->filesystem = $filesystem;
$this->driver = $driver;
$this->date = $date;
$this->assetFactory = $assetFactory;
$this->getContentHash = $getContentHash;
$this->extractMetadata = $extractMetadata;
Expand Down Expand Up @@ -112,8 +98,6 @@ public function execute(string $path): AssetInterface
'path' => $path,
'title' => $metadata->getTitle() ?: $file->getBasename('.' . $file->getExtension()),
'description' => $metadata->getDescription(),
'createdAt' => $this->date->date($file->getCTime())->format(self::DATE_FORMAT),
'updatedAt' => $this->date->date($file->getMTime())->format(self::DATE_FORMAT),
'width' => $width,
'height' => $height,
'hash' => $this->getHash($path),
Expand Down
12 changes: 5 additions & 7 deletions app/code/Magento/MediaGalleryUi/Model/UpdateAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,16 @@ public function execute(int $id, MetadataInterface $data): void

$updatedAsset = $this->assetFactory->create(
[
'id' => $asset->getId(),
'path' => $asset->getPath(),
'contentType' => $asset->getContentType(),
'title' => $data->getTitle() ?? $asset->getTitle(),
'description' => $data->getDescription() ?? $asset->getDescription(),
'width' => $asset->getWidth(),
'height' => $asset->getHeight(),
'size' => $asset->getSize(),
'id' => $asset->getId(),
'title' => $data->getTitle() ?? $asset->getTitle(),
'description' => $data->getDescription() ?? $asset->getDescription(),
'source' => $asset->getSource(),
'hash' => $asset->getHash(),
'created_at' => $asset->getCreatedAt(),
'updated_at' => $asset->getUpdatedAt()
'contentType' => $asset->getContentType(),
'source' => $asset->getSource()
]
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertAdminEnhancedMediaGalleryImageCreatedAtNotEqualsUpdatedAtTimeActionGroup">
<annotations>
<description>Assert that created_at updated_at time NOT equals</description>
</annotations>

<grabTextFrom selector="{{AdminEnhancedMediaGalleryViewDetailsSection.createdAtDate}}" stepKey="grabCreatedTime"/>
<grabTextFrom selector="{{AdminEnhancedMediaGalleryViewDetailsSection.updatedAtDate}}" stepKey="grabModifietTime"/>
<assertNotEquals stepKey="verifyContentType">
<actualResult type="variable">grabCreatedTime</actualResult>
<expectedResult type="variable">grabModifietTime</expectedResult>
</assertNotEquals>

</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertAdminEnhancedMediaGalleryUploadedImageDateTimeEqualsActionGroup">
<annotations>
<description>Assert that created_at updated_at time are the same for newly uploaded image </description>
</annotations>

<grabTextFrom selector="{{AdminEnhancedMediaGalleryViewDetailsSection.createdAtDate}}" stepKey="grabCreatedTime"/>
<grabTextFrom selector="{{AdminEnhancedMediaGalleryViewDetailsSection.updatedAtDate}}" stepKey="grabModifietTime"/>
<assertEquals stepKey="verifyContentType">
<actualResult type="variable">grabCreatedTime</actualResult>
<expectedResult type="variable">grabModifietTime</expectedResult>
</assertEquals>

</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<element name="edit" type="button" selector="//div[@class='media-gallery-image-details-modal']//button[contains(@class, 'edit')]"/>
<element name="delete" type="button" selector="//div[@class='media-gallery-image-details-modal']//button[contains(@class, 'delete')]"/>
<element name="confirmDelete" type="button" selector=".action-accept"/>
<element name="createdAtDate" type="button" selector="//div[@class='attribute']/span[contains(text(), 'Created')]/following-sibling::div"/>
<element name="updatedAtDate" type="button" selector="//div[@class='attribute']/span[contains(text(), 'Modified')]/following-sibling::div"/>
<element name="addImage" type="button" selector=".add-image-action"/>
<element name="cancel" type="button" selector="#image-details-action-cancel"/>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
<actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage">
<argument name="image" value="ImageUpload"/>
</actionGroup>
<actionGroup ref="AdminEnhancedMediaGalleryViewImageDetails" stepKey="clickViewDetails"/>
<actionGroup ref="AssertAdminEnhancedMediaGalleryUploadedImageDateTimeEqualsActionGroup" stepKey="verifyCreatedAndUpdatedAtDate" />
<wait time="100" stepKey="waitForUpdateTimeToBeGreater"/>
<actionGroup ref="AdminEnhancedMediaGalleryCloseViewDetailsActionGroup" stepKey="closeViewDetails"/>
<actionGroup ref="AdminEnhancedMediaGalleryEditImageDetailsActionGroup" stepKey="editImageDetails"/>
<actionGroup ref="AdminEnhancedMediaGalleryImageDetailsSaveActionGroup" stepKey="saveImage">
<argument name="image" value="UpdatedImageDetails"/>
Expand All @@ -40,6 +44,7 @@
<actionGroup ref="AdminEnhancedMediaGalleryVerifyImageDetailsActionGroup" stepKey="verifyImageDetails">
<argument name="image" value="UpdatedImageDetails"/>
</actionGroup>
<actionGroup ref="AssertAdminEnhancedMediaGalleryImageCreatedAtNotEqualsUpdatedAtTimeActionGroup" stepKey="assertUpdatedAtTimeChanged" />
<actionGroup ref="AdminEnhancedMediaGalleryVerifyImageDescriptionActionGroup" stepKey="verifyImageDescription">
<argument name="description" value="UpdatedImageDetails.description"/>
</actionGroup>
Expand Down