Skip to content
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 @@ -104,6 +104,61 @@ describe('Upload Files - Image', () => {

testImage(properties);
});

it('MM-69026 - Image preview supports zoom controls and keyboard shortcut', () => {
// Use a unique filename so we can find the thumbnail unambiguously after
// earlier tests in this spec have already uploaded PNG.png/JPG.jpg/etc.
const fileName = 'mm-69026-zoom.png';
const properties = {
filePath: 'mm_file_testing/Images/PNG.png',
fileName,
originalWidth: 400,
originalHeight: 479,
mimeType: 'image/png',
};

// # Post any message
cy.postMessage(fileName);

// # Post an image in center channel
attachFile(properties);

// # Wait until file upload is complete then submit
waitUntilUploadComplete();
cy.uiGetPostTextBox().clear().type('{enter}');
cy.wait(TIMEOUTS.FIVE_SEC);

// # Open file preview
cy.uiGetFileThumbnail(fileName).click();

// * Verify preview modal opened
cy.uiGetFilePreviewModal().as('filePreviewModal');

// * Zoom controls are visible for images
cy.get('@filePreviewModal').find('.file-preview-modal__zoom-bar .modal-zoom-btn').should('have.length.at.least', 1);

// # Click zoom-in
cy.get('@filePreviewModal').find('.modal-zoom-btn .icon-plus').click();

// * Image is scaled up — match only scale values strictly greater than 1
// (e.g. scale(1.25), scale(2)), so a transform of scale(1) or no
// scale at all would fail this assertion.
cy.get('@filePreviewModal').find('[data-testid="imagePreview"]').
should('have.attr', 'style').
and('match', /scale\((?:1\.\d+|[2-9]\d*(?:\.\d+)?)\)/);

// # Press '0' to reset
cy.get('body').type('0');

// * Image transform clears (no scale applied at default 1.0)
cy.get('@filePreviewModal').find('[data-testid="imagePreview"]').then(($img) => {
const style = $img.attr('style') || '';
expect(style).to.not.match(/scale\([0-9.]+\)/);
});

// # Close modal
cy.uiCloseFilePreviewModal();
});
});

function testImage(properties) {
Expand Down
1 change: 0 additions & 1 deletion server/build/notice-file/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ search:
- "webapp/package.json"
- "webapp/channels/package.json"
ignoreDependencies:
- "@mattermost/dynamic-virtualized-list"
- "@mattermost/shared"
includeDevDependencies: false
2 changes: 1 addition & 1 deletion server/channels/api4/bot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestCreateBot(t *testing.T) {
_, appErr = th.App.UpdateUserRoles(th.Context, bot.UserId, model.TeamUserRoleId+" "+model.SystemUserAccessTokenRoleId, false)
assert.Nil(t, appErr)

rtoken, _, err := th.Client.CreateUserAccessToken(context.Background(), bot.UserId, "test token")
rtoken, _, err := th.Client.CreateUserAccessToken(context.Background(), bot.UserId, "test token", 0)
require.NoError(t, err)
th.Client.AuthToken = rtoken.Token

Expand Down
4 changes: 0 additions & 4 deletions server/channels/api4/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -2912,10 +2912,6 @@ func createUserAccessToken(c *Context, w http.ResponseWriter, r *http.Request) {

accessToken.UserId = c.Params.UserId
accessToken.Token = ""
// TODO: remove once the API officially supports setting expires_at; until
// then, strip any client-supplied value so that JSON-decoded requests cannot
// set an arbitrary (or zero) expiry through the create-token endpoint.
accessToken.ExpiresAt = 0

token, err := c.App.CreateUserAccessToken(c.AppContext, &accessToken)
if err != nil {
Expand Down
Loading
Loading