streamlit
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
18const STATICFILE_URL = 'http://localhost:8501/app/static/streamlit-mark-color.png';19
20describe("static files", () => {21beforeEach(() => {22cy.intercept(23STATICFILE_URL,24
25// Disable browser cache, so cy.intercept works on every rerun of the26// test. Useful for debugging.27{ middleware: true },28(req) => {29req.on('before:response', (res) => {30// force all API responses to not be cached31res.headers['cache-control'] = 'no-store'32})33},34).as('staticFileLoad');35
36cy.loadApp("http://localhost:3000/");37});38
39it("loads streamlit_app with static image", () => {40cy.wait("@staticFileLoad").get("img").first().matchThemedSnapshots(41"static_streamlit_logo", {},42() => cy.get("img").first()43);44});45
46it("serves existing static file correctly", () => {47cy.request(STATICFILE_URL).its('status').should('eq', 200);48});49
50it("does not serve non-existing static file, return 404", () => {51cy.request(52{53url: 'http://localhost:8501/app/static/notexisting.jpeg',54failOnStatusCode: false55}).its('status').should('equal', 404)56});57});58