Skip to content

Commit

Permalink
make string? replace nullable in Replace controller & autoformat & ch…
Browse files Browse the repository at this point in the history
…ange order of test
  • Loading branch information
qdraw committed Oct 3, 2024
1 parent 86abe6d commit 43235eb
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 313 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,54 +64,6 @@ describe('Archive (from upload) (21)', () => {
).should('have.length', 1)
})

it('test realtime update 2 websockets (21)', {
retries: { runMode: 4, openMode: 2 }
}, () => {
return new Cypress.Promise((resolve) => {

// skip this test currently for windows

if (!config.isEnabled || Cypress.platform === 'win32') {
cy.log(`test skipped isEnabled: ${config.isEnabled} platform: ${Cypress.platform}` )
resolve();
return;
}

const sourceTags = 'tete de balacha, bergtop, mist, flaine'
const url = Cypress.config().baseUrl
const socketUrl =
url
.replace(config.url, '')
.replace('http://', 'ws://')
.replace('https://', 'wss://') + config.realtime
const socket = new WebSocket(socketUrl)
const keyword = `realtime-update-test${Math.floor(Math.random() * 100)}`

socket.onmessage = function (message: {data: string}) {
if (
message.data.includes(keyword) &&
message.data.includes('/starsky-end2end-test/20200822_111408.jpg') &&
message.data.includes('"type":"MetaUpdate"')
) {
resolve()
}
}

cy.request({
method: 'POST',
url: config.updateApi, // baseUrl is prepend to URL
form: true, // indicates the body should be form urlencoded and sets Content-Type: application/x-www-form-urlencoded headers
body: {
append: false,
collections: true,
tags: keyword,
f: '/starsky-end2end-test/20200822_111408.jpg'
}
})
resetAfterwards(sourceTags)
})
})

it('test realtime update notification api 3 (21)', () => {
if (!config.isEnabled) return

Expand Down Expand Up @@ -161,52 +113,53 @@ describe('Archive (from upload) (21)', () => {
resetAfterwards(sourceTags)
})

// test fails always
// xit('test realtime update (21)', {
// retries: { runMode: 2, openMode: 2 }
// }, async () => {
// if (!config.isEnabled) return

// await new Cypress.Promise((resolve) => {
// if (!config.isEnabled) return

// const sourceTags = 'tete de balacha, bergtop, mist, flaine'
// const keyword = `realtime-update-test${Math.floor(Math.random() * 100)}`

// cy.window().should(({ window }) => {
// window.document.body.addEventListener(
// 'USE_SOCKETS',
// (dataItem: any) => {
// console.log(dataItem.detail.data)

// for (const item1 of dataItem.detail.data) {
// if (
// item1.tags.includes(keyword) &&
// item1.filePath.includes(
// '/starsky-end2end-test/20200822_111408.jpg'
// )
// ) {
// resolve()
// }
// }
// }
// )

// cy.request({
// method: 'POST',
// url: config.updateApi, // baseUrl is prepend to URL
// form: true, // indicates the body should be form urlencoded and sets Content-Type: application/x-www-form-urlencoded headers
// body: {
// append: false,
// collections: true,
// tags: keyword,
// f: '/starsky-end2end-test/20200822_111408.jpg'
// }
// })
// resetAfterwards(sourceTags)
// })
// })
// })
it('test realtime update 2 websockets (21)', {
retries: { runMode: 4, openMode: 2 }
}, () => {
return new Cypress.Promise((resolve) => {

// skip this test currently for windows

if (!config.isEnabled || Cypress.platform === 'win32') {
cy.log(`test skipped isEnabled: ${config.isEnabled} platform: ${Cypress.platform}` )
resolve();
return;
}

const sourceTags = 'tete de balacha, bergtop, mist, flaine'
const url = Cypress.config().baseUrl
const socketUrl =
url
.replace(config.url, '')
.replace('http://', 'ws://')
.replace('https://', 'wss://') + config.realtime
const socket = new WebSocket(socketUrl)
const keyword = `realtime-update-test${Math.floor(Math.random() * 100)}`

socket.onmessage = function (message: {data: string}) {
if (
message.data.includes(keyword) &&
message.data.includes('/starsky-end2end-test/20200822_111408.jpg') &&
message.data.includes('"type":"MetaUpdate"')
) {
resolve()
}
}

cy.request({
method: 'POST',
url: config.updateApi, // baseUrl is prepend to URL
form: true, // indicates the body should be form urlencoded and sets Content-Type: application/x-www-form-urlencoded headers
body: {
append: false,
collections: true,
tags: keyword,
f: '/starsky-end2end-test/20200822_111408.jpg'
}
})
resetAfterwards(sourceTags)
})
})

function resetAfterwards (sourceTags: string): void {
cy.log('next step: reset afterwards')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
using System.Threading.Tasks;
using starsky.foundation.database.Models;

namespace starsky.feature.metaupdate.Interfaces
namespace starsky.feature.metaupdate.Interfaces;

public interface IMetaReplaceService
{
public interface IMetaReplaceService
{
Task<List<FileIndexItem>> Replace(string f, string fieldName,
string search, string replace, bool collections);
}
Task<List<FileIndexItem>> Replace(string f, string fieldName,
string search, string? replace, bool collections);
}
Loading

0 comments on commit 43235eb

Please sign in to comment.