-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2727 from responsible-ai-collaborative/staging
Deploy to Production
- Loading branch information
Showing
13 changed files
with
201 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
site/gatsby-site/cypress/e2e/unit/functions/getUserAdminData.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const getUserAdminData = require('../../../../../realm/functions/getUserAdminData'); | ||
|
||
describe('getUserAdminData', () => { | ||
it('Should not return data if different user id and no permissions', () => { | ||
global.context = { | ||
// @ts-ignore | ||
functions: { | ||
execute: cy.stub().resolves({}), | ||
}, | ||
user: { | ||
id: '2', | ||
custom_data: { | ||
roles: ['subscriber'], | ||
}, | ||
}, | ||
}; | ||
|
||
cy.wrap(getUserAdminData({ userId: '1' })).then((response) => { | ||
expect(global.context.functions.execute).to.not.called; | ||
expect(response.email).to.be.null; | ||
}); | ||
}); | ||
|
||
it('Should return data if user id is the same as current user', () => { | ||
global.context = { | ||
// @ts-ignore | ||
functions: { | ||
execute: cy.stub().resolves({ data: { email: '[email protected]' } }), | ||
}, | ||
user: { | ||
id: '1', | ||
custom_data: { | ||
roles: ['subscriber'], | ||
}, | ||
}, | ||
}; | ||
|
||
cy.wrap(getUserAdminData({ userId: '1' })).then((response) => { | ||
expect(global.context.functions.execute).to.have.been.calledOnce; | ||
expect(response.email).to.equal('[email protected]'); | ||
}); | ||
}); | ||
|
||
it('Should return data if user is admin', () => { | ||
global.context = { | ||
// @ts-ignore | ||
functions: { | ||
execute: cy.stub().resolves({ data: { email: '[email protected]' } }), | ||
}, | ||
user: { | ||
id: '1', | ||
custom_data: { | ||
roles: ['admin'], | ||
}, | ||
}, | ||
}; | ||
|
||
cy.wrap(getUserAdminData({ userId: '3211231' })).then((response) => { | ||
expect(global.context.functions.execute).to.have.been.calledOnce; | ||
expect(response.email).to.equal('[email protected]'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
site/gatsby-site/migrations/2024.04.16T20.04.34.delete-dummy-translations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const languages = require('../i18n/config.json'); | ||
|
||
/** | ||
* | ||
* @param {{context: {client: import('mongodb').MongoClient}}} context | ||
*/ | ||
|
||
exports.up = async ({ context: { client } }) => { | ||
const db = client.db('translations'); | ||
|
||
for (const language of languages) { | ||
const name = `reports_${language.code}`; | ||
|
||
console.log(`Deleting dummy translations from ${name}`); | ||
|
||
const translations = db.collection(name); | ||
|
||
const result = await translations.deleteMany({ | ||
text: /^translated-/, | ||
}); | ||
|
||
console.log(`Deleted ${result.deletedCount} dummy translations for ${language.code}`); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters