streamlit

Форк
0
/
staticfiles_app.spec.js 
57 строк · 1.8 Кб
1
/**
2
 * Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024)
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17

18
const STATICFILE_URL = 'http://localhost:8501/app/static/streamlit-mark-color.png';
19

20
describe("static files", () => {
21
  beforeEach(() => {
22
    cy.intercept(
23
      STATICFILE_URL,
24

25
      // Disable browser cache, so cy.intercept works on every rerun of the
26
      // test. Useful for debugging.
27
      { middleware: true },
28
      (req) => {
29
        req.on('before:response', (res) => {
30
          // force all API responses to not be cached
31
          res.headers['cache-control'] = 'no-store'
32
        })
33
      },
34
    ).as('staticFileLoad');
35

36
    cy.loadApp("http://localhost:3000/");
37
  });
38

39
  it("loads streamlit_app with static image", () => {
40
    cy.wait("@staticFileLoad").get("img").first().matchThemedSnapshots(
41
      "static_streamlit_logo", {},
42
      () => cy.get("img").first()
43
    );
44
  });
45

46
  it("serves existing static file correctly", () => {
47
    cy.request(STATICFILE_URL).its('status').should('eq', 200);
48
  });
49

50
  it("does not serve non-existing static file, return 404", () => {
51
    cy.request(
52
      {
53
        url: 'http://localhost:8501/app/static/notexisting.jpeg',
54
        failOnStatusCode: false
55
      }).its('status').should('equal', 404)
56
  });
57
});
58

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.