mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Backports the following commits to 6.7: - [chance] ensure random words are unique (#35302)
This commit is contained in:
parent
375f9c61e1
commit
da37619e5e
1 changed files with 16 additions and 4 deletions
|
@ -33,6 +33,18 @@ import { PUBLIC_PATH_PLACEHOLDER } from '../../public_path_placeholder';
|
|||
const chance = new Chance();
|
||||
const outputFixture = resolve(__dirname, './fixtures/output');
|
||||
|
||||
const randomWordsCache = new Set();
|
||||
const uniqueRandomWord = () => {
|
||||
const word = chance.word();
|
||||
|
||||
if (randomWordsCache.has(word)) {
|
||||
return uniqueRandomWord();
|
||||
}
|
||||
|
||||
randomWordsCache.add(word);
|
||||
return word;
|
||||
};
|
||||
|
||||
function replaceAll(source, replace, replaceWith) {
|
||||
return source.split(replace).join(replaceWith);
|
||||
}
|
||||
|
@ -170,7 +182,7 @@ describe('optimizer/bundle route', () => {
|
|||
|
||||
describe('js file with placeholder', () => {
|
||||
it('responds with no content-length and modified file data', async () => {
|
||||
const basePublicPath = `/${chance.word()}`;
|
||||
const basePublicPath = `/${uniqueRandomWord()}`;
|
||||
const server = createServer({ basePublicPath });
|
||||
|
||||
const response = await server.inject({
|
||||
|
@ -207,7 +219,7 @@ describe('optimizer/bundle route', () => {
|
|||
|
||||
describe('css file with placeholder', () => {
|
||||
it('responds with no content-length and modified file data', async () => {
|
||||
const basePublicPath = `/${chance.word()}`;
|
||||
const basePublicPath = `/${uniqueRandomWord()}`;
|
||||
const server = createServer({ basePublicPath });
|
||||
|
||||
const response = await server.inject({
|
||||
|
@ -304,8 +316,8 @@ describe('optimizer/bundle route', () => {
|
|||
});
|
||||
|
||||
it('is unique per basePublicPath although content is the same', async () => {
|
||||
const basePublicPath1 = `/${chance.word()}`;
|
||||
const basePublicPath2 = `/${chance.word()}`;
|
||||
const basePublicPath1 = `/${uniqueRandomWord()}`;
|
||||
const basePublicPath2 = `/${uniqueRandomWord()}`;
|
||||
|
||||
const [resp1, resp2] = await Promise.all([
|
||||
createServer({ basePublicPath: basePublicPath1 }).inject({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue